Implemented tweet searches and conversation fupport

This commit is contained in:
Manuel Cortez 2021-01-14 09:18:57 -06:00
parent 85fe94ec0c
commit f546543e9b
2 changed files with 10 additions and 10 deletions

View File

@ -1248,23 +1248,23 @@ class conversationBufferController(searchBufferController):
self.statuses = [] self.statuses = []
self.ids = [] self.ids = []
self.statuses.append(self.tweet) self.statuses.append(self.tweet)
self.ids.append(self.tweet["id"]) self.ids.append(self.tweet.id)
tweet = self.tweet tweet = self.tweet
while tweet["in_reply_to_status_id"] != None: while tweet.in_reply_to_status_id != None:
try: try:
tweet = self.session.twitter.show_status(id=tweet["in_reply_to_status_id"], tweet_mode="extended") tweet = self.session.twitter.get_status(id=tweet.in_reply_to_status_id, tweet_mode="extended")
except TweepError as err: except TweepError as err:
break break
self.statuses.insert(0, tweet) self.statuses.insert(0, tweet)
self.ids.append(tweet["id"]) self.ids.append(tweet.id)
if tweet["in_reply_to_status_id"] == None: if tweet.in_reply_to_status_id == None:
self.kwargs["since_id"] = tweet["id"] self.kwargs["since_id"] = tweet.id
self.ids.append(tweet["id"]) self.ids.append(tweet.id)
val2 = self.session.search(self.name, tweet_mode="extended", *self.args, **self.kwargs) val2 = self.session.search(self.name, tweet_mode="extended", *self.args, **self.kwargs)
for i in val2: for i in val2:
if i["in_reply_to_status_id"] in self.ids: if i.in_reply_to_status_id in self.ids:
self.statuses.append(i) self.statuses.append(i)
self.ids.append(i["id"]) self.ids.append(i.id)
tweet = i tweet = i
number_of_items = self.session.order_buffer(self.name, self.statuses) number_of_items = self.session.order_buffer(self.name, self.statuses)
log.debug("Number of items retrieved: %d" % (number_of_items,)) log.debug("Number of items retrieved: %d" % (number_of_items,))

View File

@ -924,7 +924,7 @@ class Controller(object):
def open_conversation(self, *args, **kwargs): def open_conversation(self, *args, **kwargs):
buffer = self.get_current_buffer() buffer = self.get_current_buffer()
id = buffer.get_right_tweet().id_str id = buffer.get_right_tweet().id_str
user = buffer.get_right_tweet().user["screen_name"] user = buffer.get_right_tweet().user.screen_name
search = twitterBuffers.conversationBufferController(self.view.nb, "search", "%s-searchterm" % (id,), buffer.session, buffer.session.db["user_name"], bufferType="searchPanel", sound="search_updated.ogg", since_id=id, q="@{0}".format(user,)) search = twitterBuffers.conversationBufferController(self.view.nb, "search", "%s-searchterm" % (id,), buffer.session, buffer.session.db["user_name"], bufferType="searchPanel", sound="search_updated.ogg", since_id=id, q="@{0}".format(user,))
search.tweet = buffer.get_right_tweet() search.tweet = buffer.get_right_tweet()
search.start_stream(start=True) search.start_stream(start=True)