Ejemplo n.º 1
0
 def Quote (self, buffer=None, index=None):
  """Allows you to quote the current tweet."""

  try:
   user = buffer.get_screen_name(index)
   if 'quoted_status' not in buffer[index]:
    id = buffer[index]['id']
   else:
    id = buffer[index]['quoted_status']['id']
   tweet_link = u"https://twitter.com/%s/statuses/%s" % (user, str(id))
  except:
   logging.debug("Quoter: Unable to retrieve post to reply to.")
   return output.speak(_("Item is not a post."), True)
  if self.session.config['UI']['DMSafeMode'] and 'source' not in buffer[index]:
   logging.debug("Quoter: Preventing quote of direct message in DM safe mode...")
   return output.speak(_("Cannot quote a direct message while DM safe mode is enabled."), True)
  title="Quote"
  choice = 0
  if self.session.config['UI']['RTStyle'] == 0 and 'source' in buffer[index]:
   choice = question_dialog(caption=_("Quote"), message=_("Would you like to add a comment?"))
   if choice == wx.ID_CANCEL:
    return output.speak(_("Canceled."), True)
   elif choice == wx.ID_NO:
    return call_threaded(self.session.post_update, text=tweet_link)
   else:
    return   self.NewTweet(buffer, index, tweet_link, title)
  elif self.session.config['UI']['RTStyle'] == 1:
   logging.debug("Retweeter: Automatically retweeting...")
   call_threaded(self.session.post_retweet, id)
  elif self.session.config['UI']['RTStyle'] == 2 or 'source' not in buffer[index]:
   self.NewTweet(buffer, index, tweet_link, title)
Ejemplo n.º 2
0
 def Retweet (self, buffer=None, index=None):
  """Allows you to retweet (RT) the current tweet."""

  try:
   user = buffer.get_screen_name(index)
   text = templates.retweetTemplate(user, buffer.get_text(index))
   if 'retweeted_status' not in buffer[index]:
    id = buffer[index]['id']
   else:
    id = buffer[index]['retweeted_status']['id']
  except:
   logging.debug("Retweeter: Unable to retrieve post to reply to.")
   return output.speak(_("Item is not a post."), True)
  if self.session.config['UI']['DMSafeMode'] and 'source' not in buffer[index]:
   logging.debug("Retweeter: Preventing retweet of direct message in DM safe mode...")
   return output.speak(_("Cannot retweet a direct message while DM safe mode is enabled."), True)
  if self.session.is_current_user(user):
   logging.debug("Retweeter: Preventing retweet of user's own tweet...")
   return output.speak(_("Cannot retweet your own tweet."), True)
  title="Retweet"
  choice = 0
  if self.session.config['UI']['RTStyle'] == 0 and 'source' in buffer[index]:
   choice = question_dialog(caption=_("Retweet"), message=_("Would you like to add a comment?"))
   if choice == wx.ID_CANCEL:
    return output.speak(_("Canceled."), True)
   elif choice == wx.ID_NO:
    return call_threaded(self.session.post_retweet, id)
   else:
    return   self.NewTweet(buffer, index, text, title)
  elif self.session.config['UI']['RTStyle'] == 1:
   logging.debug("Retweeter: Automatically retweeting...")
   call_threaded(self.session.post_retweet, id)
  elif self.session.config['UI']['RTStyle'] == 2 or 'source' not in buffer[index]:
   self.NewTweet(buffer, index, text, title)
Ejemplo n.º 3
0
    def NewTweet(self,
                 buffer=None,
                 index=None,
                 text="",
                 title=None,
                 retweet=False):
        """Allows you to post a new tweet.
"""
        new = gui.NewTweetDialog(parent=self.session.frame,
                                 text=text,
                                 title=title)
        new.retweet.Show(retweet)
        new.message.SetInsertionPoint(0)
        val = new.ShowModal()
        if val == wx.ID_OK:
            if new.retweet.GetValue():
                return self.Retweet(buffer, index)
            else:
                text = new.message.GetValue()
        else:
            logging.debug("User canceled post.")
            return output.speak(_("Canceled."), True)
        if len(text) > self.session.config['lengths']['tweetLength']:
            logging.info("Tweet too long.  Forcing edit.")
            return self.NewTweet(buffer, index, text)
        if new.delay:
            delay_action(new.delay,
                         self.session.post_update,
                         text=text,
                         action=_("tweet"))
        else:
            call_threaded(self.session.post_update, text=text)
