Example #1
0
 def NewReply(self, buffer=None, index=None, text="", user=None):
  """Allows you to post a reply to a tweet."""

  default = user
  users = buffer.get_all_screen_names(index)
  if 'source' not in buffer[index] and 'text' in buffer[index] and self.session.config['UI']['DMSafeMode']:
   return self.NewDm(buffer, index, text)
  if not self.session.config['UI']['replyToSelf']:
   for n, u in enumerate(users):
    if self.session.is_current_user(u):
     users.remove(users[n])
  if default:
   users.insert(0, default)
  if not users:
   return output.speak(_("Unable to detect a user to reply to."), True)
  new = modal_dialog(gui.NewReplyDialog, parent=self.session.frame, default=users[0], selection=users, title=_("Reply"), text=text)
  user = new.selection.GetValue()
  fulltext = templates.replyTemplate(user, new.message.GetValue())
  if len(fulltext) > self.session.config['lengths']['tweetLength']:
   i = fulltext.index(" ") + 1
   return self.NewReply(buffer, index, fulltext[i:])
  if new.delay:
   delay_action(new.delay, self.session.post_reply, buffer=buffer, index=index, text=fulltext, action=_("reply"))
  else:
   call_threaded(self.session.post_reply, buffer=buffer, index=index, text=fulltext)
Example #2
0
    def ApplyFilter(self, buffer=None):
        """Display a buffer containing or excluding the items which contain the specified search criteria."""

        from core.sessions.buffers.buffers import Filtered
        if not buffer.get_flag('filterable'):
            logging.debug("Buffer %s is not filterable." % buffer.name)
            return output.speak(
                _("Buffer %s does not support filtration." %
                  buffer.display_name), True)
        new = modal_dialog(gui.FilterDialog,
                           parent=self.session.frame,
                           buffer=buffer)
        output.speak(_("Processing.  Please wait."))
        filter_specs = new.get_filter_specs()
        for filter_spec in filter_specs:
            buftitle = Filtered.generate_filter_name(buffer, filter_spec)
            if filter_spec['replace']:
                replaces = buffer
            else:
                replaces = None
            filtered = self.session.register_buffer(buftitle,
                                                    Filtered,
                                                    replaces=replaces,
                                                    source_name=buffer.name,
                                                    **filter_spec)
Example #3
0
    def TwitterSearch(self, text=None):
        """Allows you to search twitter for the specified term."""

        if not text:
            text = self.buffer().get_hash_tags(self.buffer().index)
        text.extend(self.buffer().get_mentions(self.buffer().index))
        new = modal_dialog(gui.TwitterSearchDialog,
                           parent=self.session.frame,
                           title=_("Twitter search"),
                           text=text)
        term = unicode(new.term.GetValue())
        save = new.save.GetValue()
        store = new.store.GetValue()
        count = new.retrieveCount.GetValue()
        maxAPIPerUpdate = new.maxAPIPerUpdate.GetValue()
        if count == 100 and maxAPIPerUpdate > 1:
            count = 200
        if not term:
            output.speak(_("Please enter a term to search for."), True)
            return self.TwitterSearch()
        title = _("Search for %s") % term
        search = self.session.register_buffer(title,
                                              buffers.Search,
                                              store=store,
                                              term=term,
                                              saved=save,
                                              count=count,
                                              maxAPIPerUpdate=maxAPIPerUpdate)
Example #4
0
 def ListUrls(self, buffer=None, index=None):
  """List any URLs or mentions of a twitter screen name in a dialog."""

  urls = []
  try:
   urls.extend(buffer.get_urls(index))
  except:
   pass
  try:
   urls.extend(["@%s" % i for i in buffer.get_mentions(index)])
  except:
   pass
  try:
   urls.extend(["@%s" % buffer.get_screen_name(index)])
  except:
   pass
  urls = misc.RemoveDuplicates(urls)
  if not urls:
   logging.debug("No web addresses or usernames in current tweet.")
   return output.speak(_("No URLs detected in current post."), 1)
  logging.debug("Launching URL choice dialog.")
  dlg = modal_dialog(core.gui.ListURLsDialog, parent=self.session.frame, urls=urls)
  url = dlg.urls_list.GetStringSelection().replace("@","http://ww	w.twitter.com/")
  logging.debug("Opening URL: %s " % url)
  misc.open_url_in_browser(url)
