Exemple #1
0
 def on_success(self, data):
  try:
   if "delete" in data:
    pub.sendMessage("tweet-deleted", data=data)
   if "direct_message" in data:
    self.process_dm(data)
   elif "friends" in data:
    self.friends = data["friends"]
    pub.sendMessage("friends-receibed")
   elif "text" in data and utils.is_allowed(data, self.session.settings["twitter"]["ignored_clients"]) == True:
    if data["user"]["id"] in self.muted_users: return
    self.check_mentions(data)
    self.check_send(data)
    if data["user"]["id"] in self.friends or data["user"]["screen_name"] == self.session.db["user_name"]:
     d = self.put_data("home_timeline", data)
     if d != False:
      pub.sendMessage("item-in-home", data=data, user=self.get_user())
   elif data.has_key("event"):
    if "favorite" == data["event"] and "favorites" in self.session.settings["general"]["buffer_order"]:
     self.check_favs(data)
    elif "unfavorite" == data["event"] and "favorites" in self.session.settings["general"]["buffer_order"]:
     self.remove_fav(data)
    elif "follow" == data["event"] and "followers" in self.session.settings["general"]["buffer_order"]:
     self.check_follower(data)
    elif "unfollow" == data["event"] and "friends" in self.session.settings["general"]["buffer_order"]:
     self.remove_friend(data)
    elif "block" == data["event"]:
     self.block_user(data)
    elif "unblock" == data["event"]:
     self.unblock(data)
    elif "list_created" == data["event"]:
     item = utils.find_item(data["target_object"]["id"], self.session.db["lists"])
     if item != None: self.session.db["lists"].append(data["target_object"])
    elif "list_destroyed" == data["event"]:
     item = utils.find_item(data["target_object"]["id"], self.session.db["lists"])
     if item != None: self.session.db["lists"].pop(item)
     self.parent.remove_list(data["target_object"]["id"])
    elif "list_member_added" == data["event"] and data["source"]["screen_name"] == self.get_user():
     pub.sendMessage("new-list-member-added", **{"id":str(data["target"]["id"]), "list":data["target_object"], "user":self.get_user()})
    elif "list_member_added" == data["event"] and data["target"]["screen_name"] == self.get_user():
     self.session.db["lists"].append(data["target_object"])
    elif "list_member_removed" == data["event"] and data["source"]["screen_name"] == self.get_user():
     pub.sendMessage("list-member-deleted", **{"id":str(data["target"]["id"]), "list":data["target_object"], "user":self.get_user()})
    elif "list_member_removed" == data["event"] and data["target"] == self.get_user():
     id = data["target_object"]["id"]
     list = utils.find_item(id, self.session.db["lists"])
     if list != None: self.session.db["lists"].pop(list)
     pub.sendMessage("list-deleted", **{"item":list, "user":self.get_user()})
    elif "quoted_tweet" == data["event"]:
     self.set_quoted_tweet(data["target_object"])

    if "events" in self.session.settings["general"]["buffer_order"]:
     pub.sendMessage("event", data= data, user= self.get_user())
