def check_tls(self, data): for i in config.main["other_buffers"]["timelines"]: if data["user"]["screen_name"] == i: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data) announce = _(u"One tweet from %s") % (data["user"]["name"]) tweet_event.SetAnnounce(announce) wx.PostEvent( self.parent.search_buffer( buffer_type="timeline", name_buffer=data["user"]["screen_name"]), tweet_event) for i in range(0, self.parent.nb.GetPageCount()): if self.parent.nb.GetPage(i).type == "list": try: self.parent.nb.GetPage(i).users.index(data["user"]["id"]) tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data) announce = _(u"One tweet from %s in the list %s") % ( data["user"]["name"], self.parent.nb.GetPage(i).name_buffer[:-5]) tweet_event.SetAnnounce(announce) usr = data["in_reply_to_user_id"] if (usr != None and usr in self.friends ) or data.has_key("retweeted_status"): wx.PostEvent(self.parent.nb.GetPage(i), tweet_event) elif usr == None: wx.PostEvent(self.parent.nb.GetPage(i), tweet_event) except ValueError: pass
def check_follower(self, data): if data["target"]["screen_name"] == self.db.settings["user_name"] and config.main["other_buffers"]["show_followers"] == True: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data["source"]) wx.PostEvent(self.parent.search_buffer("people", "followers"), tweet_event) elif data["source"]["screen_name"] == self.db.settings["user_name"]: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data["target"]) wx.PostEvent(self.parent.search_buffer("people", "friends"), tweet_event)
def process_dm(self, data): if self.db.settings["user_name"] == data["direct_message"]["sender"]["screen_name"]: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data["direct_message"]) wx.PostEvent(self.parent.search_buffer("buffer", "sent"), tweet_event) if self.db.settings["user_name"] != data["direct_message"]["sender"]["screen_name"]: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data["direct_message"]) text = _(u"One direct message") tweet_event.SetAnnounce(text) wx.PostEvent(self.parent.search_buffer("direct_message", "direct_messages"), tweet_event)
def check_follower(self, data): if data["target"]["screen_name"] == self.db.settings[ "user_name"] and config.main["other_buffers"][ "show_followers"] == True: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data["source"]) wx.PostEvent(self.parent.search_buffer("people", "followers"), tweet_event) elif data["source"]["screen_name"] == self.db.settings["user_name"]: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data["target"]) wx.PostEvent(self.parent.search_buffer("people", "friends"), tweet_event)
def check_mentions(self, data): if "@%s" % (self.db.settings["user_name"].lower()) in data["text"].lower(): tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data) text = _(u"One mention from %s ") % (data["user"]["name"]) tweet_event.SetAnnounce(text) wx.PostEvent(self.parent.search_buffer("buffer", "mentions"), tweet_event)
def process_dm(self, data): if self.db.settings["user_name"] == data["direct_message"]["sender"][ "screen_name"]: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data["direct_message"]) wx.PostEvent(self.parent.search_buffer("buffer", "sent"), tweet_event) if self.db.settings["user_name"] != data["direct_message"]["sender"][ "screen_name"]: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data["direct_message"]) text = _(u"One direct message") tweet_event.SetAnnounce(text) wx.PostEvent( self.parent.search_buffer("direct_message", "direct_messages"), tweet_event)
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)
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())
def block_user(self, data): id = data["target"]["id"] if id in self.friends: self.friends.remove(id) if config.main["other_buffers"]["show_blocks"] == True: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data["target"]) wx.PostEvent(self.parent.search_buffer("people", "blocks"), tweet_event)
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 check_mentions(self, data): if "@%s" % ( self.db.settings["user_name"].lower()) in data["text"].lower(): tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data) text = _(u"One mention from %s ") % (data["user"]["name"]) tweet_event.SetAnnounce(text) wx.PostEvent(self.parent.search_buffer("buffer", "mentions"), tweet_event)
def check_tls(self, data): for i in config.main["other_buffers"]["timelines"]: if data["user"]["screen_name"] == i: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data) announce = _(u"One tweet from %s") % (data["user"]["name"]) tweet_event.SetAnnounce(announce) wx.PostEvent(self.parent.search_buffer(buffer_type="timeline", name_buffer=data["user"]["screen_name"]), tweet_event) for i in range(0, self.parent.nb.GetPageCount()): if self.parent.nb.GetPage(i).type == "list": try: self.parent.nb.GetPage(i).users.index(data["user"]["id"]) tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data) announce = _(u"One tweet from %s in the list %s") % (data["user"]["name"], self.parent.nb.GetPage(i).name_buffer[:-5]) tweet_event.SetAnnounce(announce) usr = data["in_reply_to_user_id"] if (usr != None and usr in self.friends) or data.has_key("retweeted_status"): wx.PostEvent(self.parent.nb.GetPage(i), tweet_event) elif usr == None: wx.PostEvent(self.parent.nb.GetPage(i), tweet_event) except ValueError: pass
def process(self, offset): progress = {} self.current = offset progress["total"] = self.file_size progress["current"] = self.current progress["percent"] = int((float(progress["current"]) / progress["total"]) * 100) self.transfer_rate = progress["current"] / self.elapsed_time() progress["speed"] = '%s/s' % convert_bytes(self.transfer_rate) if self.transfer_rate: progress["eta"] = (progress["total"] - progress["current"]) / self.transfer_rate else: progress["eta"] = 0 info = event.event(event.EVT_OBJECT, 1) info.SetItem(progress) wx.PostEvent(self.wxDialog, info)
def progress_callback(self, down_total, down_current, up_total, up_current): progress = {} progress["total"] = up_total progress["current"] = up_current # else: # print "Killed function" # return if progress["current"] == 0: progress["percent"] = 0 self.transfer_rate = 0 else: progress["percent"] = int((float(progress["current"]) / progress["total"]) * 100) self.transfer_rate = progress["current"] / self.elapsed_time() progress["speed"] = '%s/s' % convert_bytes(self.transfer_rate) if self.transfer_rate: progress["eta"] = (progress["total"] - progress["current"]) / self.transfer_rate else: progress["eta"] = 0 info = event.event(event.EVT_OBJECT, 1) info.SetItem(progress) wx.PostEvent(self.wxDialog, info)
def progress_callback(self, down_total, down_current, up_total, up_current): progress = {} progress["total"] = up_total progress["current"] = up_current # else: # print "Killed function" # return if progress["current"] == 0: progress["percent"] = 0 self.transfer_rate = 0 else: progress["percent"] = int( (float(progress["current"]) / progress["total"]) * 100) self.transfer_rate = progress["current"] / self.elapsed_time() progress["speed"] = '%s/s' % convert_bytes(self.transfer_rate) if self.transfer_rate: progress["eta"] = (progress["total"] - progress["current"]) / self.transfer_rate else: progress["eta"] = 0 info = event.event(event.EVT_OBJECT, 1) info.SetItem(progress) wx.PostEvent(self.wxDialog, info)
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()
def check_send(self, data): if self.db.settings["user_name"] == data["user"]["screen_name"]: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data) wx.PostEvent(self.parent.search_buffer("buffer", "sent"), tweet_event)
def check_favs(self, data): if data["source"]["screen_name"] == self.db.settings["user_name"]: tweet_event = event.event(event.EVT_OBJECT, 1) tweet_event.SetItem(data["target_object"]) wx.PostEvent(self.parent.search_buffer("buffer", "favs"), tweet_event)
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 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 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()