Hide replies to users the current account doesn't follow in streaming API

This commit is contained in:
Manuel Cortez 2021-07-03 11:52:21 -05:00
parent 84cbf5c497
commit c926355048

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" Streaming support for TWBlue. """ """ Streaming support for TWBlue. """
import time import time
import sys
import six import six
import requests import requests
import urllib3 import urllib3
@ -30,9 +31,12 @@ class StreamListener(tweepy.StreamListener):
def on_status(self, status): def on_status(self, status):
""" Checks data arriving as a tweet. """ """ Checks data arriving as a tweet. """
# Hide replies to users not followed by current account.
if status.in_reply_to_user_id_str != None and status.in_reply_to_user_id_str not in self.users:
return
if status.user.id_str in self.users: if status.user.id_str in self.users:
pub.sendMessage("newStatus", status=status, user=self.user) pub.sendMessage("newStatus", status=status, user=self.user)
# print(status.text)
class Stream(tweepy.Stream): class Stream(tweepy.Stream):