#     self.sound.play("new_event.ogg")
  except KeyboardInterrupt:
   pass
 def on_success(self, data):
  try:
   if "direct_message" in data:
    self.process_dm(data)
   elif "friends" in data:
    self.friends = data["friends"]
    pub.sendMessage("friends-receibed")
   elif "text" in data and utils.is_allowed(data, self.session.settings["twitter"]["ignored_clients"]) == True:
    if data["user"]["id"] in self.muted_users: return
    self.check_mentions(data)
    self.check_send(data)
    if data["user"]["id"] in self.friends or data["user"]["screen_name"] == self.session.db["user_name"]:
     self.put_data("home_timeline", data)
     pub.sendMessage("item-in-home", data=data, user=self.get_user())
   elif data.has_key("event"):
    if "favorite" == data["event"] and "favorites" in self.session.settings["general"]["buffer_order"]:
     self.check_favs(data)
    elif "unfavorite" == data["event"] and "favorites" in self.session.settings["general"]["buffer_order"]:
     self.remove_fav(data)
    elif "follow" == data["event"] and "followers" in self.session.settings["general"]["buffer_order"]:
     self.check_follower(data)
    elif "unfollow" == data["event"] and "friends" in self.session.settings["general"]["buffer_order"]:
     self.remove_friend(data)
    elif "block" == data["event"]:
     self.block_user(data)
    elif "unblock" == data["event"]:
     self.unblock(data)
    elif "list_created" == data["event"]:
     item = utils.find_item(data["target_object"]["id"], self.session.db["lists"])
     if item != None: self.session.db["lists"].append(data["target_object"])
    elif "list_destroyed" == data["event"]:
     item = utils.find_item(data["target_object"]["id"], self.session.db["lists"])
     if item != None: self.session.db["lists"].pop(item)
     self.parent.remove_list(data["target_object"]["id"])
    elif "list_member_added" == data["event"] and data["source"]["screen_name"] == self.get_user():
     pub.sendMessage("new-list-member-added", **{"id":str(data["target"]["id"]), "list":data["target_object"], "user":self.get_user()})
    elif "list_member_added" == data["event"] and data["target"]["screen_name"] == self.get_user():
     self.session.db["lists"].append(data["target_object"])
    elif "list_member_removed" == data["event"] and data["source"]["screen_name"] == self.get_user():
     pub.sendMessage("list-member-deleted", **{"id":str(data["target"]["id"]), "list":data["target_object"], "user":self.get_user()})
    elif "list_member_removed" == data["event"] and data["target"] == self.get_user():
     id = data["target_object"]["id"]
     list = utils.find_item(id, self.session.db["lists"])
     if list != None: self.session.db["lists"].pop(list)
     pub.sendMessage("list-deleted", **{"item":list, "user":self.get_user()})
    elif "quoted_tweet" == data["event"]:
     self.set_quoted_tweet(data["target_object"])

    if "events" in self.session.settings["general"]["buffer_order"]:
     pub.sendMessage("event", data= data, user= self.get_user())
#     self.sound.play("new_event.ogg")
  except KeyboardInterrupt:
   pass
Exemple #3
0
 def check_tls(self, data):
  for i in self.session.settings["other_buffers"]["timelines"]:
   if data["user"]["screen_name"] == i:
    if utils.find_item(data["id"], self.session.db["%s-timeline" % (i,)]) != None:
     log.error("duplicated tweet. Ignoring it...")
     return
    try:
     data_ = self.session.check_quoted_status(data)
     data_ = self.session.check_long_tweet(data_)
     data = data_
    except AttributeError:
     pass
    if self.session.settings["general"]["reverse_timelines"] == False: self.session.db["%s-timeline" % (i,)].append(data)
    else: self.session.db["%s-timeline" % (i,)].insert(0, data)
    pub.sendMessage("item-in-timeline", data= data, user= self.session.db["user_name"], who= i)
  for i in self.session.lists:
   try:
    i.users.index(data["user"]["id"])
    usr = data["in_reply_to_user_id"]
    if (usr != None and usr in self.friends) or data.has_key("retweeted_status"):
     data = self.session.check_quoted_status(data)
     if self.session.settings["general"]["reverse_timelines"] == False: self.session.db["%s" % (i.name,)].append(data)
     else: self.session.db["%s" % (i.name,)].insert(0, data)
     pub.sendMessage("item-in-list", data=data, user=self.session.db["user_name"], where=i.name)
    elif usr == None:
     if self.session.settings["general"]["reverse_timelines"] == False: self.session.db["%s" % (i.name,)].append(data)
     else: self.session.db["%s" % (i.name,)].insert(0, data)
     pub.sendMessage("item-in-list", data=data, user=self.session.db["user_name"], where=i.name)
   except ValueError:
    pass
Exemple #4
0
 def remove_fav(self, data):
  if self.db.settings["user_name"] == data["source"]["screen_name"]:
   self.db.settings.update()
   item = utils.find_item(data["target_object"]["id"], self.db.settings["favs"])
   self.db.settings["favs"].pop(item)
   deleted_event = event.event(event.EVT_DELETED, 1)
   deleted_event.SetItem(item)
   wx.PostEvent(self.parent.search_buffer("buffer", "favs"), deleted_event)
