The irc object is one of the arguments passed to supybot methods. There's probably more than just what's on this page, but this is all I've discovered so far.
Contains the name of the network. This is not the hostname of the server (e.g. not "irc.freenode.net"), but the name that you provide for the network when you do @connect <network> <host> (e.g. "freenode")
Example: Let's say that you want to spam a network, but only one network (assuming you're connected to multiple networks). You can do something like that with the following:
def [doPrivmsg](Trigger_methods#doPrivmsg)(self, irc, msg):
if irc.network == 'somenetwork':
irc.reply('spam!')
See also: irc.network, irc.reply(), doPrivmsg.
Contains the nick of the bot.
Flag which is true if the command is being called from within a 'nested command', and false if the command is being invoked directly.
You can check the state of this flag if you want your command to output a different reply depending on whether it is being called directly, or as a nested command.
Contains info on the current state of the irc.
Contains a dictionary of the channels that the bot is on.
Example:
if '#SomeChannel' in irc.state.channels:
irc.queueMsg(ircmsgs.privmsg('#someChannel', 'hello!'))
irc.noReply()
See also: irc.queueMsg(), irc.noReply().
Contains an IrcSet object (like a list) of the users in a given channel
TODO: investigate these IrcSet objects. Presumably contains info about the users.
Example:
nick = 'someNick'
if nick in irc.state.channels['#someChannel'].users:
irc.reply('hello, %s!' % nick)
See also: irc.reply().
Contains an IrcSet object of the users who have ops (mode +o) in a given channel
Example:
nick = 'someNick'
if nick in irc.state.channels['#someChannel'].ops:
irc.reply('wow, %s is an op!' % nick)
See also: irc.reply().
Contains an IrcSet object of the users who have halfops (mode +h) in a given channel
Contains an IrcSet object of the users who have voice (mode +v) in a given channel
irc.reply(message)
Replies to a command. message is a string you want to send. Note that there are a couple of cases where an irc object object will not include a reply() method. The irc object only includes reply() if the method is being called from someplace live from IRC, such as when you send the bot a command. You'll have to be careful about this if you have custom init() methods in your plugins. If you do @reload SomePlugin, the irc object passed to init() does include a reply() method, but when the bot is being started from the command line, the irc object does not include reply(). For that reason, if you want to send text to a channel when a plugin is loaded or reloaded in init(), you should use queueMsg() instead, or the plugin load will fail when you start the bot.
Example:
irc.reply('hello')
irc.queueMsg(message)
Queues a message for sending to the server. message should be an ircmsgs object.
Example:
irc.queueMsg(ircmsgs.privmsg('#somechannel','hello'))
irc.noReply()
Note that this example is equivalent to:
irc.reply('hello')
See also: ircmsgs.privmsg(), irc.noReply().
irc.sendMsg(message)
Sends a message immediately to the server, bypassing the internal queueing. message should be an ircmsgs object.
Be careful using this, as you can easily flood out your bot if you send too much too fast. Unless there's some reason you have to reply immediately, you should use reply() or queueMsg() instead.
Example:
irc.sendMsg(ircmsgs.privmsg('#somechannel', 'hello'))
irc.noReply()
See also: ircmsgs.privmsg(), irc.noReply().
Marks a msg object as "replied to". This will prevent the bot from sending a warning to the channel that it didn't recognize the command (if you have that enabled), if your command doesn't include an irc.reply(). It should be included in that case, or you might get some unexpected behavior.
Example:
irc.queueMsg(ircmsgs.privmsg('hello'))
irc.noReply()
See also: ircmsgs.privmsg(), irc.queueMsg().
irc.error(message, Raise)
Outputs a generic error message. message should be a descriptive error message. Raise is a boolean which, if True, will raise an exception with the error. If Raise is false, execution of the command in progress continues.
Example:
irc.error('The network connection timed out.', Raise=True)
irc.errorNoCapability(capability, Raise)
Output a nice reply about a missing required capability. capability should be a string denoting the capability. Raise is a boolean denoting whether to raise an exception with this reply. If Raise is False, the message does not terminate the flow of the function, while if it is True, function will exit at this point.
Example:
capability='admin'
if not ircdb.checkCapability(msg.prefix, capability):
irc.errorNoCapability(capability, Raise=True)
See also: msg.prefix, ircdb.checkCapability().
irc.errorNotRegistered(Raise)
Output a nice reply about a user not being registered. Raise is a boolean denoting whether to raise an exception with this reply. If Raise is False, the message does not terminate the flow of the function, while if it is True, function will exit at this point.
Example:
try:
_ = ircdb.users.getUser(msg.prefix)
except KeyError:
irc.errorNotRegistered(Raise=True)
See also: msg.prefix, ircdb.users.getUser().
irc.isNick(nick)
Check if the string nick is a proper IRC nick. Uses ircutils.isNick(). This function passes the supybot.protocols.irc.strictRfc config to ircutils.isNick(), along with maximum supported nick length, so is probably a better way of checking if something is a valid nick than calling ircutils.isNick() directly..
Example:
irc.isNick('blabla') # true
irc.isNick('moo foo') # definitely false, regardless of whether strictRfc is on.
See also: ircutils.isNick().
irc.isChannel(channel)
Check if the string channel is a proper IRC channel name. Uses ircutils.isChannel(). This function passes appropriate irc state info to ircutils.isChannel(), so is probably a better way of checking if something is a valid channel name than calling ircutils.isChannel() directly.
Example:
irc.isChannel('#somechannel') # returns true
irc.isChannel('somechannel') # returns false
See also: ircutils.isChannel().
Wiki: Ircmsgs_object
Wiki: Msg_object
Wiki: Plugin_object
Wiki: Supybot_Resources
Wiki: Supybot_Resources_Contributor_Guide