Example #5
0
 def LocalTrends(self):
  """Creates a buffer containing the trends for the specified location."""

  output.speak(_("Retrieving locations."), True)
  try:
   locations = self.session.TwitterApi.get_available_trends()
   logging.debug("Raw locations: %s" % str(locations))
  except:
   logging.debug("Unable to obtain local trend locations.")
   return output.speak(_("Unable to retrieve local trend locations; please try again later."), True)
  locations.sort(key=lambda location: location['name'])
  locations_by_name = {}
  locations_tree = {}
  for location in locations:
   type = location['placeType']['name']
   place = location['name']
   if place == "Worldwide":
    continue
   locations_by_name[place] = location
   if type not in locations_tree.keys():
    locations_tree[type] = []
   locations_tree[type].append(place)
  dlg = modal_dialog(gui.LocalTrendsDialog, parent=self.session.frame, id=wx.ID_ANY, locations_tree=locations_tree)
  if dlg.locations_list.GetSelection() == wx.NOT_FOUND:
   choice = dlg.locations_list.GetItems()[0]
  else:
   choice = dlg.locations_list.GetStringSelection()
  location = locations_by_name[choice]
  self.session.register_buffer(_("Trending: %s" % location['name']), buffers.LocalTrends, woeid=location['woeid'])
Example #6
0
 def export(self, dlg=None):
  """Writes items in a buffer to an external file."""
  if dlg is None:
   dlg = modal_dialog(gui.export.MainExportDialog, parent=self.session.frame, id=wx.ID_ANY)
  if not dlg.IsExportAvailable():
   output.speak(_("The export function is not available."), True)
  else:
    output.speak(_("Export started, please wait."), True)
    try:
     exporter = dlg.GetExporter()
     exporter.Run()
     output.speak(_("Export complete"), False)
     if dlg.format.exportMore.GetValue():
      index = dlg.items.get_buffer_index()
      if index != wx.NOT_FOUND:
       index += 1
      if dlg.items.buffer.GetCount() > 0 and (index == wx.NOT_FOUND or index >= dlg.items.buffer.GetCount()):
       index = 0
      dlg.items.set_bufferIndex(index)
      dlg.format.filename.SetValue("")
      return wx.CallAfter(self.export, dlg=dlg)
    except:
     logging.exception("Export failed.")
     output.speak(_("Export failed."), False)
     return wx.CallAfter(self.export, dlg = dlg)
Example #7
0
    def NewDm(self, buffer=None, index=None, user=u"", text=u""):
        """Allows you to send a new direct message to a user."""

        who = buffer.get_all_screen_names(index)
        new = modal_dialog(gui.NewDirectDialog,
                           parent=self.session.frame,
                           default=who[0],
                           selection=who,
                           title=_("Direct message"),
                           text=text)
        user = new.selection.GetValue()
        text = new.message.GetValue()
        if len(text) > self.session.config['lengths']['dmLength']:
            logging.info("Direct message too long.  Forcing edit.")
            return self.NewDm(buffer, index, user, text)
        if new.delay:
            delay_action(new.delay,
                         self.session.post_dm,
                         text=text,
                         buffer=buffer,
                         index=index,
                         user=user,
                         action=_("dm"))
        else:
            call_threaded(self.session.post_dm,
                          buffer=buffer,
                          index=index,
                          user=user,
                          text=text)
Example #8
0
 def ViewUserTimeline(self, buffer=None, index=None):
  """Creates a buffer containing the timeline of the specified user."""

  who = buffer.get_all_screen_names(index)
  new = modal_dialog(gui.IndividualDialog, parent=self.session.frame, users=who)
  who = new.users.GetValue()
  self.session.register_buffer(_("%s's timeline") % who, buffers.Individual, username=who, count = new.retrieveCount.GetValue(), maxAPIPerUpdate = new.maxAPIPerUpdate.GetValue(), prelaunch_message=_("Loading timeline for %s.") % who)
