Esempio n. 1
0
File: test.py Progetto: 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()
Esempio n. 2
0
File: irc.py Progetto: 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)
Esempio n. 3
0
    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()
Esempio n. 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()
Esempio n. 5
0
 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)
Esempio n. 6
0
    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()
Esempio n. 7
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()
Esempio n. 8
0
 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)
Esempio n. 9
0
 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)
Esempio n. 10
0
File: xmpp.py Progetto: 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)
Esempio n. 11
0
File: xmpp.py Progetto: 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)
Esempio n. 12
0
 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)
Esempio n. 13
0
    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)
Esempio n. 14
0
 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()
Esempio n. 15
0
File: text.py Progetto: 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()
Esempio n. 16
0
 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)
Esempio n. 17
0
File: irc.py Progetto: 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)