def dispatch_message(self, channel_id, text): message = {'id': channel_id, 'text': text} timestamp(message) for session in self.sessions: if channel_id in session.channel_ids: session.append({'channel': message}) db.add_db_list(channel_key(channel_id), {'text': text, 'timestamp': message['timestamp']})
def add_message(msg_type, content, player_id, source_id=None): msg_id = db.db_counter("message_id") message = {'msg_type': msg_type, 'msg_id': msg_id, 'content': content, 'source': um.id_to_name(source_id)} timestamp(message) db.set_db_hash(_message_key(player_id), msg_id, message) try: sm.player_session(player_id).append({'new_message': message}) except AttributeError: pass
def add_message(self, msg_type, content, player_id, source_id=None): if self.is_blocked(player_id, source_id): raise ActionError("You are blocked from sending messages to that player.") msg_id = db_counter("message_id") message = {'msg_type': msg_type, 'msg_id': msg_id, 'content': content, 'source': user_manager.id_to_name(source_id)} timestamp(message) set_db_hash(_message_key(player_id), msg_id, message) try: session_manager.player_session(player_id).append({'new_message': message}) except AttributeError: pass