Menu

Msg_Object

nanotube Valentin Lorentz quantumlemur

Contains the contents of a message received from the IRC server, broken down into its constituent parts.

msg.nick

A string containing the nick of the person that triggered the method.

Example:

irc.reply('This method was triggered by %s' % msg.nick)

See also: irc.reply()

msg.host

A string containing the host of the person that triggered the method.

msg.user

A string containing the IRC user name of the person that triggered the method. This isn't the nick, it's the part marked by the blank in this hostmask: !__@.*

msg.prefix

Contains the full hostmask (of the form nick!user@host) of the user that triggered the method.

See also: msg.nick, msg.user, msg.host

msg.args

A tuple containing the arguments of the message received from the IRC server. Its contents differ depending on the type of message, but some patterns are in evidence:

TODO: may be better to just list these by message type. As it is, this is harder to parse and is probably incomplete.

msg.args[0]

Nearly always the place from which the triggering message came, so a channel name if it's called from a channel, or a nick if it's called in a query.

The exception is IRC messages that don't include a context, such as QUITs and NICKs. In that case, msg.args[0] contains the quit message or the new nick, respectively. See doQuit(), doNick() for more information.

def doPrivmsg(self, irc, msg):
    if msg.args[0] == '#someChannel':
        irc.reply('I just heard someone talk on #someChannel!')

See also: doPrivmsg(), irc.reply().

msg.args[1]

Nearly always contains the text of the message. One exception is MODE changes, in which case msg.args[1] contains the actual modes in question (like "+o"). See doMode() for more information.

def doPrivmsg(self, irc, msg):
    if irc.nick in msg.args[1]:
        irc.reply('hey, someone just highlighted me!')

See also: doPrivmsg(), irc.reply(), irc.nick.

msg.args[2]

Present in a MODE changes, and KICKs.

For mode change, contains the target(s) of the mode change. For kicks, contains the kick message (msg.args[1] contains the target of the kick).

def doMode(self, irc, msg):
    if irc.nick in msg.args[2]:
        irc.reply('oh my, I just got my mode changed!  Someone did %s to me!' % msg.args[1])

See also: doMode(), doKick(), irc.reply(), irc.nick.

msg.command

Contains the type of message, for example "PRIVMSG", "NOTICE", "JOIN", "PART", "QUIT", "MODE".

msg.tag(string, object)

This is a method dedicated to internal mechanism of Supybot, that sets the tag (a string) to the value (an object)

msg.tags

Array used for internal purposes.


Related

Wiki: Msg_object