Ejemplo n.º 4
0
 def setup_timer (self, run_immediately=True):
  if self.buffer_metadata['interval']:
   self.timer = RepeatingTimer(self.buffer_metadata['interval'], self.update)
   self.timer.start()
   if run_immediately:
    logging.info("%s: performing immediate update in buffer %s" % (self.session, self))
    call_threaded(self.update, update_type=self._update_types['initial'])
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
 def process_command(self, command, kws={}):
     #Given a command and keywords from the handler, actually calls the appropriate command from the interface.
     basepath, func = command
     if basepath in self.urlmap:
         logging.debug("%s: Base path %s found in URL map." %
                       (self.name, basepath))
         call_threaded(self._exec_command, basepath, func, kws)
Ejemplo n.º 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)
Ejemplo n.º 8
0
 def ForceSyncToDisk(self):
     """Saves the current session's database to disk."""
     #FIXME Should be moved to storage session
     output.speak(
         _("Syncing storage to disk for %s session." %
           sessions.current_session.name), True)
     call_threaded(sessions.current_session.sync, forced=True, speak=True)
Ejemplo n.º 9
0
 def __init__(self,
              store=False,
              term="",
              saved=False,
              saved_id=0,
              *args,
              **kwargs):
     self.init_done_event = threading.Event()
     super(Search, self).__init__(*args, **kwargs)
     self.initial_update = True
     self.term = unicode(term)
     self.saved = saved or bool(saved_id)
     self.saved_id = saved_id
     if saved:
         call_threaded(self.create_saved_search)
     self.item_name = _("result for %s") % self.term
     self.item_name_plural = _("results for %s") % self.term
     self.item_sound = self.session.config['sounds']['resultReceived']
     self.default_template = 'search'
     self.store_args({'store': store, 'term': term, 'saved': saved})
     self.set_flag('temp', not store)
     if 'name' in self.item_fields:
         del self.item_fields['name']
     if 'geo' in self.item_fields:
         del self.item_fields['geo']
     #self.set_field('screen_name', _("Screen Name"), 'from_user')
     self.init_done_event.set()
Ejemplo n.º 10
0
 def NewTweet(self, buffer=None, index=None, text=u"", title=None, retweet=False, quote=False):
  """Allows you to post a new tweet.
"""
  new = gui.NewTweetDialog(parent=self.session.frame, text=text, title=title)
  new.retweet.Show(retweet)
  new.quote.Show(quote)
  new.message.SetInsertionPoint(0)
  val=new.ShowModal()
  if val==wx.ID_OK:
   if new.retweet.GetValue():
    return self.Retweet(buffer, index)
   elif new.quote.GetValue():
    return self.Quote(buffer, index)
   else:
    text = new.message.GetValue()
  else:
   logging.debug("User canceled post.")
   return output.speak(_("Canceled."), True)
  if len(text) > self.session.config['lengths']['tweetLength']:
   logging.info("Tweet too long.  Forcing edit.")
   return self.NewTweet(buffer, index, text)
  if new.delay:
   delay_action(new.delay, self.session.post_update, text=text, action=_("tweet"))
  else:
   call_threaded(self.session.post_update, text=text)
Ejemplo n.º 11
0
def RegisterSession(name, type, *args, **kwargs):
    """Registers session  in sessions list."""
    global current_session
    global sessions
    logging.debug(
        "Sessions: Registering new %s session named %s.  Args: %s kwargs: %s" %
        (type, name, args, kwargs))
    try:
        new = getattr(session, type)(name=name, type=type, *args, **kwargs)
    except:
        return logging.exception(
            "Unable to initialize an instance of session.%s " % type)
    if SessionExists(new):
        return logging.warning(
            "Suppressed duplicate registration of session %s" % name)
    AddSession(new)
    try:
        call_threaded(dispatcher.send,
                      sender=new,
                      signal=signals.session_created)
    except:
        logging.exception(
            "sessions.RegisterSession: Something errored when the NewSession signal was sent."
        )
    return sessions.index(new)