Example #9
0
    def TranslateTweet(self, buffer=None, index=None):
        """Translate the current tweet into another language with Google Translate service."""

        try:
            text_to_translate = buffer.get_text(index).encode("UTF-8")
        except:
            text_to_translate = buffer.format_item(index).encode("UTF-8")
        dlg = modal_dialog(core.gui.TranslateDialog, parent=self.session.frame)
        source = [x[0] for x in dlg.available_languages()
                  ][dlg.source_lang_list.GetSelection()]
        target = [x[0] for x in dlg.available_languages()
                  ][dlg.target_lang_list.GetSelection()]
        try:
            translate = Translator().translate
            response = translate(text_to_translate,
                                 lang_from=source,
                                 lang_to=target)
            if source == '':
                source = response['source_lang']
            translated_text = response['translatedText']
        except TranslationError:
            logging.exception("Translation error has happened.")
            return output.speak(_("Translation process has failed."), True)
        self.NewTweet(text=translated_text,
                      title=_("Translation from %s to %s") % (source, target),
                      retweet=True)
Example #10
0
    def ListUrls(self, buffer=None, index=None):
        """List any URLs or mentions of a twitter screen name in a dialog."""

        urls = []
        try:
            urls.extend(buffer.get_urls(index))
        except:
            pass
        try:
            urls.extend(["@%s" % i for i in buffer.get_mentions(index)])
        except:
            pass
        try:
            urls.extend(["@%s" % buffer.get_screen_name(index)])
        except:
            pass
        urls = misc.RemoveDuplicates(urls)
        if not urls:
            logging.debug("No web addresses or usernames in current tweet.")
            return output.speak(_("No URLs detected in current post."), 1)
        logging.debug("Launching URL choice dialog.")
        dlg = modal_dialog(core.gui.ListURLsDialog,
                           parent=self.session.frame,
                           urls=urls)
        url = dlg.urls_list.GetStringSelection().replace(
            "@", "http://ww	w.twitter.com/")
        logging.debug("Opening URL: %s " % url)
        misc.open_url_in_browser(url)
Example #11
0
 def CountdownTimer(self):
  """Create a timer to count down from the time specified to 0, at which point you will be notified."""

  dlg = modal_dialog(gui.CountdownDialog, parent=self.session.frame, title=_("Countdown Timer"))
  name = dlg.name.GetValue()
  time = dlg.get_time()
  self.session.create_countdown(name, time)
  output.speak(_("Counting."), True)
Example #12
0
 def SMSReply(self, buffer=None, index=None, text=""):
  phone_number = str(buffer.get_phone_number(index))
  if not phone_number:
   return output.speak(_("Unable to detect a sender to reply to."), True)
  numbers = [phone_number]
  new = modal_dialog(gui.SMSDialog, parent=self.session.frame, default=phone_number, selection=numbers, title=_("Reply"), text=text)
  self.session.gv.send_sms(new.selection.GetValue(), new.message.GetValue())
  output.speak(_("Reply sent to %s" % new.selection.GetValue()))
Example #13
0
 def FavoritesFor(self, buffer=None, index=None):
  """Creates a buffer containing the tweets the specified user has favorited."""

  who = buffer.get_all_screen_names(index)
  new = modal_dialog(gui.FavoritesDialog, parent=self.session.frame, users=who, results_per_api=200)
  who = new.users.GetValue()
  name = _("%s's favorites") % who
  self.session.register_buffer(name, buffers.Favorites, username=who, count=new.retrieveCount.GetValue(), maxAPIPerUpdate=new.maxAPIPerUpdate.GetValue(), prelaunch_message=_("Loading favorites for %s.") % who)
Example #14
0
 def MainConfigDialog(self):
     """Shows a dialog in which you can configure global application settings."""
     new = modal_dialog(core.gui.configuration.MainConfigDialog,
                        parent=application.main_frame,
                        id=wx.ID_ANY,
                        title=_("%s Configuration") % application.name)
     new.SetNewConfigValues()
     output.speak(_("Configuration saved."), 1)
Example #15
0
 def friendsFor (self, buffer=None, index=None):
  """Creates a buffer containing the people the specified user is following."""

  who = buffer.get_all_screen_names(index)
  new = modal_dialog(gui.FriendsDialog, parent=self.session.frame, users=who, results_per_api=100)
  who = new.users.GetValue()
  api = new.maxAPIPerUpdate.GetValue()
  name = _("%s's friends") % who
  self.session.register_buffer(name, buffers.Friends, username=who, maxAPIPerUpdate=api, prelaunch_message=_("Loading friends for %s.") % who)
