Пример #1
0
 def _add_user_to_list(self, buffer=None, index=None):
     try:
         who = [buffer.get_screen_name(index)]
     except:
         who = [""]
     if who == [None]:
         who = [""]
     if hasattr(buffer, "get_mentions"):
         who.extend(buffer.get_mentions())
     dlg = gui.UserListDialog(parent=self.frame,
                              title=_("Select user to add"),
                              users=who)
     dlg.setup_users()
     dlg.finish_setup()
     if dlg.ShowModal() != wx.ID_OK:
         return output.speak(_("Canceled."), True)
     user = dlg.users.GetValue()
     output.speak(_("Retrieving lists, please wait."), True)
     lists = self.TwitterApi.lists()[0]['lists']
     dlg = wx.SingleChoiceDialog(
         parent=self.frame,
         caption=_("Select list"),
         message=_("Please select a list to add %s to?") % user,
         choices=[i['name'] for i in lists])
     if dlg.ShowModal() != wx.ID_OK:
         return output.speak(_("Canceled."), True)
     which = lists[dlg.GetSelection()]
     self.api_call('add_list_member',
                   _("adding user %s to list %s") % (user, which['name']),
                   id=user,
                   slug=which['slug'])
Пример #2
0
    def RemoveFromList(self, buffer=None, index=None):
        """Remove a user from a list"""

        who = buffer.get_all_screen_names(index)
        dlg = gui.UserListDialog(parent=self.session.frame,
                                 title=_("Select user to remove"),
                                 users=who)
        dlg.setup_users()
        dlg.finish_setup()
        if dlg.ShowModal() != wx.ID_OK:
            return output.speak(_("Canceled."), True)
        user = dlg.users.GetValue()
        output.speak(_("Retrieving lists, please wait."), True)
        lists = self.session.TwitterApi.show_lists()
        if not lists:
            return output.speak(
                _("No lists defined.  Please create a list with the list manager before performing this action."
                  ), True)
        dlg = wx.SingleChoiceDialog(
            parent=self.session.frame,
            caption=_("Select list"),
            message=_("Please select a list to remove %s from?") % user,
            choices=[i['name'] for i in lists])
        if dlg.ShowModal() != wx.ID_OK:
            return output.speak(_("Canceled."), True)
        which = lists[dlg.GetSelection()]
        self.session.api_call('delete_list_member',
                              action=_("removing %s from list %s.") %
                              (user, which['name']),
                              screen_name=user,
                              list_id=which['id'])
Пример #3
0
    def ViewUserLists(self, buffer=None, index=None):
        """View the public lists a user has created."""

        who = buffer.get_all_screen_names(index)
        dlg = gui.UserListDialog(parent=self.session.frame,
                                 title=_("Select user"),
                                 users=who)
        dlg.setup_users()
        dlg.finish_setup()
        if dlg.ShowModal() != wx.ID_OK:
            return output.speak(_("Canceled."), True)
        user = dlg.users.GetValue()
        dlg.Destroy()
        call_threaded(self.session.list_manager(screen_name=user))