【发布时间】:2020-07-22 12:31:44
【问题描述】:
我现在正在计算 d-day 并注意到不和谐的机器人。我需要我的机器人每 12 小时发送一次 d-day 计数消息。我怎样才能做到这一点??
import discord
from discord.ext import commands
from bs4 import BeautifulSoup as bs
import asyncio
import requests
bot = commands.Bot(command_prefix='?')
html = requests.get('https://superkts.com/cal/d_day/20200504')
soup = bs(html.text, 'html.parser')
data1 = soup.find('article', {'class': 'result'}).text
html = requests.get('https://superkts.com/cal/d_day/20201203')
soup = bs(html.text, 'html.parser')
data2 = soup.find('article', {'class': 'result'}).text
html = requests.get('https://superkts.com/cal/d_day/20220105')
soup = bs(html.text, 'html.parser')
data3 = soup.find('article', {'class': 'result'}).text
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.command()
async def notice(ctx):
await ctx.send("문준영 입대" + data1)
await ctx.send("신원호 수능" + data2)
await ctx.send("김수한 전역" + data3)
bot.run('TOKEN')
【问题讨论】:
-
如果您使用的是 Windows,您还应该考虑使用 Windows 任务计划程序。
-
只是想在代码级别完成
标签: python discord discord.py