def handle_live_update(self, message): username = message.get('user', {}).get('username', '(unknown)') me = self.convore.get_username() if message.get('kind') != 'message' or username == me: return topic = message.get('topic', {}) self.set_output_topic(_id(topic), async=True) output(_format_message(message), async=True)
def loop(self): output('welcome to convoread! type /help for more info') while True: try: data = raw_input(config['PROMPT']) self.dispatch(data.decode(config['ENCODING'], 'replace')) except EOFError: raise except Exception, e: error(unicode(e), exc=e)
def cmd_help(self): output('''\ commands: /ts [name] list unread topics or topics in group <name> /t [num] set the posting topic to <num> and list recent messages /help show help on commands /q quit <text> post a new message to the selected topic keys: C-u clear the command line C-d quit ''')
def cmd_help(self): output('''\ commands: /ts [name] list unread topics or topics in group <name> /t [num] set the posting topic to <num> and list recent messages /m [name] mark messages as read (all or in group <name>) /help show help on commands /q quit <text> post a new message to the selected topic keys: C-u clear the command line C-d quit ''')
groups = list(self.convore.get_groups().values()) except NetworkError, e: error(unicode(e)) return if group_slug: groups = [g for g in groups if g.get('slug') == group_slug] if not groups: error('group "{0}" not found'.format(group_slug)) return groups = sorted(groups, key=latest_message, reverse=True) for group in groups: output('{name}:'.format( name=group.get('slug', '(unknown)'))) topics = [t for t in all_topics if t.get('group') == _id(group)] topics = sorted(topics, key=latest_message, reverse=True) for topic in topics: unread = topic.get('unread', 0) if not group_slug and unread == 0: continue msg = ' {mark} {id:6} {new:2} {name}'.format( mark='*' if _id(topic) == self.topic else ' ', id=topic.get('id', '?'), new=unread if unread > 0 else '', name=topic.get('name', '(unknown)')) output(msg) def cmd_t(self, topic_id=None):
all_topics = list(self.convore.get_topics().values()) groups = list(self.convore.get_groups().values()) except NetworkError, e: error(unicode(e)) return if group_slug: groups = [g for g in groups if g.get('slug') == group_slug] if not groups: error('group "{0}" not found'.format(group_slug)) return groups = sorted(groups, key=latest_message, reverse=True) for group in groups: output('{name}:'.format(name=group.get('slug', '(unknown)'))) topics = [ t for t in all_topics if t.get('group') == group.get('id') ] topics = sorted(topics, key=latest_message, reverse=True) for topic in topics: unread = topic.get('unread', 0) if not group_slug and unread == 0: continue msg = ' {mark} {id:6} {new:2} {name}'.format( mark='*' if topic.get('id') == self.topic else ' ', id=topic.get('id', '?'), new=unread if unread > 0 else '', name=topic.get('name', '(unknown)')) output(msg)