Ejemplo n.º 12
0
    def UpdateCurrentBuffer(self, buffer=None):
        """Check for, and retrieve any new data in the current buffer."""

        if not buffer.get_flag('updatable'):
            return output.speak(
                _("Forcing updates is not permitted in this buffer."), True)
        call_threaded(buffer.update,
                      update_type=buffer._update_types['forced'])
Ejemplo n.º 13
0
 def login_succeeded (self):
  self.save_config()
  output.speak(_("Logged into Twitter as %s") % self.username)
  self.API_initialized()
  self.setup_stream()
  if self.config['UI']['autoLoadSearches']:
   call_threaded(self.load_saved_searches)
  if self.config['UI']['autoLoadLists']:
   call_threaded(self.load_lists)
Ejemplo n.º 14
0
 def login_succeeded(self):
     self.save_config()
     output.speak(_("Logged into Twitter as %s") % self.username)
     self.API_initialized()
     self.setup_stream()
     if self.config['UI']['autoLoadSearches']:
         call_threaded(self.load_saved_searches)
     if self.config['UI']['autoLoadLists']:
         call_threaded(self.load_lists)
Ejemplo n.º 15
0
 def setup_timer(self, run_immediately=True):
     if self.buffer_metadata['interval']:
         self.timer = RepeatingTimer(self.buffer_metadata['interval'],
                                     self.update)
         self.timer.start()
         if run_immediately:
             logging.info("%s: performing immediate update in buffer %s" %
                          (self.session, self))
             call_threaded(self.update,
                           update_type=self._update_types['initial'])
Ejemplo n.º 16
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)
Ejemplo n.º 17
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)
Ejemplo n.º 18
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))
Ejemplo n.º 19
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)
Ejemplo n.º 20
0
 def RelationshipStatus(self, buffer=None, index=None):
  """Retrieve and speak the current relationship between yourself and the user associated with the focused item"""

  try:
   name = buffer.get_screen_name(index)
  except:
   output.speak(_("No user detected in current item."), 1)
   return
  try:
   name = buffer.get_name(index)
  except:
   pass
  output.speak(_("Retrieving relationship status for %s") % name, True)
  call_threaded(self.session.relationship_status, buffer=buffer, index=index)
Ejemplo n.º 21
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))
Ejemplo n.º 22
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)
Ejemplo n.º 23
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)
Ejemplo n.º 24
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)
Ejemplo n.º 25
0
    def RelationshipStatus(self, buffer=None, index=None):
        """Retrieve and speak the current relationship between yourself and the user associated with the focused item"""

        try:
            name = buffer.get_screen_name(index)
        except:
            output.speak(_("No user detected in current item."), 1)
            return
        try:
            name = buffer.get_name(index)
        except:
            pass
        output.speak(_("Retrieving relationship status for %s") % name, True)
        call_threaded(self.session.relationship_status,
                      buffer=buffer,
                      index=index)
Ejemplo n.º 26
0
def RegisterSession (name, type, *args, **kwargs):
 """Registers session  in sessions list."""
 global current_session
 global sessions
 logging.debug("Sessions: Registering new %s session named %s.  Args: %s kwargs: %s" % (type, name, args, kwargs))
 try:
  new = getattr (session, type) (name=name, type=type, *args, **kwargs)
 except:
  return logging.exception("Unable to initialize an instance of session.%s " % type)
 if SessionExists(new):
  return logging.warning("Suppressed duplicate registration of session %s" % name)
 AddSession (new)
 try:
  call_threaded(dispatcher.send, sender=new, signal=signals.session_created)
 except:
  logging.exception("sessions.RegisterSession: Something errored when the NewSession signal was sent.")
 return sessions.index(new)
