예제 #1
0
파일: silc.py 프로젝트: shoosen/ibid
    def connected(self):
        for channel in self.factory.channels:
            self.join(channel)

        event = Event(self.factory.name, u'source')
        event.status = u'connected'
        ibid.dispatcher.dispatch(event)
예제 #2
0
파일: silc.py 프로젝트: B-Rich/ibid-1
    def connected(self):
        for channel in self.factory.channels:
            self.join(channel)

        event = Event(self.factory.name, u'source')
        event.status = u'connected'
        ibid.dispatcher.dispatch(event)
예제 #3
0
파일: irc.py 프로젝트: B-Rich/ibid-1
    def connectionLost(self, reason):
        self.factory.log.info(u"Disconnected (%s)", reason)

        event = Event(self.factory.name, u'source')
        event.status = u'disconnected'
        ibid.dispatcher.dispatch(event)

        irc.IRCClient.connectionLost(self, reason)
예제 #4
0
    def connectionLost(self, reason):
        self.parent.log.info(u"Disconnected (%s)", reason)

        event = Event(self.parent.name, u'source')
        event.status = u'disconnected'
        ibid.dispatcher.dispatch(event)

        subprotocols.XMPPHandler.connectionLost(self, reason)
예제 #5
0
파일: irc.py 프로젝트: rsnyman/ibid
    def connectionLost(self, reason):
        self.factory.log.info(u"Disconnected (%s)", reason)

        event = Event(self.factory.name, u'source')
        event.status = u'disconnected'
        ibid.dispatcher.dispatch(event)

        irc.IRCClient.connectionLost(self, reason)
예제 #6
0
파일: core.py 프로젝트: oguya/ibid
    def call_later(self, delay, callable, oldevent, *args, **kw):
        "Run callable after delay seconds. Pass args and kw to it"

        event = Event(oldevent.source, u'delayed')
        event.sender = oldevent.sender
        event.channel = oldevent.channel
        event.public = oldevent.public
        return reactor.callLater(delay, threads.deferToThread, self.delayed_call, callable, event, *args, **kw)
예제 #7
0
파일: core.py 프로젝트: ibid/ibid
    def call_later(self, delay, callable, oldevent, *args, **kw):
        "Run callable after delay seconds. Pass args and kw to it"

        event = Event(oldevent.source, u'delayed')
        event.sender = oldevent.sender
        event.channel = oldevent.channel
        event.public = oldevent.public
        return reactor.callLater(delay, threads.deferToThread, self.delayed_call, callable, event, *args, **kw)
예제 #8
0
파일: http.py 프로젝트: B-Rich/ibid-1
 def render_POST(self, request):
     event = Event(self.name, u'message')
     event.sender['nick'] = event.sender['id'] = event.sender['connection'] = event.channel = unicode(request.transport.getPeer().host)
     event.addressed = True
     event.public = False
     event.message = unicode(request.args['m'][0], 'utf-8', 'replace')
     self.log.debug(u"Received GET request from %s: %s", event.sender['connection'], event.message)
     ibid.dispatcher.dispatch(event).addCallback(self.respond, request)
     return server.NOT_DONE_YET
예제 #9
0
파일: http.py 프로젝트: shoosen/ibid
 def render_POST(self, request):
     event = Event(self.name, u'message')
     event.sender['nick'] = event.sender['id'] = event.sender['connection'] = event.channel = unicode(request.transport.getPeer().host)
     event.addressed = True
     event.public = False
     event.message = unicode(request.args['m'][0], 'utf-8', 'replace')
     self.log.debug(u"Received GET request from %s: %s", event.sender['connection'], event.message)
     ibid.dispatcher.dispatch(event).addCallback(self.respond, request)
     return server.NOT_DONE_YET
예제 #10
0
 def create_event(self, message, event_type=u'message'):
     event = Event(u'fakesource', event_type)
     event.message = {
         'raw': message,
         'deaddressed': message,
         'clean': message,
         'stripped': message,
     }
     return event
예제 #11
0
파일: test_core.py 프로젝트: vhata/ibid
 def create_event(self, message, event_type=u'message'):
     event = Event(u'fakesource', event_type)
     event.message = {
         'raw': message,
         'deaddressed': message,
         'clean': message,
         'stripped': message,
     }
     return event
예제 #12
0
 def remote_message(self, message):
     event = Event(self.name, u'message')
     event.sender['connection'] = event.sender['id'] = event.sender[
         'nick'] = event.channel = self.name
     event.addressed = True
     event.public = False
     event.message = unicode(message, 'utf-8', 'replace')
     self.log.debug(u'message("%s")' % event.message)
     return ibid.dispatcher.dispatch(event).addCallback(self.respond)
