def irc_PRIVMSG(self, prefix, params): """ Called when we get a message. """ user = prefix channel = params[0] message = params[-1] if not message: # Don't raise an exception if we get blank message. return if message[0] == X_DELIM: m = ctcpExtract(message) if m['extended']: self.ctcpQuery(user, channel, m['extended'], params) if not m['normal']: return message = ' '.join(m['normal']) nick, ident, host = processHostmask(prefix) if nick == self.nickname: # take note of our prefix! (for message length calculation self.prefixlen = len(prefix) # These are actually messages, ctcp's aren't dispatched here self.dispatch(self, "privmsged", prefix=prefix, params=params, hostmask=user, target=channel, msg=message, nick=nick, ident=ident, host=host)
def irc_PRIVMSG(self, prefix, params): """ Called when we get a message. """ if self.debug >= 2: print "INCOMING PRIVMSG:", prefix, params user = prefix channel = params[0] message = params[-1] if not message: # Don't raise an exception if we get blank message. return if message[0] == X_DELIM: m = ctcpExtract(message) if m['extended']: self.ctcpQuery(user, channel, m['extended'], params) if not m['normal']: return message = ' '.join(m['normal']) nick, ident, host = processHostmask(prefix) if nick == self.nickname: # take note of our prefix! (for message length calculation self.prefixlen = len(prefix) # These are actually messages, ctcp's aren't dispatched here self.dispatch(self, "privmsged", prefix=prefix, params=params, hostmask=user, target=channel, msg=message, nick=nick, ident=ident, host=host)
def irc_NOTICE(self, prefix, params): """ Called when a user gets a notice. """ if self.debug >= 2: print "INCOMING NOTICE:", prefix, params user = prefix channel = params[0] message = params[-1] if message[0] == X_DELIM: m = ctcpExtract(message) if m['extended']: self.ctcpReply(user, channel, m['extended'], params) if not m['normal']: return message = ' '.join(m['normal']) nick, ident, host = processHostmask(prefix) if nick == self.nickname: # take note of our prefix! (for message length calculation self.prefixlen = len(prefix) self.dispatch(self, "noticed", prefix=prefix, params=params, hostmask=user, target=channel, msg=message, nick=nick, ident=ident, host=host)
def _privmsg(self, source, dest, message): if (len(message) > 0) and (message[0] == '\x01') and (message[-1] == '\x01'): m = ctcpExtract(message) if m['extended']: self.ctcpQuery(str(source), str(dest), m['extended']) if not m['normal']: return message = string.join(m['normal'], ' ') self.privmsg(str(source), str(dest), message)
def irc_PRIVMSG(self, prefix, params): channel = params[0] nickname = prefix.split("!")[0] d = irc.ctcpExtract(params[1]) if d["extended"] != []: message = d["extended"][0][1] self.emit("me-command", channel, nickname, message) else: irc.IRCClient.irc_PRIVMSG(self, prefix, params)
def parse_ctcpable_directed_message(command, params): kwargs = parse_directed_message(command, params) if params[1].startswith(X_DELIM): # CTCP extended message quoting is pathologically designed, but # nobody actually sends more than one at a time. Thankfully. tag, data = ctcpExtract(params[1])['extended'][0] kwargs['content'] = data if tag.lower() == 'action': kwargs['action'] = 'action' else: kwargs['action'] = ('ctcpquery' if command == 'PRIVMSG' else 'ctcpreply') kwargs['subaction'] = tag return kwargs
def notice(self, to, msg): irc.IRCClient.notice(self, to, msg) if msg and msg[0] == irc.X_DELIM: # Ignore any CTCP stuff ctcp = irc.ctcpExtract(msg) if not ctcp['normal']: return msg = " ".join(ctcp['normal']) event = { 'internal': True, 'type': 'notice', 'sent_by': self.nickname, 'sent_to': to, 'reply_to': None, 'text': msg, 'time': time.time() } self.manager.plugins.hook(self, event)