Segue sugestão do listener que funciona com o Twitter API v2.
import socket
import tweepy
HOST = 'localhost'
PORT = 9009
s = socket.socket()
s.bind((HOST, PORT))
print(f'Aguardando conexão na porta: {PORT}')
s.listen(5)
connection, address = s.accept()
print(f'Recebendo solicitação de {address}')
consumer_key = "sua_consumer_key"
consumer_secret = "seu_consumer_secret"
access_token = "seu_access_token"
access_token_secret = "seu_access_token_secret"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
keyword = 'esporte'
try:
tweets = api.search_tweets(q=keyword, count=20)
for tweet in tweets:
print(tweet.text)
print('=' * 50)
connection.send(tweet.text.encode('latin1', 'ignore'))
finally:
connection.close()
s.close()