irc-robot
Small framework for writing irc bots using node.
var ircbot = ; var bot = ; bot; bot;
API
This is all very much a work in progress, but so far...
ircbot(options)
Creates a new bot.
var ircbot = ;var bot = ;
Options
Required
name
chan
||channel
Optional
password
(default:"password"
)realname
(default:"I am a bot"
)server
(default:"irc.freenode.org"
)port
(default:6667
)debug
(default:false
)
bot.on(regex, cb)
Calls the callback when a message in the channel matches the regex.
The callback takes 2 arguments:
request
object
from
- nick of user who sent messageto
- name of channelmsg
- full string of the messagematches
- return value of msg.match(regex)
response
object
send
- function that sends message to channel
bot;
bot.onPM(regex, cb)
Calls the callback if a PM to the bot matches the regex.
The callback takes 2 arguments:
request
object
from
- nick of user who sent messageto
- bot namemsg
- full string of the messagematches
- return value of msg.match(regex)
response
object
send
- function that sends a PM back to the user
bot;
bot.every(interval, cb)
Calls the callback every interval
milliseconds.
The callback takes 1 argument:
response
object
send
- function that sends a message to the channel
bot;
bot.PM(recipient, message)
Sends a PM.
recipient
can be a string for a user or a channel
bot;
bot.connect()
Connects to the channel and starts listening.