예제 #13
0
파일: silc.py 프로젝트: shoosen/ibid
    def disconnected(self, message):
        self.factory.log.info(u"Disconnected (%s)", message)

        event = Event(self.factory.name, u'source')
        event.status = u'disconnected'
        ibid.dispatcher.dispatch(event)

        self.factory.s.stopService()
        self.channels.clear()
        self.users.clear()
예제 #14
0
파일: silc.py 프로젝트: B-Rich/ibid-1
    def disconnected(self, message):
        self.factory.log.info(u"Disconnected (%s)", message)

        event = Event(self.factory.name, u'source')
        event.status = u'disconnected'
        ibid.dispatcher.dispatch(event)

        self.factory.s.stopService()
        self.channels.clear()
        self.users.clear()
예제 #15
0
파일: smtp.py 프로젝트: vhata/ibid
    def eomReceived(self):
        mail = message_from_string('\n'.join(self.lines))

        event = Event(self.name, u'message')
        (realname, address) = email_utils.parseaddr(mail['from'])
        event.channel = event.sender['connection'] = event.sender[
            'id'] = unicode(address, 'utf-8', 'replace')
        event.sender['nick'] = realname != '' and unicode(
            realname, 'utf-8', 'replace') or event.channel
        event.public = False
        event.addressed = True
        event.subject = unicode(mail['subject'], 'utf-8', 'replace')
        event.headers = dict((i[0].lower(), unicode(i[1], 'utf-8', 'replace'))
                             for i in mail.items())

        message = mail.is_multipart() and mail.get_payload()[0].get_payload(
        ) or mail.get_payload()
        if len(message) > 0:
            stripsig = re.compile(r'^-- $.*', re.M + re.S)
            event.message = stripsig.sub('',
                                         unicode(message, 'utf-8',
                                                 'replace')).strip().replace(
                                                     '\n', ' ')
        else:
            event.message = event.subject

        self.log.debug(u"Received message from %s: %s",
                       event.sender['connection'], event.message)
        ibid.dispatcher.dispatch(event).addCallback(
            ibid.sources[self.name.lower()].respond)
        return defer.succeed(None)
예제 #16
0
파일: telnet.py 프로젝트: vhata/ibid
 def telnet_Query(self, line):
     event = Event(self.factory.name, u'message')
     event.message = unicode(line.strip(), 'utf-8', 'replace')
     event.sender['connection'] = self.user
     event.sender['id'] = self.user
     event.sender['nick'] = event.sender['connection']
     event.channel = event.sender['connection']
     event.addressed = True
     event.public = False
     self.factory.log.debug(u"Received message from %s: %s", self.user, event.message)
     ibid.dispatcher.dispatch(event).addCallback(self.respond)
     return 'Query'
예제 #17
0
    def connectionInitialized(self):
        self.parent.log.info(u"Connected")
        xmppim.MessageProtocol.connectionInitialized(self)
        xmppim.PresenceClientProtocol.connectionInitialized(self)
        xmppim.RosterClientProtocol.connectionInitialized(self)
        self.xmlstream.send(xmppim.AvailablePresence())
        self.roster = self.getRoster() #See section 7.3 of http://www.ietf.org/rfc/rfc3921.txt
        self.name = self.parent.name
        self.parent.send = self.send
        self.parent.proto = self
        for room in self.parent.rooms:
            self.join(room)

        event = Event(self.parent.name, u'source')
        event.status = u'connected'
        ibid.dispatcher.dispatch(event)
예제 #18
0
파일: irc.py 프로젝트: B-Rich/ibid-1
    def signedOn(self):
        names = ibid.config.plugins['core']['names']
        if self.nickname not in names:
            self.factory.log.info(u'Adding "%s" to plugins.core.names', self.nickname)
            names.append(self.nickname)
            ibid.config.plugins['core']['names'] = names
            ibid.reloader.reload_config()
        if self.factory.modes:
            self.mode(self.nickname, True, self.factory.modes.encode('utf-8'))
        self.ctcpMakeQuery(self.nickname, [('HOSTMASK', None)])
        for channel in self.factory.channels:
            self.join(channel.encode('utf-8'))
        self.factory.log.info(u"Signed on")

        event = Event(self.factory.name, u'source')
        event.status = u'connected'
        ibid.dispatcher.dispatch(event)