Example #16
0
 def followersFor(self, buffer=None, index=None):
  """Creates a buffer containing the people that are following the specified user."""

  who = buffer.get_all_screen_names(index)
  new = modal_dialog(gui.FollowersDialog, parent=self.session.frame, users=who, results_per_api=100)
  who = new.users.GetValue()
  api = new.maxAPIPerUpdate.GetValue()
  output.speak(_("Loading followers for %s.") % who, True)
  name = _("%s's followers") % who
  self.session.register_buffer(name, buffers.Followers, username=who, maxAPIPerUpdate = api)
Example #17
0
 def followersFor(self, buffer=None, index=None):
  """Creates a buffer containing the people that are following the specified user."""

  who = buffer.get_all_screen_names(index)
  new = modal_dialog(gui.FollowersDialog, parent=self.session.frame, users=who)
  who = new.users.GetValue()
  retrieveCount = new.retrieveCount.GetValue()
  maxAPIPerUpdate = new.maxAPIPerUpdate.GetValue()
  name = _("%s's followers") % who
  self.session.register_buffer(name, buffers.Followers, username=who, count = retrieveCount, maxAPIPerUpdate = maxAPIPerUpdate, prelaunch_message=_("Loading friends for %s.") % who)
Example #18
0
    def CountdownTimer(self):
        """Create a timer to count down from the time specified to 0, at which point you will be notified."""

        dlg = modal_dialog(gui.CountdownDialog,
                           parent=self.session.frame,
                           title=_("Countdown Timer"))
        name = dlg.name.GetValue()
        time = dlg.get_time()
        self.session.create_countdown(name, time)
        output.speak(_("Counting."), True)
Example #19
0
 def Unfollow(self, buffer=None, index=None):
  """Allows you to unfollow, block, or report the specified user as a spammer."""

  who = buffer.get_all_screen_names(index)
  if not who:
   output.speak(_("No users to unfollow detected in current post."), True)
   return logging.debug("No users to unfollow detected in current post.")
  new = modal_dialog(gui.UnfollowDialog, parent=self.session.frame, users=who)
  who = new.users.GetValue()
  action = new.action.GetSelection()
  call_threaded(self.session.do_unfollow, who, action)
Example #20
0
 def UserInfoDialog(self, buffer=None, index=None):
  """Displays a dialog containing information such as the screen name, real name, whether or not tweets are protected, etc, for the specified user."""

  who = buffer.get_all_screen_names(index)
  new = modal_dialog(gui.UserInfoDialog, parent=self.session.frame, users=who)
  who = new.users.GetValue()
  output.speak(_("Loading profile for %s") % who, True)
  user_ptr = self.session.TwitterApi.show_user(screen_name=who)
  logging.debug("UserInfoDialog: Twitter returned user profile for %s as \n%s" % (who, user_ptr))
  new = gui.TwitterProfileDialog(parent=self.session.frame, id=wx.ID_ANY, user=user_ptr)
  new.ShowModal()
Example #21
0
 def Follow(self, buffer=None, index=None):
  """Allows you to follow the specified user."""

  who = buffer.get_all_screen_names(index)
  if not who:
   output.speak(_("No users to follow detected in current post."), True)
   return logging.debug("No users to follow detected in current post.")
  new = modal_dialog(gui.FollowDialog, parent=self.session.frame, users=who)
  who = new.users.GetValue()
  updates = new.updates.GetValue()
  call_threaded(self.session.follow, who, updates)
Example #22
0
 def JumpToPost(self, buffer=None):
  """Moves you to the item of the specified index in the current buffer."""

  new = modal_dialog(gui.JumpToPostDialog, parent=self.session.frame, buffer=buffer)
  num = int(new.number.GetValue())
  if num > len(buffer):
   output.speak(_("Item number too high."), True)
   return self.JumpToPost(buffer=buffer)
  num = num-1
  index = len(buffer)-1 - num
  buffer.index = index
  buffer.speak_item()
Example #23
0
 def ChangeKeymap(self):
  """Allows you to change the keystrokes used to control qwitter."""

  @always_call_after
  def replace_keymap(new):
   self.session.unregister_hotkeys()
   self.session.keymap.clear()
   self.session.keymap.update(new)
   self.session.set_active_keymap(self.session.keymap)
   self.session.save_config()
   output.speak(_("Keymap saved."), True)

  dlg = modal_dialog(KeymapDialog, parent=self.session.frame)
  replace_keymap(dlg.new_keymap)
