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
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
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)
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)