예제 #19
0
파일: dc.py 프로젝트: B-Rich/ibid-1
    def signedOn(self):
        names = ibid.config.plugins['core']['names']
        if self.my_nickname not in names:
            self.factory.log.info(u'Adding "%s" to plugins.core.names', self.my_nickname)
            names.append(self.my_nickname)
            ibid.config.plugins['core']['names'] = names
            ibid.reloader.reload_config()

        event = Event(self.factory.name, u'source')
        event.status = u'connected'
        ibid.dispatcher.dispatch(event)

        event = Event(self.factory.name, u'source')
        event.channel = u'$public'
        event.status = u'joined'
        ibid.dispatcher.dispatch(event)

        self.factory.log.info(u"Signed on")
예제 #20
0
파일: irc.py 프로젝트: rsnyman/ibid
    def signedOn(self):
        names = ibid.config.plugins['core']['names']
        if self.nickname not in names:
            self.factory.log.info(u'Adding "%s" to plugins.core.names',
                                  self.nickname)
            names.append(self.nickname)
            ibid.config.plugins['core']['names'] = names
            ibid.reloader.reload_config()
        if self.factory.modes:
            self.mode(self.nickname, True, self.factory.modes.encode('utf-8'))
        self.ctcpMakeQuery(self.nickname, [('HOSTMASK', None)])
        for channel in self.factory.channels:
            self.join(channel)
        self.factory.log.info(u"Signed on")

        event = Event(self.factory.name, u'source')
        event.status = u'connected'
        ibid.dispatcher.dispatch(event)
예제 #21
0
파일: dc.py 프로젝트: vhata/ibid
 def _create_event(self, type, user):
     event = Event(self.factory.name, type)
     event.sender['connection'] = user
     event.sender['id'] = user
     event.sender['nick'] = user
     event.channel = u'$public'
     event.public = True
     return event
예제 #22
0
파일: irc.py 프로젝트: rsnyman/ibid
 def _create_event(self, type, user, channel):
     nick = user.split('!', 1)[0]
     event = Event(self.factory.name, type)
     event.sender['connection'] = user
     event.sender['id'] = nick
     event.sender['nick'] = event.sender['id']
     event.channel = channel
     event.public = True
     return event
예제 #23
0
파일: silc.py 프로젝트: shoosen/ibid
    def _create_event(self, type, user, channel):
        event = Event(self.factory.name, type)
        event.sender['connection'] = unicode(
            "%s@%s" % (user.username, user.hostname), 'utf-8', 'replace')
        event.sender['nick'] = unicode(user.nickname, 'utf-8', 'replace')
        event.sender['connection'] = self._to_hex(user.user_id)
        event.sender['id'] = self._to_hex(user.fingerprint)
        if channel:
            event.channel = unicode(channel.channel_name, 'utf-8', 'replace')
        else:
            event.channel = event.sender['connection']
        event.public = True

        self.users[event.sender['connection']] = user
        self.users[event.sender['id']] = user

        return event
예제 #24
0
    def make_event(self, message=None, type=u'message'):
        event = Event(self.source, type)
        event.sender['id'] = event.sender['connection'] = \
            event.sender['nick'] = self.username
        event.identity = self.identity.id
        event.account = None
        event.addressed = not self.public
        event.public = self.public
        event.channel = u'testchan'

        if message is not None:
            event.message = unicode(message)

        return event
예제 #25
0
 def _create_event(self, type, user_id, user_name, room_id, room_name):
     event = Event(self.factory.name, type)
     if user_id is not None:
         # user_id is an int. simplejson may have returned a str() if
         # user_name and room_name don't contain non-ASCII chars.
         user_id = unicode(user_id)
         user_name = unicode(user_name)
         event.sender['connection'] = user_id
         event.sender['id'] = user_id
         event.sender['nick'] = user_name
     event.channel = unicode(room_name)
     event.public = True
     event.source = self.factory.name
     return event
예제 #26
0
파일: dc.py 프로젝트: B-Rich/ibid-1
 def _create_event(self, type, user):
     event = Event(self.factory.name, type)
     event.sender['connection'] = user
     event.sender['id'] = user
     event.sender['nick'] = user
     event.channel = u'$public'
     event.public = True
     return event
예제 #27
0
파일: silc.py 프로젝트: B-Rich/ibid-1
    def _create_event(self, type, user, channel):
        event = Event(self.factory.name, type)
        event.sender['connection'] = unicode("%s@%s" % (user.username, user.hostname), 'utf-8', 'replace')
        event.sender['nick'] = unicode(user.nickname, 'utf-8', 'replace')
        event.sender['connection'] = self._to_hex(user.user_id)
        event.sender['id'] = self._to_hex(user.fingerprint)
        if channel:
            event.channel = unicode(channel.channel_name, 'utf-8', 'replace')
        else:
            event.channel = event.sender['connection']
        event.public = True

        self.users[event.sender['connection']] = user
        self.users[event.sender['id']] = user

        return event
