コード例 #1
0
ファイル: test.py プロジェクト: J4LP/rooster
    def serve_forever(self):
        import config

        self.jid = 'Err@localhost'  # whatever
        self.connect()  # be sure we are "connected" before the first command
        self.connect_callback()  # notify that the connection occured
        self.sender = config.BOT_ADMINS[0]  # By default, assume this is the admin talking
        try:
            while True:
                stanza_type, entry = incoming_stanza_queue.get()
                if entry == QUIT_MESSAGE:
                    logging.info("Stop magic message received, quitting...")
                    break
                if stanza_type is STZ_MSG:
                    msg = Message(entry)
                    msg.setFrom(self.sender)
                    msg.setTo(self.jid)  # To me only
                    self.callback_message(self.conn, msg)
                elif stanza_type is STZ_PRE:
                    logging.info("Presence stanza received.")
                elif stanza_type is STZ_IQ:
                    logging.info("IQ stanza received.")
                else:
                    logging.error("Unknown stanza type.")

        except EOFError as _:
            pass
        except KeyboardInterrupt as _:
            pass
        finally:
            logging.debug("Trigger disconnect callback")
            self.disconnect_callback()
            logging.debug("Trigger shutdown")
            self.shutdown()
コード例 #2
0
ファイル: irc.py プロジェクト: P-Product/err
 def on_pubmsg(self, c, e):
     msg = Message(e.arguments[0])
     msg.setFrom(e.target)
     msg.setTo(self.callback.jid)
     msg.setMuckNick(e.source.split('!')[0])  # FIXME find the real nick in the channel
     msg.setType('groupchat')
     self.callback.callback_message(self, msg)
コード例 #3
0
ファイル: test.py プロジェクト: will-kanjoya/err
    def serve_forever(self):
        import config

        self.jid = 'Err@localhost'  # whatever
        self.connect()  # be sure we are "connected" before the first command
        self.connect_callback()  # notify that the connection occured
        self.sender = config.BOT_ADMINS[0]  # By default, assume this is the admin talking
        try:
            while True:
                entry = incoming_message_queue.get()
                if entry == QUIT_MESSAGE:
                    logging.info("Stop magic message received, quitting...")
                    break
                msg = Message(entry)
                msg.setFrom(self.sender)
                msg.setTo(self.jid)  # To me only
                self.callback_message(self.conn, msg)
        except EOFError as _:
            pass
        except KeyboardInterrupt as _:
            pass
        finally:
            logging.debug("Trigger disconnect callback")
            self.disconnect_callback()
            logging.debug("Trigger shutdown")
            self.shutdown()
コード例 #4
0
 def send_command(self, text):
     self.new_message(text, False)
     msg = Message(text)
     msg.setFrom(config.BOT_ADMINS[0])  # assume this is the admin talking
     msg.setTo(self.jid)  # To me only
     self.callback_message(self.conn, msg)
     self.input.clear()
コード例 #5
0
ファイル: irc.py プロジェクト: will-kanjoya/err
 def on_pubmsg(self, c, e):
     msg = Message(e.arguments[0])
     msg.setFrom(e.target)
     msg.setTo(self.callback.jid)
     msg.setMuckNick(e.source.split('!')[0])  # FIXME find the real nick in the channel
     msg.setType('groupchat')
     self.callback.callback_message(self, msg)
コード例 #6
0
ファイル: test.py プロジェクト: P-Product/err
    def serve_forever(self):
        import config

        self.jid = 'Err@localhost'  # whatever
        self.connect()  # be sure we are "connected" before the first command
        self.connect_callback()  # notify that the connection occured
        try:
            while True:
                entry = incoming_message_queue.get()
                if entry == QUIT_MESSAGE:
                    logging.info("Stop magic message received, quitting...")
                    break
                msg = Message(entry)
                msg.setFrom(config.BOT_ADMINS[0])  # assume this is the admin talking
                msg.setTo(self.jid)  # To me only
                self.callback_message(self.conn, msg)
        except EOFError as _:
            pass
        except KeyboardInterrupt as _:
            pass
        finally:
            logging.debug("Trigger disconnect callback")
            self.disconnect_callback()
            logging.debug("Trigger shutdown")
            self.shutdown()
コード例 #7
0
ファイル: graphic.py プロジェクト: linuxtechie/err
 def send_command(self, text):
     self.new_message(text, False)
     msg = Message(text)
     msg.setFrom(config.BOT_ADMINS[0])  # assume this is the admin talking
     msg.setTo(self.jid)  # To me only
     self.callback_message(self.conn, msg)
     self.input.clear()
コード例 #8
0
ファイル: xmpp.py プロジェクト: P-Product/err
 def incoming_message(self, xmppmsg):
     msg = Message(xmppmsg['body'])
     msg.setFrom(xmppmsg['from'].bare)
     msg.setTo(xmppmsg['to'].bare)
     msg.setType(xmppmsg['type'])
     msg.setMuckNick(xmppmsg['mucnick'])
     msg.setDelayed(bool(xmppmsg['delay']._get_attr('stamp')))  # this is a bug in sleekxmpp it should be ['from']
     self.callback_message(self.conn, msg)