Example #24
0
 def NewDm(self, buffer=None, index=None, user="", text=""):
  """Allows you to send a new direct message to a user."""

  who = buffer.get_all_screen_names(index)
  new = modal_dialog(gui.NewDirectDialog, parent=self.session.frame, default=who[0], selection=who, title=_("Direct message"), text=text)
  user = new.selection.GetValue()
  text = new.message.GetValue()
  if len(text) > self.session.config['lengths']['tweetLength']:
   logging.info("Direct message too long.  Forcing edit.")
   return self.NewDm (buffer, index, user, text)
  if new.delay:
   delay_action(new.delay, self.session.post_dm, text=text, buffer=buffer, index=index, user=user, action=_("dm"))
  else:
   call_threaded(self.session.post_dm, buffer=buffer, index=index, user=user, text=text)
Example #25
0
    def ChangeKeymap(self):
        """Allows you to change the keystrokes used to control TheQube."""

        @always_call_after
        def replace_keymap(new):
            self.session.unregister_hotkeys()
            self.session.keymap.clear()
            self.session.keymap.update(new)
            self.session.set_active_keymap(self.session.keymap)
            self.session.save_config()
            output.speak(_("Keymap saved."), True)

        dlg = modal_dialog(KeymapDialog, parent=self.session.frame)
        replace_keymap(dlg.new_keymap)
Example #26
0
 def call(self):
  dlg = modal_dialog(gui.CallDialog, parent=self.session.frame, title=_("Call Phone"))
  number = int(dlg.number.GetValue())
  if not number:
   output.speak(_("Please enter a phone number to call."), 1)
   return self.call()
  fp_formatted = dlg.forwardingPhone.GetValue()
  if not fp_formatted:
   output.speak(_("Please indicate where the call should be bridged by selecting a forwarding phone number."), 1)
   return self.call()
  if fp_formatted not in self.session.source_numbers():
   return output.speak(_("Error, forwarding phone number not found."), True)
  output.speak(_("Calling: %r") % number, True)
  self.session.gv.call(number, self.session.unformat_phone_number(fp_formatted))
  output.speak(_("Call placed."))
Example #27
0
    def Follow(self, buffer=None, index=None):
        """Allows you to follow the specified user."""

        who = buffer.get_all_screen_names(index)
        if not who:
            output.speak(_("No users to follow detected in current post."),
                         True)
            return logging.debug(
                "No users to follow detected in current post.")
        new = modal_dialog(gui.FollowDialog,
                           parent=self.session.frame,
                           users=who)
        who = new.users.GetValue()
        updates = new.updates.GetValue()
        call_threaded(self.session.follow, who, updates)
Example #28
0
    def Unfollow(self, buffer=None, index=None):
        """Allows you to unfollow, block, or report the specified user as a spammer."""

        who = buffer.get_all_screen_names(index)
        if not who:
            output.speak(_("No users to unfollow detected in current post."),
                         True)
            return logging.debug(
                "No users to unfollow detected in current post.")
        new = modal_dialog(gui.UnfollowDialog,
                           parent=self.session.frame,
                           users=who)
        who = new.users.GetValue()
        action = new.action.GetSelection()
        call_threaded(self.session.do_unfollow, who, action)
Example #29
0
    def ViewUserTimeline(self, buffer=None, index=None):
        """Creates a buffer containing the timeline of the specified user."""

        who = buffer.get_all_screen_names(index)
        new = modal_dialog(gui.IndividualDialog,
                           parent=self.session.frame,
                           users=who)
        who = new.users.GetValue()
        self.session.register_buffer(
            _("%s's timeline") % who,
            buffers.Individual,
            username=who,
            count=new.retrieveCount.GetValue(),
            maxAPIPerUpdate=new.maxAPIPerUpdate.GetValue(),
            prelaunch_message=_("Loading timeline for %s.") % who)
Example #30
0
 def TranslateTweet(self, buffer=None, index=None):
  """Translate the current tweet into another language with Google Translate service."""

  try:
   text_to_translate = buffer.get_text(index).encode("UTF-8")
  except:
   text_to_translate = buffer.format_item(index).encode("UTF-8")
  dlg = modal_dialog(core.gui.TranslateDialog, parent=self.session.frame)
  source = dlg.langs_keys[dlg.source_lang_list.GetSelection()]
  target = dlg.langs_keys[dlg.target_lang_list.GetSelection()]
  try:
   translated_text = dlg.t.translate(text_to_translate, target, source)
  except Exception as e:
   logging.exception("Translation error: {0}".format(e))
   output.speak(_("Translation process has failed."), True)
  self.NewTweet(text=translated_text, title=_("Translation from %s to %s") % (dlg.langs_values[dlg.source_lang_list.GetSelection()], dlg.langs_values[dlg.target_lang_list.GetSelection()]), retweet=True)
