예제 #1
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)
예제 #2
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)
예제 #3
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
예제 #4
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
예제 #5
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)
예제 #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
 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)
예제 #8
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
예제 #9
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
예제 #10
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
예제 #11
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
예제 #12
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)
예제 #13
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'
예제 #14
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
예제 #15
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
예제 #16
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
예제 #17
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
예제 #18
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
예제 #19
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
예제 #20
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
예제 #21
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)