コード例 #9
0
ファイル: campfire.py プロジェクト: linuxtechie/err
 def msg_callback(self, message):
     logging.debug('Incoming message [%s]' % message)
     user = ""
     if message.user:
         user = message.user.name
     if message.is_text():
         msg = Message(message.body, typ='groupchat')  # it is always a groupchat in campfire
         msg.setFrom(user + '@' + message.room.get_data()['name'] + '/' + user)
         msg.setTo(self.jid)  # assume it is for me
         self.callback_message(self.conn, msg)
コード例 #10
0
ファイル: xmpp.py プロジェクト: avallark/err
 def incoming_message(self, xmppmsg):
     """Callback for message events"""
     msg = Message(xmppmsg['body'])
     if 'html' in xmppmsg.keys():
         msg.setHTML(xmppmsg['html'])
     msg.setFrom(xmppmsg['from'].full)
     msg.setTo(xmppmsg['to'].full)
     msg.setType(xmppmsg['type'])
     msg.setMuckNick(xmppmsg['mucnick'])
     msg.setDelayed(bool(xmppmsg['delay']._get_attr('stamp')))  # this is a bug in sleekxmpp it should be ['from']
     self.callback_message(self.conn, msg)
コード例 #11
0
ファイル: xmpp.py プロジェクト: tjardick/err
 def incoming_message(self, xmppmsg):
     """Callback for message events"""
     msg = Message(xmppmsg['body'])
     if 'html' in xmppmsg.keys():
         msg.setHTML(xmppmsg['html'])
     msg.setFrom(xmppmsg['from'].full)
     msg.setTo(xmppmsg['to'].full)
     msg.setType(xmppmsg['type'])
     msg.setMuckNick(xmppmsg['mucnick'])
     msg.setDelayed(bool(xmppmsg['delay']._get_attr(
         'stamp')))  # this is a bug in sleekxmpp it should be ['from']
     self.callback_message(self.conn, msg)
コード例 #12
0
ファイル: campfire.py プロジェクト: achew22/err
 def msg_callback(self, message):
     logging.debug('Incoming message [%s]' % message)
     user = ""
     if message.user:
         user = message.user.name
     if message.is_text():
         msg = Message(
             message.body,
             typ='groupchat')  # it is always a groupchat in campfire
         msg.setFrom(user + '@' + message.room.get_data()['name'] + '/' +
                     user)
         msg.setTo(self.jid)  # assume it is for me
         self.callback_message(self.conn, msg)
コード例 #13
0
ファイル: irc.py プロジェクト: linuxtechie/err
    def irc_PRIVMSG(self, prefix, params):
        fr, line = params
        if fr == self.nickname:  # it is a private message
            from_identity = Identifier(node=self.extract_from_from_prefix(prefix))  # reextract the real from
            typ = 'chat'
        else:
            from_identity = Identifier(node=fr, resource=self.extract_from_from_prefix(prefix))  # So we don't loose the original sender and the chatroom
            typ = 'groupchat'
        logging.debug('IRC message received from %s [%s]' % (fr, line))

        msg = Message(line, typ=typ)
        msg.setFrom(from_identity)
        msg.setTo(params[0])
        self.callback.callback_message(self, msg)
コード例 #14
0
ファイル: text.py プロジェクト: DazWorrall/err
 def serve_forever(self):
     self.jid = 'Err@localhost'  # whatever
     self.connect()  # be sure we are "connected" before the first command
     self.connect_callback()  # notify that the connection occured
     try:
         while True:
             entry = input("Talk to  me >>")
             msg = Message(entry)
             msg.setFrom(config.BOT_ADMINS[0])  # assume this is the admin talking
             msg.setTo(self.jid)  # To me only
             self.callback_message(self.conn, msg)
     except EOFError as eof:
         pass
     except KeyboardInterrupt as ki:
         pass
     finally:
         logging.debug("Trigger disconnect callback")
         self.disconnect_callback()
         logging.debug("Trigger shutdown")
         self.shutdown()
コード例 #15
0
ファイル: text.py プロジェクト: achew22/err
 def serve_forever(self):
     self.jid = 'Err@localhost'  # whatever
     self.connect()  # be sure we are "connected" before the first command
     self.connect_callback()  # notify that the connection occured
     try:
         while True:
             entry = raw_input("Talk to  me >>").decode(ENCODING_INPUT)
             msg = Message(entry)
             msg.setFrom(
                 config.BOT_ADMINS[0])  # assume this is the admin talking
             msg.setTo(self.jid)  # To me only
             self.callback_message(self.conn, msg)
     except EOFError as eof:
         pass
     except KeyboardInterrupt as ki:
         pass
     finally:
         logging.debug("Trigger disconnect callback")
         self.disconnect_callback()
         logging.debug("Trigger shutdown")
         self.shutdown()
コード例 #16
0
ファイル: irc.py プロジェクト: sanketsudake/err
 def on_privmsg(self, c, e):
     msg = Message(e.arguments[0])
     msg.setFrom(e.source.split('!')[0])
     msg.setTo(e.target)
     msg.setType('chat')
     self.callback.callback_message(self, msg)
コード例 #17
0
ファイル: irc.py プロジェクト: P-Product/err
 def on_privmsg(self, c, e):
     msg = Message(e.arguments[0])
     msg.setFrom(e.source.split('!')[0])
     msg.setTo(e.target)
     msg.setType('chat')
     self.callback.callback_message(self, msg)