Example #31
0
 def RelationshipStatusBetween(self, buffer=None, index=None):
  """Determine the relationship status between any two users"""

  username = self.session.username
  who = buffer.get_all_screen_names(index)
  if len(who) > 1 or who[0] != "":
   try:
    who.remove(username)
   except:
    pass
   who.append(username)
  new = modal_dialog(gui.RelationshipStatusDialog, parent=self.session.frame, users=who)
  user1 = new.users.GetValue()
  user2 = new.users2.GetValue()
  output.speak(_("Retrieving relationship status between %s and %s") % (user1, user2), True)
  call_threaded(self.session.relationship_status_between, user1, user2)
Example #32
0
 def ApplyFilter(self, buffer=None):
  """Display a buffer containing or excluding the items which contain the specified search criteria."""

  from core.sessions.buffers.buffers import Filtered
  if not buffer.get_flag('filterable'):
   logging.debug("Buffer %s is not filterable." % buffer.name)
   return output.speak(_("Buffer %s does not support filtration." % buffer.display_name), True)
  new = modal_dialog(gui.FilterDialog, parent=self.session.frame, buffer=buffer)
  output.speak(_("Processing.  Please wait."))
  filter_specs = new.get_filter_specs()
  for filter_spec in filter_specs:
   buftitle = Filtered.generate_filter_name(buffer, filter_spec)
   if filter_spec['replace']:
    replaces = buffer
   else:
    replaces = None
   filtered = self.session.register_buffer(buftitle, Filtered, replaces=replaces, source_name=buffer.name, **filter_spec)
Example #33
0
 def NewSession(self):
  """Allows you to create a new session."""
  dlg = modal_dialog(core.gui.SessionManager.NewSessionDialog, parent=application.main_frame)
  kind = dlg.sessions.GetStringSelection()
  name = dlg.name.GetValue()
  if not name:
   output.speak(_("Please enter a name for this session."))
   return self.NewSession()
  try:
   new = sessions.SpawnSession(kind=kind, name=name)
  except:
   output.speak(_("Unable to spawn new %s session.") % kind, True)
   application.main_frame.Show(False)
   return
  sessions.SetSession(new)
  output.AnnounceSession()
  application.main_frame.Show(False)
Example #34
0
    def UserInfoDialog(self, buffer=None, index=None):
        """Displays a dialog containing information such as the screen name, real name, whether or not tweets are protected, etc, for the specified user."""

        who = buffer.get_all_screen_names(index)
        new = modal_dialog(gui.UserInfoDialog,
                           parent=self.session.frame,
                           users=who)
        who = new.users.GetValue()
        output.speak(_("Loading profile for %s") % who, True)
        user_ptr = self.session.TwitterApi.show_user(screen_name=who)
        logging.debug(
            "UserInfoDialog: Twitter returned user profile for %s as \n%s" %
            (who, user_ptr))
        new = gui.TwitterProfileDialog(parent=self.session.frame,
                                       id=wx.ID_ANY,
                                       user=user_ptr)
        new.ShowModal()
Example #35
0
    def FavoritesFor(self, buffer=None, index=None):
        """Creates a buffer containing the tweets the specified user has liked."""

        who = buffer.get_all_screen_names(index)
        new = modal_dialog(gui.FavoritesDialog,
                           parent=self.session.frame,
                           users=who,
                           results_per_api=200)
        who = new.users.GetValue()
        name = _("%s's likes") % who
        self.session.register_buffer(
            name,
            buffers.Favorites,
            username=who,
            count=new.retrieveCount.GetValue(),
            maxAPIPerUpdate=new.maxAPIPerUpdate.GetValue(),
            prelaunch_message=_("Loading likes for %s.") % who)