Ejemplo n.º 27
0
    def Retweet(self, buffer=None, index=None):
        """Allows you to retweet (RT) the current tweet."""

        try:
            user = buffer.get_screen_name(index)
            text = templates.retweetTemplate(user, buffer.get_text(index))
            if 'retweeted_status' not in buffer[index]:
                id = buffer[index]['id']
            else:
                id = buffer[index]['retweeted_status']['id']
        except:
            logging.debug("Retweeter: Unable to retrieve post to reply to.")
            return output.speak(_("Item is not a post."), True)
        if self.session.config['UI']['DMSafeMode'] and 'source' not in buffer[
                index]:
            logging.debug(
                "Retweeter: Preventing retweet of direct message in DM safe mode..."
            )
            return output.speak(
                _("Cannot retweet a direct message while DM safe mode is enabled."
                  ), True)
        if self.session.is_current_user(user):
            logging.debug(
                "Retweeter: Preventing retweet of user's own tweet...")
            return output.speak(_("Cannot retweet your own tweet."), True)
        title = "Retweet"
        choice = 0
        if self.session.config['UI']['RTStyle'] == 0 and 'source' in buffer[
                index]:
            choice = question_dialog(
                caption=_("Retweet"),
                message=_("Would you like to add a comment?"))
            if choice == wx.ID_CANCEL:
                return output.speak(_("Canceled."), True)
            elif choice == wx.ID_NO:
                return call_threaded(self.session.post_retweet, id)
            else:
                return self.NewTweet(buffer, index, text, title)
        elif self.session.config['UI']['RTStyle'] == 1:
            logging.debug("Retweeter: Automatically retweeting...")
            call_threaded(self.session.post_retweet, id)
        elif self.session.config['UI'][
                'RTStyle'] == 2 or 'source' not in buffer[index]:
            self.NewTweet(buffer, index, text, title)
Ejemplo n.º 28
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)
Ejemplo n.º 29
0
def RemoveSession(session, end=False, delete = False):
 """Remove session from global sessions list.  Accepts a session object."""
 global sessions
 logging.info("Removing session %s from global list." % session.name)
 index = GetSessionIndex(session)
 index = index - 1
 if not end:
  SetSession(index)
 try:
  sessions.remove(session)
  config.main['sessions']['sessions'].remove(session_descriptor(session))
  config.main.write()
 except:
  pass
 try:
  call_threaded(session.shutdown, end=end, delete=delete)
 except:
  logging.exception("Error deactivating session...")
 dispatcher.send(sender=session, signal=signals.session_destroyed)
 output.AnnounceSession()
Ejemplo n.º 30
0
def RemoveSession(session, end=False, delete=False):
    """Remove session from global sessions list.  Accepts a session object."""
    global sessions
    logging.info("Removing session %s from global list." % session.name)
    index = GetSessionIndex(session)
    index = index - 1
    if not end:
        SetSession(index)
    try:
        sessions.remove(session)
        config.main['sessions']['sessions'].remove(session_descriptor(session))
        config.main.write()
    except:
        pass
    try:
        call_threaded(session.shutdown, end=end, delete=delete)
    except:
        logging.exception("Error deactivating session...")
    dispatcher.send(sender=session, signal=signals.session_destroyed)
    output.AnnounceSession()
Ejemplo n.º 31
0
    def Quote(self, buffer=None, index=None):
        """Allows you to quote the current tweet."""

        try:
            user = buffer.get_screen_name(index)
            if 'quoted_status' not in buffer[index]:
                id = buffer[index]['id']
            else:
                id = buffer[index]['quoted_status']['id']
            tweet_link = u"https://twitter.com/%s/statuses/%s" % (user,
                                                                  str(id))
        except:
            logging.debug("Quoter: Unable to retrieve post to reply to.")
            return output.speak(_("Item is not a post."), True)
        if self.session.config['UI']['DMSafeMode'] and 'source' not in buffer[
                index]:
            logging.debug(
                "Quoter: Preventing quote of direct message in DM safe mode..."
            )
            return output.speak(
                _("Cannot quote a direct message while DM safe mode is enabled."
                  ), True)
        title = "Quote"
        choice = 0
        if self.session.config['UI']['RTStyle'] == 0 and 'source' in buffer[
                index]:
            choice = question_dialog(
                caption=_("Quote"),
                message=_("Would you like to add a comment?"))
            if choice == wx.ID_CANCEL:
                return output.speak(_("Canceled."), True)
            elif choice == wx.ID_NO:
                return call_threaded(self.session.post_update, text=tweet_link)
            else:
                return self.NewTweet(buffer, index, tweet_link, title)
        elif self.session.config['UI']['RTStyle'] == 1:
            logging.debug("Retweeter: Automatically retweeting...")
            call_threaded(self.session.post_retweet, id)
        elif self.session.config['UI'][
                'RTStyle'] == 2 or 'source' not in buffer[index]:
            self.NewTweet(buffer, index, tweet_link, title)
