Python discord Bot 处理来自一个用户的消息并在 webhook 中发送它们
Python discord Bot coping messages from one user and sending them in a webhook
所以我尝试编写一个机器人,它将从一个用户那里复制消息并将它们通过网络挂接发送到另一台服务器,但我在处理消息时遇到了困难,找不到任何答案。
import discord
import os
import requests
import json
from dhooks import Webhook, file
hook = Webhook("WEBHOOK HERE")
client = discord.Client()
@client.event
async def on_ready():
print('Logged in as {0.user}'.format(client))
async def on_message(message):
if message.author.id == "ID HERE":
hook.send(content = "MESSAGE HERE", username = "Secound", avatar_url = "https://i.imgur.com/Kg5IIib.png")
client.run(os.getenv('TOKEN'))
discord.Message
具有引用消息内容的属性 content
content = message.content
# i.e `Hello world`
参考:
所以我尝试编写一个机器人,它将从一个用户那里复制消息并将它们通过网络挂接发送到另一台服务器,但我在处理消息时遇到了困难,找不到任何答案。
import discord
import os
import requests
import json
from dhooks import Webhook, file
hook = Webhook("WEBHOOK HERE")
client = discord.Client()
@client.event
async def on_ready():
print('Logged in as {0.user}'.format(client))
async def on_message(message):
if message.author.id == "ID HERE":
hook.send(content = "MESSAGE HERE", username = "Secound", avatar_url = "https://i.imgur.com/Kg5IIib.png")
client.run(os.getenv('TOKEN'))
discord.Message
具有引用消息内容的属性 content
content = message.content
# i.e `Hello world`