Exemple #5
0
 def onDelete(self, event=None):
     list_id = self.lists[self.lista.get_selected()]["id"]
     try:
         list = self.twitter.twitter.unsubscribe_from_list(list_id=list_id)
         item = utils.find_item(list["id"], self.db.settings["lists"])
         self.db.settings["lists"].remove(list)
     except TwythonError as e:
         output.speak("error %s: %s" % (e.msg))
Exemple #6
0
 def unblock(self, data):
  if config.main["other_buffers"]["show_blocks"] == True:
   item = utils.find_item(data["target"]["id"], self.db.settings["blocks"])
   self.db.settings["blocks"].pop(item)
   deleted_event = event.event(event.EVT_DELETED, 1)
   deleted_event.SetItem(item)
   wx.PostEvent(self.parent.search_buffer("people", "blocks"), deleted_event)
   wx.PostEvent(self.parent, event.ResultEvent())
Exemple #7
0
 def onDelete(self, event=None):
     list_id = self.lists[self.lista.get_selected()]["id"]
     try:
         list = self.twitter.twitter.unsubscribe_from_list(list_id=list_id)
         item = utils.find_item(list["id"], self.db.settings["lists"])
         self.db.settings["lists"].remove(list)
     except TwythonError as e:
         output.speak("error %s: %s" % (e.msg))
Exemple #8
0
 def onGo(self, ev):
     list_id = self.lists[self.lista.get_selected()]["id"]
     try:
         list = self.twitter.twitter.subscribe_to_list(list_id=list_id)
         item = utils.find_item(list["id"], self.db.settings["lists"])
         self.db.settings["lists"].append(list)
     except TwythonError as e:
         output.speak("error %s: %s" % (e.status_code, e.msg))
Exemple #9
0
 def onGo(self, ev):
     list_id = self.lists[self.lista.get_selected()]["id"]
     try:
         list = self.twitter.twitter.subscribe_to_list(list_id=list_id)
         item = utils.find_item(list["id"], self.db.settings["lists"])
         self.db.settings["lists"].append(list)
     except TwythonError as e:
         output.speak("error %s: %s" % (e.status_code, e.msg))
Exemple #10
0
 def remove_friend(self, data):
  if config.main["other_buffers"]["show_friends"] == True:
   item = utils.find_item(data["target"]["id"], self.db.settings["friends"])
   if item > 0:
    deleted_event = event.event(event.EVT_DELETED, 1)
    deleted_event.SetItem(item)
    self.friends.pop(item)
    self.db.settings["friends"].pop(item)
    wx.PostEvent(self.parent.search_buffer("people", "friends"), deleted_event)
Exemple #11
0
 def subscribe(self, *args, **kwargs):
  if self.dialog.lista.get_count() == 0: return
  list_id = self.lists[self.dialog.get_item()]["id"]
  try:
   list = self.session.twitter.twitter.subscribe_to_list(list_id=list_id)
   item = utils.find_item(list["id"], self.session.db["lists"])
   self.session.db["lists"].append(list)
  except TwythonError as e:
   output.speak("error %s: %s" % (e.status_code, e.msg))
Exemple #12
0
 def remove_fav(self, data):
     if self.db.settings["user_name"] == data["source"]["screen_name"]:
         self.db.settings.update()
         item = utils.find_item(data["target_object"]["id"],
                                self.db.settings["favs"])
         self.db.settings["favs"].pop(item)
         deleted_event = event.event(event.EVT_DELETED, 1)
         deleted_event.SetItem(item)
         wx.PostEvent(self.parent.search_buffer("buffer", "favs"),
                      deleted_event)
Exemple #13
0
 def unblock(self, data):
     if config.main["other_buffers"]["show_blocks"] == True:
         item = utils.find_item(data["target"]["id"],
                                self.db.settings["blocks"])
         self.db.settings["blocks"].pop(item)
         deleted_event = event.event(event.EVT_DELETED, 1)
         deleted_event.SetItem(item)
         wx.PostEvent(self.parent.search_buffer("people", "blocks"),
                      deleted_event)
         wx.PostEvent(self.parent, event.ResultEvent())