Ejemplo n.º 32
0
 def __init__(self, store=False, term="", saved=False, saved_id=0, *args, **kwargs):
  self.init_done_event = threading.Event()
  super(Search, self).__init__(*args, **kwargs)
  self.initial_update = True
  self.term = unicode(term)
  self.saved = saved or bool(saved_id)
  self.saved_id = saved_id
  if saved:
    call_threaded(self.create_saved_search)
  self.item_name = _("result for %s") % self.term
  self.item_name_plural = _("results for %s") % self.term
  self.item_sound = self.session.config['sounds']['resultReceived']
  self.default_template = 'search'
  self.store_args({'store':store, 'term':term, 'saved':saved})
  self.set_flag('temp', not store)
  if 'name' in self.item_fields:
   del self.item_fields['name']
  if 'geo' in self.item_fields:
   del self.item_fields['geo']
  #self.set_field('screen_name', _("Screen Name"), 'from_user')
  self.init_done_event.set()
Ejemplo n.º 33
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)
Ejemplo n.º 34
0
 def setup_stream(self):
     consumer = oauth2.Token(key=self.config['oauth']['twitterKey'],
                             secret=self.config['oauth']['twitterSecret'])
     token = oauth2.Token(key=self.config['oauth']['userKey'],
                          secret=self.config['oauth']['userSecret'])
     self.streamer = stream.UserStreamer(
         consumer=consumer,
         token=token,
         callback=self.stream_callback,
         reconnected_callback=self.update_all_buffers())
     logging.debug("Twitter user stream created.")
     self.daemon_stream = call_threaded(self.streamer.stream)
     logging.debug("Twitter user Stream connected.")
Ejemplo n.º 35
0
 def setup_stream(self):
  twitterDataOrig = str(self.config['oauth']['twitterData'])
  trans = maketrans("-_~", "+/=")
  twitterDataTrans = twitterDataOrig.translate(trans)
  twitterData = b64decode(twitterDataTrans)
  twitterData = literal_eval(twitterData)
  userDataOrig = str(self.config['oauth']['userData'])
  userDataTrans = userDataOrig.translate(trans)
  userData = b64decode(userDataTrans)
  userData = literal_eval(userData)
  consumer = oauth2.Token(key=twitterData[0], secret=twitterData[1])
  token = oauth2.Token(key=userData[0], secret=userData[1])
  self.streamer = stream.UserStreamer(consumer=consumer, token=token, callback=self.stream_callback, reconnected_callback=self.update_all_buffers())
  logging.debug("Twitter user stream created.")
  self.daemon_stream = call_threaded(self.streamer.stream)
  logging.debug("Twitter user Stream connected.")
Ejemplo n.º 36
0
 def setup_stream(self):
  twitterDataOrig = str(self.config['oauth']['twitterData'])
  trans = maketrans("-_~", "+/=")
  twitterDataTrans = twitterDataOrig.translate(trans)
  twitterData = b64decode(twitterDataTrans)
  twitterData = literal_eval(twitterData)
  userDataOrig = str(self.config['oauth']['userData'])
  userDataTrans = userDataOrig.translate(trans)
  userData = b64decode(userDataTrans)
  userData = literal_eval(userData)
  consumer = oauth2.Token(key=twitterData[0], secret=twitterData[1])
  token = oauth2.Token(key=userData[0], secret=userData[1])
  self.streamer = stream.UserStreamer(consumer=consumer, token=token, callback=self.stream_callback, reconnected_callback=self.update_all_buffers())
  logging.debug("Twitter user stream created.")
  self.daemon_stream = call_threaded(self.streamer.stream)
  logging.debug("Twitter user Stream connected.")
