From 2b2d4741ee1d604c72126715b07b8ce3ae8f4155 Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Sun, 18 Mar 2018 00:08:14 +0100 Subject: [PATCH] - deal with non-existent tweet shortcodes - parse tweet detail parameters properly --- screenless/bureau/publicrelations/publicrelations.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/screenless/bureau/publicrelations/publicrelations.py b/screenless/bureau/publicrelations/publicrelations.py index 75e3501..92992d1 100644 --- a/screenless/bureau/publicrelations/publicrelations.py +++ b/screenless/bureau/publicrelations/publicrelations.py @@ -57,7 +57,10 @@ class PublicRelations(Bureau): """ with self.dbenv.begin(db=self.tweetdb) as txn: tweetid = txn.get(tweet_hash.encode()) - return int(tweetid) + if tweetid: + return int(tweetid) + else: + return tweetid def short_tweet_id(self, tweet_id): """ @@ -151,8 +154,8 @@ class PublicRelations(Bureau): """ Print detailed tweet info and commands for reply, like, retweet, etc. """ - self.log.debug("got data " + str(data)) - tweet_id = self.get_tweet_id(data) + shortcode, _ = data.split(".") + tweet_id = self.get_tweet_id(shortcode) self.log.debug("tweet details for id:" + tweet_id) tweet = self.t.t.statuses.show(id=tweet_id) prn = printer.Usb(0x416, 0x5011, in_ep=0x81, out_ep=0x03)