예제 #28
0
파일: irc.py 프로젝트: B-Rich/ibid-1
 def _create_event(self, type, user, channel):
     nick = user.split('!', 1)[0]
     event = Event(self.factory.name, type)
     event.sender['connection'] = user
     event.sender['id'] = nick
     event.sender['nick'] = event.sender['id']
     event.channel = channel
     event.public = True
     return event
예제 #29
0
파일: __init__.py 프로젝트: GertBurger/ibid
    def make_event(self, message=None, type=u"message"):
        event = Event(self.source, type)
        event.sender["id"] = event.sender["connection"] = event.sender["nick"] = self.username
        event.identity = self.identity.id
        event.account = None
        event.addressed = not self.public
        event.public = self.public
        event.channel = u"testchan"

        if message is not None:
            event.message = unicode(message)

        return event
예제 #30
0
파일: campfire.py 프로젝트: B-Rich/ibid-1
 def _create_event(self, type, user_id, user_name, room_id, room_name):
     event = Event(self.factory.name, type)
     if user_id is not None:
         # user_id is an int. simplejson may have returned a str() if
         # user_name and room_name don't contain non-ASCII chars.
         user_id = unicode(user_id)
         user_name = unicode(user_name)
         event.sender['connection'] = user_id
         event.sender['id'] = user_id
         event.sender['nick'] = user_name
     event.channel = unicode(room_name)
     event.public = True
     event.source = self.factory.name
     return event
예제 #31
0
    def make_event(self, message=None, type=u'message'):
        event = Event(self.source, type)
        event.sender['id'] = event.sender['connection'] = \
            event.sender['nick'] = self.username
        event.identity = self.identity.id
        event.account = None
        event.addressed = not self.public
        event.public = self.public
        event.channel = u'testchan'

        if message is not None:
            event.message = unicode(message)

        return event
예제 #32
0
파일: smtp.py 프로젝트: B-Rich/ibid-1
    def eomReceived(self):
        mail = message_from_string('\n'.join(self.lines))

        event = Event(self.name, u'message')
        (realname, address) = email_utils.parseaddr(mail['from'])
        event.channel = event.sender['connection'] = event.sender['id'] = unicode(address, 'utf-8', 'replace')
        event.sender['nick'] = realname != '' and unicode(realname, 'utf-8', 'replace') or event.channel
        event.public = False
        event.addressed = True
        event.subject = unicode(mail['subject'], 'utf-8', 'replace')
        event.headers = dict((i[0].lower(), unicode(i[1], 'utf-8', 'replace')) for i in mail.items())

        message = mail.is_multipart() and mail.get_payload()[0].get_payload() or mail.get_payload()
        if len(message) > 0:
            stripsig = re.compile(r'^-- $.*', re.M+re.S)
            event.message = stripsig.sub('', unicode(message, 'utf-8', 'replace')).strip().replace('\n', ' ')
        else:
            event.message = event.subject

        self.log.debug(u"Received message from %s: %s", event.sender['connection'], event.message)
        ibid.dispatcher.dispatch(event).addCallback(ibid.sources[self.name.lower()].respond)
        return defer.succeed(None)
예제 #33
0
파일: dc.py 프로젝트: vhata/ibid
    def signedOn(self):
        names = ibid.config.plugins['core']['names']
        if self.my_nickname not in names:
            self.factory.log.info(u'Adding "%s" to plugins.core.names',
                                  self.my_nickname)
            names.append(self.my_nickname)
            ibid.config.plugins['core']['names'] = names
            ibid.reloader.reload_config()

        event = Event(self.factory.name, u'source')
        event.status = u'connected'
        ibid.dispatcher.dispatch(event)

        event = Event(self.factory.name, u'source')
        event.channel = u'$public'
        event.status = u'joined'
        ibid.dispatcher.dispatch(event)

        self.factory.log.info(u"Signed on")
예제 #34
0
파일: log.py 프로젝트: shoosen/ibid
    def log_handler(self, event):
        self.log_event(event)

        for response in event.responses:
            if 'reply' in response and isinstance(response['reply'], basestring):
                type = 'message'
                if response.get('action', False):
                    type = 'action'
                elif response.get('notice', False):
                    type = 'notice'
                e = Event(response['source'], type)
                e.source = response['source']
                e.channel = response['target']
                e.time = datetime.utcnow()
                e.sender = {
                    'id': ibid.config['botname'],
                    'connection': ibid.config['botname'],
                    'nick': ibid.config['botname'],
                }
                e.message = response['reply']
                self.log_event(e)
