def irc_cmd_332(self, prefix, command, params): # RPL_TOPIC topic = remove_evil_characters(params[1]) m = Message(from_jid=self.room_jid.bare(), to_jid=self.session.jid, stanza_type="groupchat", subject=unicode(topic, self.encoding, "replace")) self.session.component.send(m)
def irc_cmd_TOPIC(self, prefix, command, params): self.requests.get("TOPIC") topic = remove_evil_characters(params[1]) m = Message(from_jid=self.prefix_to_jid(prefix), to_jid=self.session.jid, stanza_type="groupchat", subject=unicode(topic, self.encoding, "replace")) self.session.component.send(m)
def CTCP(self,prefix,command): if " " in command: command,arg=command.split(" ",1) else: arg=None if command=="ACTION": m=Message(stanza_type="groupchat",from_jid=self.prefix_to_jid(prefix),to_jid=self.session.jid, body="/me "+remove_evil_characters(strip_colors(arg))) self.session.component.send(m) else: self.__logger.debug("Unknown CTCP command: %r %r" % (command,arg))
def irc_message(self,prefix,command,params): if not self.state or len(params)<2: self.__logger.debug("ignoring it") return body=unicode(params[1],self.encoding,"replace") if body[0]=="\001" and body[-1]=="\001": self.CTCP(prefix,body[1:-1]) else: m=Message(stanza_type="groupchat",from_jid=self.prefix_to_jid(prefix),to_jid=self.session.jid, body=remove_evil_characters(strip_colors(body))) self.session.component.send(m)
def irc_message(self, prefix, command, params): if not self.state or len(params) < 2: self.__logger.debug("ignoring it") return body = unicode(params[1], self.encoding, "replace") if body[0] == "\001" and body[-1] == "\001": self.CTCP(prefix, body[1:-1]) else: m = Message(stanza_type="groupchat", from_jid=self.prefix_to_jid(prefix), to_jid=self.session.jid, body=remove_evil_characters(strip_colors(body))) self.session.component.send(m)
def CTCP(self, prefix, command): if " " in command: command, arg = command.split(" ", 1) else: arg = None if command == "ACTION": m = Message(stanza_type="groupchat", from_jid=self.prefix_to_jid(prefix), to_jid=self.session.jid, body="/me " + remove_evil_characters(strip_colors(arg))) self.session.component.send(m) else: self.__logger.debug("Unknown CTCP command: %r %r" % (command, arg))
def send_error_message(self,source,cond,text): text=remove_evil_characters(text) user=self.get_user(source) if user: self.unregister_user(user) if user and user.current_thread: typ,thread,fr=user.current_thread if not fr: fr=self.prefix_to_jid(source) m=Message(stanza_type="error",error_cond=cond,error_text=text, to_jid=self.jid,from_jid=fr,thread=thread) else: fr=self.prefix_to_jid(source) m=Message(stanza_type="error",error_cond=cond,error_text=text, to_jid=self.jid,from_jid=fr) self.component.send(m)
def pass_input_to_raw_channel(self,prefix,command,params): body=string.join([command]+params) body=`body` if body[0] in '"\'': body=body[1:-1] body=unicode(body,self.default_encoding,"replace") if prefix: prefix=remove_evil_characters(prefix) prefix=`prefix` if prefix[0] in '"\'': prefix=prefix[1:-1] prefix=unicode(prefix,self.default_encoding,"replace") else: prefix=None fr=JID('#',self.network.jid.domain,prefix) m=Message(to_jid=self.jid,from_jid=fr,body=body,stanza_type="groupchat") self.component.send(m)
def irc_message(self,prefix,command,params): if len(params)<2 or not prefix: self.__logger.debug("ignoring it") return user=self.get_user(prefix) if not user: self.__logger.debug("could not convert %r to IRCUser object" % (prefix,)) return if user.current_thread: typ,thread,fr=user.current_thread else: typ="chat" thread=str(random.random()) fr=None user.current_thread=typ,thread,None if not fr: fr=user.jid() body=unicode(params[1],self.default_encoding,"replace") m=Message(stanza_type=typ,from_jid=fr,to_jid=self.jid,body=remove_evil_characters(strip_colors(body))) self.component.send(m)
def irc_message(self,prefix,command,params): if len(params)<2 or not prefix: self.__logger.debug("ignoring it") return user=self.get_user(prefix) if not user: self.__logger.debug("could not convert %r to IRCUser object" % (prefix,)) return if user.current_thread: typ,thread,fr=user.current_thread else: typ="chat" thread=str(random.random()) fr=None user.current_thread=typ,thread,None do_invite = False if params[0][0]=='#': # This should be a PM but it was still aimed at a channel. # Invite the user and send the message from the channel. fr='%s@%s/%s' % (params[0], self.network.jid.domain, user.nick) do_invite=True if not fr: fr=user.jid() body=unicode(params[1],self.default_encoding,"replace") m=Message(stanza_type=typ,from_jid=fr,to_jid=self.jid,body=remove_evil_characters(strip_colors(body))) if do_invite: # <x tag> x = m.xmlnode.newTextChild(None, 'x', None) x.setNs(x.newNs('http://jabber.org/protocol/muc#user', None)) # <invite to="buddy to invite"><reason>Plz come chat</reason></invite> invite = x.newTextChild(None, 'invite', None) invite.setProp('to', self.jid) reason = invite.newTextChild(None, 'reason', '(You are not in the channel yet.)') self.component.send(m)
def irc_message(self, prefix, command, params): if len(params) < 2 or not prefix: self.__logger.debug("ignoring it") return user = self.get_user(prefix) if not user: self.__logger.debug("could not convert %r to IRCUser object" % (prefix, )) return if user.current_thread: typ, thread, fr = user.current_thread else: typ = "chat" thread = str(random.random()) fr = None user.current_thread = typ, thread, None if not fr: fr = user.jid() body = unicode(params[1], self.default_encoding, "replace") m = Message(stanza_type=typ, from_jid=fr, to_jid=self.jid, body=remove_evil_characters(strip_colors(body))) self.component.send(m)
def irc_cmd_TOPIC(self,prefix,command,params): self.requests.get("TOPIC") topic=remove_evil_characters(params[1]) m=Message(from_jid=self.prefix_to_jid(prefix),to_jid=self.session.jid, stanza_type="groupchat", subject=unicode(topic,self.encoding,"replace")) self.session.component.send(m)
def irc_cmd_332(self,prefix,command,params): # RPL_TOPIC topic=remove_evil_characters(params[1]) m=Message(from_jid=self.room_jid.bare(),to_jid=self.session.jid, stanza_type="groupchat", subject=unicode(topic,self.encoding,"replace")) self.session.component.send(m)