コード例 #1
0
ファイル: channel.py プロジェクト: AdamPrzybyla/jjigw
 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))
コード例 #2
0
ファイル: channel.py プロジェクト: AdamPrzybyla/jjigw
 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)
コード例 #3
0
ファイル: channel.py プロジェクト: ivucica/jjigw
 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)
コード例 #4
0
ファイル: channel.py プロジェクト: ivucica/jjigw
 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))
コード例 #5
0
 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)
コード例 #6
0
    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)
コード例 #7
0
ファイル: ircsession.py プロジェクト: AdamPrzybyla/jjigw
 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)