Python Discord机器人无法记录链接和图像

时间:2018-12-31 14:48:04

标签: python discord discord.py

我试图仅记录发布到我的Discord服务器之一的站点链接和图像链接(而忽略聊天或开玩笑),并创建了一个简单的Python Discord机器人来执行此操作。它成功地将许多站点链接和图像链接保存到文件中。但是,许多其他链接,特别是那些由用户“大量”发布的链接(即,将多个图像或链接链接到一条消息)无法记录。

这是我简单的机器人:

import discord
import asyncio
import os

#Initializes the bot to accept commands.
client = discord.Client()

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

@client.event
async def on_message(message):
    if message.author != client.user:   #This prevents a self-propogating echo chamber of text!

        if(message.content == "log_channel"):
            async for message in client.logs_from(message.channel, limit=5000000, reverse=True):
                with open(os.getcwd()+"/logs.txt", "a") as output_file: 
                    if("http" in message.content): output_file.write(message.content+"\n")

client.run(xxx-xxx-xxx)

我该怎么做才能确保即使包含多个图像和链接的邮件也能准确记录?

0 个答案:

没有答案