Ejemplo n.º 37
0
 def SetNewConfigValues (self):
  logging.debug("Saving default buffer configuration from dialog.")
  self.session.config['updates']['checkInterval'] = int(self.panels[0].checkInterval.GetValue()) * 60
  logging.info("Check interval set to: %s" % self.session.config['updates']['checkInterval'])
  self.session.config['counts']['retrieveCount'] = int(self.panels[0].retrieveCount.GetValue()) or 100
  logging.info("Retrieve count set to: %s" % self.session.config['counts']['retrieveCount'])
  self.session.config['updates']['maxAPIPerUpdate'] = int(self.panels[0].maxAPIPerUpdate.GetValue()) or 1
  logging.info("Max API calls per update set to: %s" % self.session.config['updates']['maxAPIPerUpdate'])
  self.session.config['sounds']['defaultBufferMute'] = self.panels[0].mute.GetValue()
  logging.info("Mute set to: %s" % self.session.config['sounds']['mute'])
  if self.panels[0].applyToAll.GetValue():
   apply = call_threaded(self.ApplyDefaultBufferSettingsToAll)
  else:
   logging.debug("Saving buffer configuration from dialog.")
   for panel in self.panels[1:]:
    if panel.buffer.buffer_metadata.has_key('interval') and panel.buffer.buffer_metadata['interval'] != panel.checkInterval.GetValue() * 60:
     panel.buffer.set_new_interval(panel.checkInterval.GetValue() * 60)
     logging.info("Update interval for buffer %s set to: %s" % (panel.buffer.name, panel.buffer.buffer_metadata['interval'] / 60))
    if panel.buffer.buffer_metadata.has_key('retrieveCount') and panel.buffer.buffer_metadata['retrieveCount'] != panel.retrieveCount.GetValue():
     panel.buffer.count = panel.buffer.buffer_metadata['retrieveCount'] = panel.retrieveCount.GetValue()
     logging.info("Retrieve count for buffer %s set to: %s" % (panel.buffer.name, panel.buffer.buffer_metadata['retrieveCount']))
    if panel.buffer.buffer_metadata.has_key('maxAPIPerUpdate') and panel.buffer.buffer_metadata['maxAPIPerUpdate'] != panel.maxAPIPerUpdate.GetValue():
     panel.buffer.maxAPIPerUpdate = panel.buffer.buffer_metadata['maxAPIPerUpdate'] = panel.maxAPIPerUpdate.GetValue()
     logging.info("Retrieve count for buffer %s set to: %s" % (panel.buffer.name, panel.buffer.buffer_metadata['maxAPIPerUpdate']))
    if panel.buffer.buffer_metadata.has_key('sounds') and panel.buffer.buffer_metadata['sounds'].has_key('mute') and panel.buffer.buffer_metadata['sounds']['mute'] != panel.mute.GetValue():
     panel.buffer.buffer_metadata['sounds']['mute'] = panel.mute.GetValue()
     logging.info("Mute for buffer %s set to: %s" % (panel.buffer.name, panel.buffer.buffer_metadata['sounds']['mute']))
    if not panel.buffer.get_flag('fixed_template'):
     if panel.useDefaultClipboard.GetValue():
      if 'clipboard' in panel.buffer.buffer_metadata:
       del panel.buffer.buffer_metadata['clipboard']
      logging.info("Clipboard template for {0} was reset to default.".format(panel.buffer.name))
     else:
      panel.buffer.buffer_metadata['clipboard'] = panel.clipboard.GetValue()
      logging.info("Clipboard template for buffer %s set to: %s." % (panel.buffer.name, panel.buffer.buffer_metadata['clipboard']))
     if panel.useDefaultSpoken.GetValue():
      if 'spoken' in panel.buffer.buffer_metadata:
       del panel.buffer.buffer_metadata['spoken']
      logging.info("Spoken template for {0} was reset to default.".format(panel.buffer.name))
     else:
      panel.buffer.buffer_metadata['spoken'] = panel.spoken.GetValue()
      logging.info("Spoken template for buffer %s set to: %s." % (panel.buffer.name, panel.buffer.buffer_metadata['spoken']))
Ejemplo n.º 38
0
 def DeviceNotifications(self, buffer=None, index=None):
  """Toggles whether or not device notifications will be sent to your mobile device. Your device must be configured on twitter first."""

  call_threaded(self.session.toggle_device_notifications, buffer, index)
