def callback_message(self, message): logger.debug('Receive message from client: {}'.format(message[0])) logger.debug('Full message body: {}'.format(message)) msg_obj = Message(message) session_id = Session.generate_session_id(msg_obj['id'], msg_obj['user']) self.sessions[session_id] = self.sessions.get(session_id) or Session( msg_obj['id'], msg_obj['user']) current_session = self.sessions[session_id] logger.debug('Global Sessions: {}'.format(self.sessions)) logger.debug('Current session: {}'.format(current_session._data)) msg_obj.session = current_session if msg_obj.session['is_wait']: # BUG actually, needs a lock here if user type fast enough msg_obj.session.queue.put(msg_obj['content']) return if super(TomBot, self).callback_message(msg_obj): # Act only in the backend tells us that this message is OK to broadcast for plugin in get_all_active_plugin_objects(): #noinspection PyBroadException try: logger.debug('Callback %s' % plugin) plugin.callback_message(msg_obj) except Exception as _: logger.exception("Crash in a callback_message handler")
def callback_message(self, message): logger.debug('Receive message from client: {}'.format(message[0])) logger.debug('Full message body: {}'.format(message)) msg_obj = Message(message) session_id = Session.generate_session_id(msg_obj['id'], msg_obj['user']) self.sessions[session_id] = self.sessions.get(session_id) or Session(msg_obj['id'], msg_obj['user']) current_session = self.sessions[session_id] logger.debug('Global Sessions: {}'.format(self.sessions)) logger.debug('Current session: {}'.format(current_session._data)) msg_obj.session = current_session if msg_obj.session['is_wait']: # BUG actually, needs a lock here if user type fast enough msg_obj.session.queue.put(msg_obj['content']) return if super(TomBot, self).callback_message(msg_obj): # Act only in the backend tells us that this message is OK to broadcast for plugin in get_all_active_plugin_objects(): #noinspection PyBroadException try: logger.debug('Callback %s' % plugin) plugin.callback_message(msg_obj) except Exception as _: logger.exception("Crash in a callback_message handler")
def send_message(self, mess): # super(TomBot, self).send_message(mess) # Act only in the backend tells us that this message is OK to broadcast for bot in get_all_active_plugin_objects(): #noinspection PyBroadException try: bot.callback_message(mess) except Exception as _: logger.exception("Crash in a callback_message handler")
def signal_connect_to_all_plugins(self): for plugin in get_all_active_plugin_objects(): if hasattr(plugin, 'callback_connect'): #noinspection PyBroadException try: logger.debug('Callback %s' % plugin) plugin.callback_connect() except Exception as _: logger.exception("callback_connect failed for %s" % plugin)