예제 #35
0
파일: log.py 프로젝트: B-Rich/ibid-1
    def log_handler(self, event):
        self.log_event(event)

        for response in event.responses:
            if 'reply' in response and isinstance(response['reply'], basestring):
                type = 'message'
                if response.get('action', False):
                    type = 'action'
                elif response.get('notice', False):
                    type = 'notice'
                e = Event(response['source'], type)
                e.source = response['source']
                e.channel = response['target']
                e.time = datetime.utcnow()
                e.sender = {
                    'id': ibid.config['botname'],
                    'connection': ibid.config['botname'],
                    'nick': ibid.config['botname'],
                }
                e.message = response['reply']
                self.log_event(e)
예제 #36
0
파일: irc.py 프로젝트: rsnyman/ibid
 def left(self, channel):
     event = Event(self.factory.name, u'source')
     event.channel = channel
     event.status = u'left'
     ibid.dispatcher.dispatch(event)
예제 #37
0
파일: irc.py 프로젝트: rsnyman/ibid
 def joined(self, channel):
     event = Event(self.factory.name, u'source')
     event.channel = unicode(channel, 'utf-8', 'replace')
     event.status = u'joined'
     ibid.dispatcher.dispatch(event)
예제 #38
0
 def _state_event(self, entity, state, realjid=None):
     event = Event(self.name, u'state')
     event.state = state
     if entity.userhost().lower() in self.rooms:
         nick = entity.full().split('/')[1]
         event.channel = entity.userhost()
         if nick == self.parent.nick:
             event.type = u'connection'
             event.status = state == u'online' and u'joined' or u'left'
         else:
             if realjid:
                 if state == u'online':
                     self.room_users[entity.full()] = realjid.full()
                 elif state == u'offline':
                     if entity.full() in self.room_users:
                         del self.room_users[entity.full()]
                 event.sender['connection'] = realjid.full()
                 event.sender['id'] = realjid.userhost()
             else:
                 event.sender['connection'] = entity.full()
                 event.sender['id'] = event.sender['connection']
             event.sender['nick'] = nick
             event.public = True
     else:
         event.sender['connection'] = entity.full()
         event.sender['id'] = event.sender['connection'].split('/')[0]
         event.sender['nick'] = event.sender['connection'].split('@')[0]
         event.channel = entity.full()
         event.public = False
     ibid.dispatcher.dispatch(event).addCallback(self.respond)
예제 #39
0
파일: irc.py 프로젝트: B-Rich/ibid-1
 def left(self, channel):
     event = Event(self.factory.name, u'source')
     event.channel = channel
     event.status = u'left'
     ibid.dispatcher.dispatch(event)
예제 #40
0
파일: irc.py 프로젝트: B-Rich/ibid-1
 def joined(self, channel):
     event = Event(self.factory.name, u'source')
     event.channel = unicode(channel, 'utf-8', 'replace')
     event.status = u'joined'
     ibid.dispatcher.dispatch(event)
예제 #41
0
파일: timer.py 프로젝트: simpoir/ibid
 def tick(self):
     event = Event(self.name, u'clock')
     ibid.dispatcher.dispatch(event)
예제 #42
0
    def onMessage(self, message):
        self.parent.log.debug(u"Received %s message from %s: %s", message['type'], message['from'], message.body)

        if message.x and message.x.defaultUri == 'jabber:x:delay':
            self.parent.log.debug(u"Ignoring delayed message")
            return

        if self.parent.accept_domains:
            if message['from'].split('/')[0].split('@')[1] not in self.parent.accept_domains:
                self.parent.log.info(u"Ignoring message because sender is not in accept_domains")
                return

        if message.body is None:
            self.parent.log.info(u'Ignoring empty message')
            return

        event = Event(self.parent.name, u'message')
        event.message = unicode(message.body)
        event.sender['connection'] = message['from']

        if message['type'] == 'groupchat':
            if message['from'] in self.room_users:
                event.sender['connection'] = self.room_users[message['from']]
                event.sender['id'] = event.sender['connection'].split('/')[0]
            else:
                event.sender['id'] = message['from']
            if event.sender['id'] == self.parent.nick:
                return
            if '/' in message['from']:
                event.sender['nick'] = message['from'].split('/')[1]
            else:
                event.sender['nick'] = message['from']
            event.channel = message['from'].split('/')[0]
            event.public = True
        else:
            event.sender['id'] = event.sender['connection'].split('/')[0]
            event.sender['nick'] = event.sender['connection'].split('@')[0]
            event.channel = event.sender['connection']
            event.public = False
            event.addressed = True

        ibid.dispatcher.dispatch(event).addCallback(self.respond)