Example #36
0
    def friendsFor(self, buffer=None, index=None):
        """Creates a buffer containing the people the specified user is following."""

        who = buffer.get_all_screen_names(index)
        new = modal_dialog(gui.FriendsDialog,
                           parent=self.session.frame,
                           users=who)
        who = new.users.GetValue()
        retrieveCount = new.retrieveCount.GetValue()
        maxAPIPerUpdate = new.maxAPIPerUpdate.GetValue()
        name = _("%s's friends") % who
        self.session.register_buffer(
            name,
            buffers.Friends,
            username=who,
            count=retrieveCount,
            maxAPIPerUpdate=maxAPIPerUpdate,
            prelaunch_message=_("Loading friends for %s.") % who)
Example #37
0
 def NewSession(self):
     """Allows you to create a new session."""
     dlg = modal_dialog(core.gui.SessionManager.NewSessionDialog,
                        parent=application.main_frame)
     kind = dlg.sessions.GetStringSelection()
     name = dlg.name.GetValue()
     if not name:
         output.speak(_("Please enter a name for this session."))
         return self.NewSession()
     try:
         new = sessions.SpawnSession(kind=kind, name=name)
     except:
         output.speak(_("Unable to spawn new %s session.") % kind, True)
         application.main_frame.Show(False)
         return
     sessions.SetSession(new)
     output.AnnounceSession()
     application.main_frame.Show(False)
Example #38
0
 def TwitterSearch (self, text=None):
  """Allows you to search twitter for the specified term."""

  if not text:
   text = self.buffer().get_hash_tags(self.buffer().index)
  text.extend(self.buffer().get_mentions(self.buffer().index))
  new = modal_dialog(gui.TwitterSearchDialog, parent=self.session.frame, title=_("Twitter search"), text=text)
  term = unicode(new.term.GetValue())
  save = new.save.GetValue()
  store = new.store.GetValue()
  count = new.retrieveCount.GetValue()
  maxAPIPerUpdate = new.maxAPIPerUpdate.GetValue()
  if count == 100 and maxAPIPerUpdate > 1:
   count = 200
  if not term:
   output.speak(_("Please enter a term to search for."), True)
   return self.TwitterSearch()
  title = _("Search for %s") % term
  search = self.session.register_buffer(title, buffers.Search, store=store, term=term, saved=save, count=count, maxAPIPerUpdate=maxAPIPerUpdate)
Example #39
0
 def TranslateTweet(self, buffer=None, index=None):
  """Translate the current tweet into another language with Google Translate service."""

  try:
   text_to_translate = buffer.get_text(index).encode("UTF-8")
  except:
   text_to_translate = buffer.format_item(index).encode("UTF-8")
  dlg = modal_dialog(core.gui.TranslateDialog, parent=self.session.frame)
  source = [x[0] for x in dlg.available_languages()][dlg.source_lang_list.GetSelection()]
  target = [x[0] for x in dlg.available_languages()][dlg.target_lang_list.GetSelection()]
  try:
   translate = Translator().translate
   response = translate(text_to_translate, lang_from=source, lang_to=target)
   if source == '':
    source = response['source_lang']
   translated_text = response['translatedText']
  except TranslationError:
   logging.exception("Translation error has happened.")
   return output.speak(_("Translation process has failed."), True)
  self.NewTweet(text=translated_text, title=_("Translation from %s to %s") % (source, target), retweet=True)
Example #40
0
    def RelationshipStatusBetween(self, buffer=None, index=None):
        """Determine the relationship status between any two users"""

        username = self.session.username
        who = buffer.get_all_screen_names(index)
        if len(who) > 1 or who[0] != "":
            try:
                who.remove(username)
            except:
                pass
            who.append(username)
        new = modal_dialog(gui.RelationshipStatusDialog,
                           parent=self.session.frame,
                           users=who)
        user1 = new.users.GetValue()
        user2 = new.users2.GetValue()
        output.speak(
            _("Retrieving relationship status between %s and %s") %
            (user1, user2), True)
        call_threaded(self.session.relationship_status_between, user1, user2)