Ejemplo n.º 39
0
 def UnfavoriteTweet(self, buffer=None, index=None):
  """If possible, removes the current tweet from your favorites."""

  call_threaded(self.session.unfavorite_tweet, buffer, index)
Ejemplo n.º 40
0
 def FavoriteTweet(self, buffer=None, index=None):
  """Add the current tweet to your favorites on twitter."""

  call_threaded(self.session.favorite_tweet, buffer, index)
Ejemplo n.º 41
0
 def destroy(self):
     call_threaded(self.do_destroy)
Ejemplo n.º 42
0
 def unlisten(self):
     call_threaded(self._unlisten)
Ejemplo n.º 43
0
 def on_play(self, evt):
  evt.Skip()
  if not self.playing:
   call_threaded(self._play)
  else:
   self._stop()
Ejemplo n.º 44
0
 def UpdateCurrentBuffer (self, buffer=None):
  """Check for, and retrieve any new data in the current buffer."""

  if not buffer.get_flag('updatable'):
   return output.speak(_("Forcing updates is not permitted in this buffer."), True)
  call_threaded(buffer.update, update_type=buffer._update_types['forced'])
Ejemplo n.º 45
0
    def DeviceNotifications(self, buffer=None, index=None):
        """Toggles whether or not device notifications will be sent to your mobile device. Your device must be configured on twitter first."""

        call_threaded(self.session.toggle_device_notifications, buffer, index)
Ejemplo n.º 46
0
    def UpdateProfile(self):
        """Update the information displayed on your twitter profile for other people to view."""

        call_threaded(self.session.update_profile)
Ejemplo n.º 47
0
 def on_play(self, evt):
  evt.Skip()
  if not self.playing:
   call_threaded(self._play)
  else:
   self._stop()
Ejemplo n.º 48
0
 def UpdateProfile(self):
  """Update the information displayed on your twitter profile for other people to view."""

  call_threaded(self.session.update_profile)
Ejemplo n.º 49
0
 def unlisten (self):
  call_threaded(self._unlisten)
Ejemplo n.º 50
0
 def shutdown (self, end=False):
  if self.saved and not end:
   call_threaded(self.remove_saved_search)
  return super(Search, self).shutdown(end)
Ejemplo n.º 51
0
def setup():
    application.update_timer = RepeatingTimer(UPDATE_INTERVAL,
                                              check_for_update)
    application.update_timer.start()
    call_threaded(check_for_update)