Exemple #14
0
 def remove_friend(self, data):
     if config.main["other_buffers"]["show_friends"] == True:
         item = utils.find_item(data["target"]["id"],
                                self.db.settings["friends"])
         if item > 0:
             deleted_event = event.event(event.EVT_DELETED, 1)
             deleted_event.SetItem(item)
             self.friends.pop(item)
             self.db.settings["friends"].pop(item)
             wx.PostEvent(self.parent.search_buffer("people", "friends"),
                          deleted_event)
 def order_buffer(self, name, data):

  """ Put the new items in the local database.
  name str: The name for the buffer stored in the dictionary.
  data list: A list with tweets.
  returns the number of items that have been added in this execution"""

  num = 0
  if self.db.has_key(name) == False:
   self.db[name] = []
  for i in data:
   if utils.find_item(i["id"], self.db[name]) == None and     utils.is_allowed(i, self.settings["twitter"]["ignored_clients"]) == True:
    if self.settings["general"]["reverse_timelines"] == False: self.db[name].append(i)
    else: self.db[name].insert(0, i)
    num = num+1
  return num
Exemple #16
0
 def put_data(self, place, data):
  if self.session.db.has_key(place):
   if utils.find_item(data["id"], self.session.db[place]) != None:
    log.error("duplicated tweet. Ignoring it...")
    return False
#   try:
   data_ = self.session.check_quoted_status(data)
   data_ = self.session.check_long_tweet(data_)
   data = data_
#   except:
#    pass
   if self.session.settings["general"]["reverse_timelines"] == False:
    self.session.db[place].append(data)
   else:
    self.session.db[place].insert(0, data)
  utils.is_audio(data)
  return True
Exemple #17
0
 def order_cursored_buffer(self, name, data):

  """ Put the new items on the local database. Useful for cursored buffers (followers, friends, users of a list and searches)
  name str: The name for the buffer stored in the dictionary.
  data list: A list with items and some information about cursors.
  returns the number of items that have been added in this execution"""

  num = 0
  if self.db.has_key(name) == False:
   self.db[name] = {}
   self.db[name]["items"] = []
#  if len(self.db[name]["items"]) > 0:
  for i in data:
   if utils.find_item(i["id"], self.db[name]["items"]) == None:
    if self.settings["general"]["reverse_timelines"] == False: self.db[name]["items"].append(i)
    else: self.db[name]["items"].insert(0, i)
    num = num+1
  return num
 def order_cursored_buffer(self, name, data):

  """ Put the new items on the local database. Useful for cursored buffers (followers, friends, users of a list and searches)
  name str: The name for the buffer stored in the dictionary.
  data list: A list with items and some information about cursors.
  returns the number of items that have been added in this execution"""

  num = 0
  if self.db.has_key(name) == False:
   self.db[name] = {}
   self.db[name]["items"] = []
#  if len(self.db[name]["items"]) > 0:
  for i in data:
   if utils.find_item(i["id"], self.db[name]["items"]) == None:
    if self.settings["general"]["reverse_timelines"] == False: self.db[name]["items"].append(i)
    else: self.db[name]["items"].insert(0, i)
    num = num+1
  return num
Exemple #19
0
 def order_buffer(self, name, data):

  """ Put the new items in the local database.
  name str: The name for the buffer stored in the dictionary.
  data list: A list with tweets.
  returns the number of items that have been added in this execution"""

  num = 0
  if self.db.has_key(name) == False:
   self.db[name] = []
  for i in data:
   if utils.find_item(i["id"], self.db[name]) == None and     utils.is_allowed(i, self.settings["twitter"]["ignored_clients"]) == True:
    try: i = self.check_quoted_status(i)
    except: pass
    i = self.check_long_tweet(i)
    if self.settings["general"]["reverse_timelines"] == False: self.db[name].append(i)
    else: self.db[name].insert(0, i)
    num = num+1
  return num
