Discord.py@client.event twitter会自动发布到特定频道

2024-04-27 22:21:51 发布

您现在位置:Python中文网/ 问答频道 /正文

因此,我有一个discord机器人,它使用tweepy从twitter时间线上发布内容,自动发布似乎还可以,但每次打开该机器人时,它也会发送旧的时间线。我仍然对如何让机器人只从推特时间线上发送新推特感到困惑。以下是我的代码:

timeline = api.home_timeline()

@client.event
async def on_message(message):
    for tweet in timeline:
        channel = client.get_channel(CHANNELID)
        em1 = discord.Embed(title = f'New Tweet From {tweet.user.name}.', description = f'{tweet.text}.')
        await channel.send(embed = em1)

Tags: 代码clientapi内容messagehome时间channel
1条回答
网友
1楼 · 发布于 2024-04-27 22:21:51

将你已经发送的推文id存储在某种数据库中,并用它过滤掉你还没有发送的推文。我也有点困惑为什么你会在on_message中这样做?这对我来说没什么意义

相关问题 更多 >