Ejemplo n.º 1
0
Archivo: app.py Proyecto: l-n-s/toot
    def reply(self):
        """Reply to the selected status"""
        status = self.get_selected_status()
        app, user = self.app, self.user
        if not app or not user:
            self.footer.draw_message("You must be logged in to reply",
                                     Color.RED)
            return

        compose_modal = ComposeModal(
            self.stdscr,
            default_cw='\n'.join(status['spoiler_text']) or None,
            resize_callback=self.on_resize)
        content, cw = compose_modal.loop()
        self.full_redraw()
        if content is None:
            return
        elif len(content) == 0:
            self.footer.draw_message("Status must contain content", Color.RED)
            return

        self.footer.draw_message("Submitting reply...", Color.YELLOW)
        response = api.post_status(app,
                                   user,
                                   content,
                                   spoiler_text=cw,
                                   sensitive=cw is not None,
                                   in_reply_to_id=status['id'])
        status = parse_status(response)
        self.statuses.insert(0, status)
        self.selected += 1
        self.left.draw_statuses(self.statuses, self.selected)
        self.footer.draw_message("✓ Reply posted", Color.GREEN)
Ejemplo n.º 2
0
Archivo: app.py Proyecto: l-n-s/toot
    def compose(self):
        """Compose and submit a new status"""
        app, user = self.app, self.user
        if not app or not user:
            self.footer.draw_message("You must be logged in to post",
                                     Color.RED)
            return

        compose_modal = ComposeModal(self.stdscr,
                                     resize_callback=self.on_resize)
        content, cw = compose_modal.loop()
        self.full_redraw()
        if content is None:
            return
        elif len(content) == 0:
            self.footer.draw_message("Status must contain content", Color.RED)
            return

        self.footer.draw_message("Submitting status...", Color.YELLOW)
        response = api.post_status(app,
                                   user,
                                   content,
                                   spoiler_text=cw,
                                   sensitive=cw is not None)
        status = parse_status(response)
        self.statuses.insert(0, status)
        self.selected += 1
        self.left.draw_statuses(self.statuses, self.selected)
        self.footer.draw_message("✓ Status posted", Color.GREEN)
Ejemplo n.º 3
0
    def fetch_next(self):
        try:
            self.footer.draw_message("Loading toots...", Color.BLUE)
            statuses = next(self.status_generator)
        except StopIteration:
            return None

        for status in statuses:
            self.statuses.append(parse_status(status))

        self.footer.draw_message("Loaded {} toots".format(len(statuses)), Color.GREEN)

        return len(statuses)