Exemple #20
0
 def onok(self, ev):
  if self.follow.GetValue() == True:
   try:
    self.parent.twitter.twitter.create_friendship(screen_name=self.cb.GetValue())
    self.Destroy()
   except TwythonError as err:
    output.speak("Error %s: %s" % (err.error_code, err.msg), True)
  elif self.unfollow.GetValue() == True:
   try:
    id = self.parent.twitter.twitter.destroy_friendship(screen_name=self.cb.GetValue())
    self.Destroy()
   except TwythonError as err:
    output.speak("Error %s: %s" % (err.error_code, err.msg), True)
  elif self.mute.GetValue() == True:
   try:
    id = self.parent.twitter.twitter.create_mute(screen_name=self.cb.GetValue())
    if config.main["other_buffers"]["show_muted_users"] == True:
     tweet_event = event.event(event.EVT_OBJECT, 1)
     tweet_event.SetItem(id)
     wx.PostEvent(self.parent.parent.nb.GetPage(self.parent.db.settings["buffers"].index("muteds")), tweet_event)
    self.parent.db.settings["muted_users"].append(id["id"])
    self.Destroy()
    output.speak(_(u"You've muted to %s") % (id["screen_name"]))
   except TwythonError as err:
    output.speak("Error %s: %s" % (err.error_code, err.msg), True)
  elif self.unmute.GetValue() == True:
   try:
    id = self.parent.twitter.twitter.destroy_mute(screen_name=self.cb.GetValue())
    if config.main["other_buffers"]["show_muted_users"] == True:
     item = utils.find_item(id, self.parent.db.settings["muteds"])
     if item > 0:
      deleted_event = event.event(event.EVT_DELETED, 1)
      deleted_event.SetItem(item)
      wx.PostEvent(self.parent.parent.nb.GetPage(self.parent.db.settings["buffers"].index("muteds")), deleted_event)
    if id["id"] in self.parent.db.settings["muted_users"]: self.parent.db.settings["muted_users"].remove(id["id"])
    self.Destroy()
    output.speak(_(u"You've unmuted to %s") % (id["screen_name"]))
   except TwythonError as err:
    output.speak("Error %s: %s" % (err.error_code, err.msg), True)
  elif self.reportSpam.GetValue() == True:
   try:
    self.parent.twitter.twitter.report_spam(screen_name=self.cb.GetValue())
    self.Destroy()
   except TwythonError as err:
    output.speak("Error %s: %s" % (err.error_code, err.msg), True)
  elif self.block.GetValue() == True:
   try:
    self.parent.twitter.twitter.create_block(screen_name=self.cb.GetValue())
    self.Destroy()
   except TwythonError as err:
    output.speak("Error %s: %s" % (err.error_code, err.msg), True)
  elif self.unblock.GetValue() == True:
   try:
    self.parent.twitter.twitter.destroy_block(screen_name=self.cb.GetValue())
    self.Destroy()
   except TwythonError as err:
    output.speak("Error %s: %s" % (err.error_code, err.msg), True)
  elif self.ignore_client.GetValue() == True:
   tweet = self.parent.get_tweet()
   if tweet.has_key("sender"):
    output.speak(_(u"You can't ignore direct messages"))
    return
   else:
    client = re.sub(r"(?s)<.*?>", "", tweet["source"])
   if client not in config.main["twitter"]["ignored_clients"]:
    config.main["twitter"]["ignored_clients"].append(client)
   self.Destroy()
Exemple #21
0
 def remove_friend(self, data):
  if "friends" in self.session.settings["general"]["buffer_order"]:
   item = utils.find_item(data["target"]["id"], self.session.db["friends"]["items"])
   if item > 0:
    self.friends.pop(item)
    pub.sendMessage("unfollowing", item=item, user=self.get_user())
Exemple #22
0
 def remove_fav(self, data):
  if self.session.db["user_name"] == data["source"]["screen_name"]:
   item = utils.find_item(data["target_object"]["id"], self.session.db["favourites"])
   self.session.db["favourites"].pop(item)
   pub.sendMessage("unfavourite", item=item, user=self.get_user())
