From b7bc53bb925f66bc0a54cce00138d5f37ae5a9cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Mon, 6 Jul 2015 09:45:56 -0500 Subject: [PATCH] Quoted tweets are saved in mentions, added quoted tweet event handler --- src/twitter/buffers/stream.py | 9 ++++++++- src/twitter/compose.py | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/twitter/buffers/stream.py b/src/twitter/buffers/stream.py index dffd7525..6345cf51 100644 --- a/src/twitter/buffers/stream.py +++ b/src/twitter/buffers/stream.py @@ -66,7 +66,11 @@ class streamer(TwythonStreamer): if "@%s" % (self.session.db["user_name"]) in data["text"]: self.put_data("mentions", data) pub.sendMessage("mention", data=data, user=self.get_user()) - + + def set_quoted_tweet(self, data): + self.put_data("mentions", data) + pub.sendMessage("mention", data=data, user=self.get_user()) + def process_dm(self, data): if self.session.db["user_name"] == data["direct_message"]["sender"]["screen_name"]: self.put_data("sent_direct_messages", data["direct_message"]) @@ -148,6 +152,9 @@ class streamer(TwythonStreamer): 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") diff --git a/src/twitter/compose.py b/src/twitter/compose.py index ded9fce9..50e96572 100644 --- a/src/twitter/compose.py +++ b/src/twitter/compose.py @@ -128,6 +128,8 @@ def compose_event(data, username): elif data["event"] == "retweeted_retweet": if data["source"]["screen_name"] == username: event = _(u"You have retweeted a retweet from %s(@%s): %s") % (data["target"]["name"], data["target"]["screen_name"], data["target_object"]["retweeted_status"]["text"]) else: event = _(u"%s(@%s) has retweeted your retweet: %s") % (data["source"]["name"], data["source"]["screen_name"], data["target_object"]["retweeted_status"]["text"]) + elif data["event"] == "quoted_tweet": + event = _(u"@{0} quoted your tweet: {1}").format(data["source"]["screen_name"], data["target_object"]["text"]) else: event = _("Unknown") log.error("event: %s\n target: %s\n source: %s\n target_object: %s" % (data["event"], data["target"], data["source"], data["target_object"]))