我知道这可能是一个简单的修复,但我遇到了一个问题,即bot发布消息的方法在自定义客户端类中,而接收tweet的方法在MSL类中。我非常肯定,这是一个简单的解决办法,我只是哑巴,但我有麻烦的机器人张贴推特
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token,access_token_secret)
api = tweepy.API(auth)
load_dotenv('botAttributes.env')
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
client = discord.Client()
class MSL(tweepy.StreamListener):
def on_status(self, status):
print(status.text)
def on_error(self, status_code):
if status_code == 420:
return False
else:
print(status_code)
class CustomClient(discord.Client):
async def on_ready(self):
print(f'{self.user} has connected to Discord!')
print("the program should start showing tweets")
StreamListener = MSL()
MS = tweepy.Stream(auth = api.auth, listener = StreamListener)
MS.filter(track=['#python'],is_async=True)
client = CustomClient()
client.run(TOKEN)
目前没有回答
相关问题 更多 >
编程相关推荐