Exemple #23
0
 def on_success(self, data):
  try:
   if "direct_message" in data:
    self.process_dm(data)
   elif "friends" in data:
    self.friends = data["friends"]
    pub.sendMessage("friendsReceived")
   elif "text" in data and utils.is_allowed(data) == True:
    if data["user"]["id"] in self.muted_users: return
    self.check_mentions(data)
    self.check_send(data)
    if data["user"]["id"] in self.friends or data["user"]["screen_name"] == self.db.settings["user_name"]:
     tweet_event = event.event(event.EVT_OBJECT, 1)
     tweet_event.SetItem(data)
     wx.PostEvent(self.parent.search_buffer("buffer", "home_timeline"), tweet_event)
   elif data.has_key("event"):
    if "favorite" == data["event"] and config.main["other_buffers"]["show_favourites"] == True:
     self.check_favs(data)
    elif "unfavorite" == data["event"] and config.main["other_buffers"]["show_favourites"] == True:
     self.remove_fav(data)
    elif "follow" == data["event"]:
     self.check_follower(data)
    elif "unfollow" == data["event"] and config.main["other_buffers"]["show_followers"] == True:
     self.remove_friend(data)
    elif "block" == data["event"]:
     self.block_user(data)
    elif "unblock" in data["event"]:
     self.unblock(data)
    elif "list_created" == data["event"]:
     item = utils.find_item(data["target_object"]["id"], self.db.settings["lists"])
     if item != None: self.db.settings["lists"].append(data["target_object"])
    elif "list_destroyed" == data["event"]:
     item = utils.find_item(data["target_object"]["id"], self.db.settings["lists"])
     if item != None: self.db.settings["lists"].pop(item)
     self.parent.remove_list(data["target_object"]["id"])
    elif "list_member_added" == data["event"] and data["source"]["screen_name"] == self.db.settings["user_name"]:
     if len(config.main["other_buffers"]["lists"]) > 0:
      for i in range(0, self.parent.nb.GetPageCount()):
       if self.parent.nb.GetPage(i).type == "list":
        if str(data["target_object"]["id"]) == str(self.parent.nb.GetPage(i).argumento):
         self.parent.nb.GetPage(i).users.append(data["target"]["id"])
         wx.PostEvent(self.parent, event.ResultEvent())
    elif "list_member_added" == data["event"] and data["target"]["screen_name"] == self.db.settings["user_name"]:
     self.db.settings["lists"].append(data["target_object"])
    elif "list_member_removed" == data["event"] and data["source"]["screen_name"] == self.db.settings["user_name"]:
     if len(config.main["other_buffers"]["lists"]) > 0:
      for i in range(0, self.parent.nb.GetPageCount()):
       if self.parent.nb.GetPage(i).type == "list":
        if str(data["target_object"]["id"]) == str(self.parent.nb.GetPage(i).argumento):
         self.parent.nb.GetPage(i).users.remove(data["target"]["id"])
         wx.PostEvent(self.parent, event.ResultEvent())
    elif "list_member_removed" == data["event"] and data["target"] == self.db.settings["user_name"]:
     id = data["target_object"]["id"]
     list = utils.find_item(id, self.db.settings["lists"])
     if list != None: self.db.settings["lists"].pop(list)
     self.parent.remove_list(data["target_object"]["id"])
    if config.main["other_buffers"]["show_events"] == True:
     evento = compose_event(data, self.db.settings["user_name"])
     tweet_event = event.event(event.EVT_OBJECT, 1)
     tweet_event.SetItem(evento)
     text = evento[1]
     tweet_event.SetAnnounce(text)
#     deleted_event = event.event(event.EVT_DELETED, 1)
#     deleted_event.SetItem(evento)
     wx.PostEvent(self.parent.search_buffer("event", "events"), tweet_event)
#     self.sound.play("new_event.ogg")
  except:
   pass
 def remove_fav(self, data):
  if self.session.db["user_name"] == data["source"]["screen_name"]:
   item = utils.find_item(data["target_object"]["id"], self.session.db["favourites"])
   self.session.db["favourites"].pop(item)
   pub.sendMessage("unfavourite", item=item, user=self.get_user())
 def unblock(self, data):
  if "blocks" in self.session.settings["general"]["buffer_order"] == True:
   item = utils.find_item(data["target"]["id"], self.session.db["blocked"]["items"])
   self.session.db["blocked"]["items"].pop(item)
   pub.sendMessage("unblocked-user", item=item, user=self.get_user())
 def remove_friend(self, data):
  if "friends" in self.session.settings["general"]["buffer_order"]:
   item = utils.find_item(data["target"]["id"], self.session.db["friends"]["items"])
   if item > 0:
    self.friends.pop(item)
    pub.sendMessage("unfollowing", item=item, user=self.get_user())