Example #41
0
    def TranslateTweet(self, buffer=None, index=None):
        """Translate the current tweet into another language with Google Translate service."""

        try:
            text_to_translate = buffer.get_text(index).encode("UTF-8")
        except:
            text_to_translate = buffer.format_item(index).encode("UTF-8")
        dlg = modal_dialog(core.gui.TranslateDialog, parent=self.session.frame)
        source = dlg.langs_keys[dlg.source_lang_list.GetSelection()]
        target = dlg.langs_keys[dlg.target_lang_list.GetSelection()]
        try:
            translated_text = dlg.t.translate(text_to_translate, target,
                                              source)
        except Exception as e:
            logging.exception("Translation error: {0}".format(e))
            output.speak(_("Translation process has failed."), True)
        self.NewTweet(text=translated_text,
                      title=_("Translation from %s to %s") %
                      (dlg.langs_values[dlg.source_lang_list.GetSelection()],
                       dlg.langs_values[dlg.target_lang_list.GetSelection()]),
                      retweet=True)
Example #42
0
    def NewReply(self, buffer=None, index=None, text=u"", user=None):
        """Allows you to post a reply to a tweet."""

        default = user
        users = buffer.get_all_screen_names(index)
        if 'source' not in buffer[index] and 'text' in buffer[
                index] and self.session.config['UI']['DMSafeMode']:
            return self.NewDm(buffer, index, text)
        if not self.session.config['UI']['replyToSelf']:
            for n, u in enumerate(users):
                if self.session.is_current_user(u):
                    users.remove(users[n])
        if default:
            users.insert(0, default)
        if not users:
            return output.speak(_("Unable to detect a user to reply to."),
                                True)
        new = modal_dialog(gui.NewReplyDialog,
                           parent=self.session.frame,
                           default=users[0],
                           selection=users,
                           title=_("Reply"),
                           text=text)
        user = new.selection.GetValue()
        fulltext = templates.replyTemplate(user, new.message.GetValue())
        if len(fulltext) > self.session.config['lengths']['tweetLength']:
            i = fulltext.index(" ") + 1
            return self.NewReply(buffer, index, fulltext[i:])
        if new.delay:
            delay_action(new.delay,
                         self.session.post_reply,
                         buffer=buffer,
                         index=index,
                         text=fulltext,
                         action=_("reply"))
        else:
            call_threaded(self.session.post_reply,
                          buffer=buffer,
                          index=index,
                          text=fulltext)
Example #43
0
    def LocalTrends(self):
        """Creates a buffer containing the trends for the specified location."""

        output.speak(_("Retrieving locations."), True)
        try:
            locations = self.session.TwitterApi.get_available_trends()
            logging.debug("Raw locations: %s" % str(locations))
        except:
            logging.debug("Unable to obtain local trend locations.")
            return output.speak(
                _("Unable to retrieve local trend locations; please try again later."
                  ), True)
        locations.sort(key=lambda location: location['name'])
        locations_by_name = {}
        locations_tree = {}
        for location in locations:
            type = location['placeType']['name']
            place = location['name']
            if place == "Worldwide":
                continue
            locations_by_name[place] = location
            if type not in locations_tree.keys():
                locations_tree[type] = []
            locations_tree[type].append(place)
        dlg = modal_dialog(gui.LocalTrendsDialog,
                           parent=self.session.frame,
                           id=wx.ID_ANY,
                           locations_tree=locations_tree)
        if dlg.locations_list.GetSelection() == wx.NOT_FOUND:
            choice = dlg.locations_list.GetItems()[0]
        else:
            choice = dlg.locations_list.GetStringSelection()
        location = locations_by_name[choice]
        self.session.register_buffer(_("Trending: %s" % location['name']),
                                     buffers.LocalTrends,
                                     woeid=location['woeid'])
Example #44
0
 def MainConfigDialog(self):
  """Shows a dialog in which you can configure global application settings."""
  new = modal_dialog(core.gui.configuration.MainConfigDialog, parent=application.main_frame, id=wx.ID_ANY, title=_("%s Configuration") % application.name)
  new.SetNewConfigValues()
  output.speak(_("Configuration saved."), 1)
Example #45
0
 def newSMS(self):
  dlg = modal_dialog(gui.SMSDialog, parent=self.session.frame, title=_("New SMS"))
  self.session.gv.send_sms(self.session.unformat_phone_number(dlg.selection.GetValue()), dlg.message.GetValue())
  output.speak(_("Sms successfully sent to %s") % dlg.selection.GetValue())
Example #46
0
 def ViewItem(self, buffer=None, index=None):
  dlg = modal_dialog(gui.ViewItemDialog, parent=self.session.frame, label=_("Item text:"), title=_("View item"), text=buffer.format_item(index))