Ejemplo n.º 52
0
 def SetNewConfigValues(self):
     logging.debug("Saving default buffer configuration from dialog.")
     self.session.config["updates"]["checkInterval"] = int(self.panels[0].checkInterval.GetValue()) * 60
     logging.info("Check interval set to: %s" % self.session.config["updates"]["checkInterval"])
     self.session.config["counts"]["retrieveCount"] = int(self.panels[0].retrieveCount.GetValue()) or 100
     logging.info("Retrieve count set to: %s" % self.session.config["counts"]["retrieveCount"])
     self.session.config["updates"]["maxAPIPerUpdate"] = int(self.panels[0].maxAPIPerUpdate.GetValue()) or 1
     logging.info("Max API calls per update set to: %s" % self.session.config["updates"]["maxAPIPerUpdate"])
     self.session.config["sounds"]["defaultBufferMute"] = self.panels[0].mute.GetValue()
     logging.info("Mute set to: %s" % self.session.config["sounds"]["mute"])
     if self.panels[0].applyToAll.GetValue():
         apply = call_threaded(self.ApplyDefaultBufferSettingsToAll)
     else:
         logging.debug("Saving buffer configuration from dialog.")
         for panel in self.panels[1:]:
             if (
                 panel.buffer.buffer_metadata.has_key("interval")
                 and panel.buffer.buffer_metadata["interval"] != panel.checkInterval.GetValue() * 60
             ):
                 panel.buffer.set_new_interval(panel.checkInterval.GetValue() * 60)
                 logging.info(
                     "Update interval for buffer %s set to: %s"
                     % (panel.buffer.name, panel.buffer.buffer_metadata["interval"] / 60)
                 )
             if (
                 panel.buffer.buffer_metadata.has_key("retrieveCount")
                 and panel.buffer.buffer_metadata["retrieveCount"] != panel.retrieveCount.GetValue()
             ):
                 panel.buffer.count = panel.buffer.buffer_metadata["retrieveCount"] = panel.retrieveCount.GetValue()
                 logging.info(
                     "Retrieve count for buffer %s set to: %s"
                     % (panel.buffer.name, panel.buffer.buffer_metadata["retrieveCount"])
                 )
             if (
                 panel.buffer.buffer_metadata.has_key("maxAPIPerUpdate")
                 and panel.buffer.buffer_metadata["maxAPIPerUpdate"] != panel.maxAPIPerUpdate.GetValue()
             ):
                 panel.buffer.maxAPIPerUpdate = panel.buffer.buffer_metadata[
                     "maxAPIPerUpdate"
                 ] = panel.maxAPIPerUpdate.GetValue()
                 logging.info(
                     "Retrieve count for buffer %s set to: %s"
                     % (panel.buffer.name, panel.buffer.buffer_metadata["maxAPIPerUpdate"])
                 )
             if (
                 panel.buffer.buffer_metadata.has_key("sounds")
                 and panel.buffer.buffer_metadata["sounds"].has_key("mute")
                 and panel.buffer.buffer_metadata["sounds"]["mute"] != panel.mute.GetValue()
             ):
                 panel.buffer.buffer_metadata["sounds"]["mute"] = panel.mute.GetValue()
                 logging.info(
                     "Mute for buffer %s set to: %s"
                     % (panel.buffer.name, panel.buffer.buffer_metadata["sounds"]["mute"])
                 )
             if not panel.buffer.get_flag("fixed_template"):
                 if panel.useDefaultClipboard.GetValue():
                     if "clipboard" in panel.buffer.buffer_metadata:
                         del panel.buffer.buffer_metadata["clipboard"]
                     logging.info("Clipboard template for {0} was reset to default.".format(panel.buffer.name))
                 else:
                     panel.buffer.buffer_metadata["clipboard"] = panel.clipboard.GetValue()
                     logging.info(
                         "Clipboard template for buffer %s set to: %s."
                         % (panel.buffer.name, panel.buffer.buffer_metadata["clipboard"])
                     )
                 if panel.useDefaultSpoken.GetValue():
                     if "spoken" in panel.buffer.buffer_metadata:
                         del panel.buffer.buffer_metadata["spoken"]
                     logging.info("Spoken template for {0} was reset to default.".format(panel.buffer.name))
                 else:
                     panel.buffer.buffer_metadata["spoken"] = panel.spoken.GetValue()
                     logging.info(
                         "Spoken template for buffer %s set to: %s."
                         % (panel.buffer.name, panel.buffer.buffer_metadata["spoken"])
                     )
Ejemplo n.º 53
0
 def update_all_buffers(self):
     for i in self.buffers:
         call_threaded(i.update, update_type=i._update_types['initial'])
Ejemplo n.º 54
0
    def FavoriteTweet(self, buffer=None, index=None):
        """Add the current tweet to your likes on twitter."""

        call_threaded(self.session.favorite_tweet, buffer, index)
Ejemplo n.º 55
0
 def update_all_buffers(self):
  for i in self.buffers:
   call_threaded(i.update, update_type=i._update_types['initial'])
Ejemplo n.º 56
0
 def listen (self):
  call_threaded(self._listen)
Ejemplo n.º 57
0
    def UnfavoriteTweet(self, buffer=None, index=None):
        """If possible, removes the current tweet from your likes."""

        call_threaded(self.session.unfavorite_tweet, buffer, index)
Ejemplo n.º 58
0
 def process_command (self, command, kws={}):
  #Given a command and keywords from the handler, actually calls the appropriate command from the interface.
  basepath, func = command
  if basepath in self.urlmap:
   logging.debug("%s: Base path %s found in URL map." % (self.name, basepath))
   call_threaded(self._exec_command, basepath, func, kws)
Ejemplo n.º 59
0
    def GetRateLimitStatus(self):
        """Reports the number of calls you can make to twitter  as well as how long you have until they reset."""

        output.speak(_("Checking current API call count..."), True)
        call_threaded(self.session.remaining_api_calls)