Exemple #27
0
 def onok(self, ev):
     if self.follow.GetValue() == True:
         try:
             self.parent.twitter.twitter.create_friendship(
                 screen_name=self.cb.GetValue())
             self.Destroy()
         except TwythonError as err:
             output.speak("Error %s: %s" % (err.error_code, err.msg), True)
     elif self.unfollow.GetValue() == True:
         try:
             id = self.parent.twitter.twitter.destroy_friendship(
                 screen_name=self.cb.GetValue())
             self.Destroy()
         except TwythonError as err:
             output.speak("Error %s: %s" % (err.error_code, err.msg), True)
     elif self.mute.GetValue() == True:
         try:
             id = self.parent.twitter.twitter.create_mute(
                 screen_name=self.cb.GetValue())
             if config.main["other_buffers"]["show_muted_users"] == True:
                 tweet_event = event.event(event.EVT_OBJECT, 1)
                 tweet_event.SetItem(id)
                 wx.PostEvent(
                     self.parent.parent.nb.GetPage(
                         self.parent.db.settings["buffers"].index(
                             "muteds")), tweet_event)
             self.parent.db.settings["muted_users"].append(id["id"])
             self.Destroy()
             output.speak(_(u"You've muted to %s") % (id["screen_name"]))
         except TwythonError as err:
             output.speak("Error %s: %s" % (err.error_code, err.msg), True)
     elif self.unmute.GetValue() == True:
         try:
             id = self.parent.twitter.twitter.destroy_mute(
                 screen_name=self.cb.GetValue())
             if config.main["other_buffers"]["show_muted_users"] == True:
                 item = utils.find_item(id,
                                        self.parent.db.settings["muteds"])
                 if item > 0:
                     deleted_event = event.event(event.EVT_DELETED, 1)
                     deleted_event.SetItem(item)
                     wx.PostEvent(
                         self.parent.parent.nb.GetPage(
                             self.parent.db.settings["buffers"].index(
                                 "muteds")), deleted_event)
             if id["id"] in self.parent.db.settings["muted_users"]:
                 self.parent.db.settings["muted_users"].remove(id["id"])
             self.Destroy()
             output.speak(_(u"You've unmuted to %s") % (id["screen_name"]))
         except TwythonError as err:
             output.speak("Error %s: %s" % (err.error_code, err.msg), True)
     elif self.reportSpam.GetValue() == True:
         try:
             self.parent.twitter.twitter.report_spam(
                 screen_name=self.cb.GetValue())
             self.Destroy()
         except TwythonError as err:
             output.speak("Error %s: %s" % (err.error_code, err.msg), True)
     elif self.block.GetValue() == True:
         try:
             self.parent.twitter.twitter.create_block(
                 screen_name=self.cb.GetValue())
             self.Destroy()
         except TwythonError as err:
             output.speak("Error %s: %s" % (err.error_code, err.msg), True)
     elif self.unblock.GetValue() == True:
         try:
             self.parent.twitter.twitter.destroy_block(
                 screen_name=self.cb.GetValue())
             self.Destroy()
         except TwythonError as err:
             output.speak("Error %s: %s" % (err.error_code, err.msg), True)
     elif self.ignore_client.GetValue() == True:
         tweet = self.parent.get_tweet()
         if tweet.has_key("sender"):
             output.speak(_(u"You can't ignore direct messages"))
             return
         else:
             client = re.sub(r"(?s)<.*?>", "", tweet["source"])
         if client not in config.main["twitter"]["ignored_clients"]:
             config.main["twitter"]["ignored_clients"].append(client)
         self.Destroy()
Exemple #28
0
 def unblock(self, data):
  if "blocks" in self.session.settings["general"]["buffer_order"] == True:
   item = utils.find_item(data["target"]["id"], self.session.db["blocked"]["items"])
   self.session.db["blocked"]["items"].pop(item)
   pub.sendMessage("unblocked-user", item=item, user=self.get_user())
