Beispiel #1
0
    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)
Beispiel #2
0
 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)
Beispiel #3
0
 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)
Beispiel #4
0
    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
''')
Beispiel #5
0
    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
''')
Beispiel #6
0
            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):
Beispiel #7
0
            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)