Exemple #29
0
    def on_success(self, data):
        try:
            if "direct_message" in data:
                self.process_dm(data)
            elif "friends" in data:
                self.friends = data["friends"]
                pub.sendMessage("friendsReceived")
            elif "text" in data and utils.is_allowed(data) == True:
                if data["user"]["id"] in self.muted_users: return
                self.check_mentions(data)
                self.check_send(data)
                if data["user"]["id"] in self.friends or data["user"][
                        "screen_name"] == self.db.settings["user_name"]:
                    tweet_event = event.event(event.EVT_OBJECT, 1)
                    tweet_event.SetItem(data)
                    wx.PostEvent(
                        self.parent.search_buffer("buffer", "home_timeline"),
                        tweet_event)
            elif data.has_key("event"):
                if "favorite" == data["event"] and config.main[
                        "other_buffers"]["show_favourites"] == True:
                    self.check_favs(data)
                elif "unfavorite" == data["event"] and config.main[
                        "other_buffers"]["show_favourites"] == True:
                    self.remove_fav(data)
                elif "follow" == data["event"]:
                    self.check_follower(data)
                elif "unfollow" == data["event"] and config.main[
                        "other_buffers"]["show_followers"] == True:
                    self.remove_friend(data)
                elif "block" == data["event"]:
                    self.block_user(data)
                elif "unblock" in data["event"]:
                    self.unblock(data)
                elif "list_created" == data["event"]:
                    item = utils.find_item(data["target_object"]["id"],
                                           self.db.settings["lists"])
                    if item != None:
                        self.db.settings["lists"].append(data["target_object"])
                elif "list_destroyed" == data["event"]:
                    item = utils.find_item(data["target_object"]["id"],
                                           self.db.settings["lists"])
                    if item != None: self.db.settings["lists"].pop(item)
                    self.parent.remove_list(data["target_object"]["id"])
                elif "list_member_added" == data["event"] and data["source"][
                        "screen_name"] == self.db.settings["user_name"]:
                    if len(config.main["other_buffers"]["lists"]) > 0:
                        for i in range(0, self.parent.nb.GetPageCount()):
                            if self.parent.nb.GetPage(i).type == "list":
                                if str(data["target_object"]["id"]) == str(
                                        self.parent.nb.GetPage(i).argumento):
                                    self.parent.nb.GetPage(i).users.append(
                                        data["target"]["id"])
                                    wx.PostEvent(self.parent,
                                                 event.ResultEvent())
                elif "list_member_added" == data["event"] and data["target"][
                        "screen_name"] == self.db.settings["user_name"]:
                    self.db.settings["lists"].append(data["target_object"])
                elif "list_member_removed" == data["event"] and data["source"][
                        "screen_name"] == self.db.settings["user_name"]:
                    if len(config.main["other_buffers"]["lists"]) > 0:
                        for i in range(0, self.parent.nb.GetPageCount()):
                            if self.parent.nb.GetPage(i).type == "list":
                                if str(data["target_object"]["id"]) == str(
                                        self.parent.nb.GetPage(i).argumento):
                                    self.parent.nb.GetPage(i).users.remove(
                                        data["target"]["id"])
                                    wx.PostEvent(self.parent,
                                                 event.ResultEvent())
                elif "list_member_removed" == data["event"] and data[
                        "target"] == self.db.settings["user_name"]:
                    id = data["target_object"]["id"]
                    list = utils.find_item(id, self.db.settings["lists"])
                    if list != None: self.db.settings["lists"].pop(list)
                    self.parent.remove_list(data["target_object"]["id"])
                if config.main["other_buffers"]["show_events"] == True:
                    evento = compose_event(data, self.db.settings["user_name"])
                    tweet_event = event.event(event.EVT_OBJECT, 1)
                    tweet_event.SetItem(evento)
                    text = evento[1]
                    tweet_event.SetAnnounce(text)
                    #     deleted_event = event.event(event.EVT_DELETED, 1)
                    #     deleted_event.SetItem(evento)
                    wx.PostEvent(self.parent.search_buffer("event", "events"),
                                 tweet_event)


#     self.sound.play("new_event.ogg")
        except:
            pass