我看到别人的机器人如何从私人消息中接收消息,我也想。底线:你在给机器人的私人消息中写“lol”,它接受所有内容,如果你在服务器上的频道中写,那么机器人会忽略它。简而言之,接收消息并仅回复 PM。需要使用async def on_message(message)
主页
/
user-498921
MayorLeon19's questions
我想为我的世界服务器做一个解析器,所以我开始做它,这是一个死胡同。它显示相同的ip版本等等,我需要一切都不同,我的代码是:
import requests
from bs4 import BeautifulSoup as bs
import pandas as pd
URL_TEMPLATE = "https://monitoringminecraft.ru/novie-servera"
FILE_NAME = "test.csv"
def parse():
result_list = {'href': [], 'title': [], 'about': []}
r = requests.get(URL_TEMPLATE)
soup = bs(r.text, "html.parser")
server = soup.find('tr', class_='server')
ru = soup.find_all('div', class_='flag ru')
ip = soup.find('span', class_='ip_serv')
version = soup.find('td', class_='ver')
opened = soup.find('td', class_='opened')
online = soup.find('div', class_='wrap')
clear_ip = [c.text for c in ip]
clear_version = [c.text for c in version]
clear_opened = [c.text for c in opened]
clear_online = [c.text for c in online]
comps = []
for servers in server:
comps.append({
'ip': clear_ip,
'version': clear_version,
'opened': clear_opened,
'online': clear_online
})
for comp in comps:
print(comp)
parse()
控制台输出什么:
{'ip': ['89.239.167.113:19132'], 'version': ['?'], 'opened': ['только что'], 'online': [' ', '0', ' из 2022 ']}
{'ip': ['89.239.167.113:19132'], 'version': ['?'], 'opened': ['только что'], 'online': [' ', '0', ' из 2022 ']}
{'ip': ['89.239.167.113:19132'], 'version': ['?'], 'opened': ['только что'], 'online': [' ', '0', ' из 2022 ']}
{'ip': ['89.239.167.113:19132'], 'version': ['?'], 'opened': ['только что'], 'online': [' ', '0', ' из 2022 ']}
编码:
@slash.slash(
name="takecash",
description="- вычесть количество ар",
guild_ids=[924384808187093032],
options=[
create_option(
name="member",
description="пользователь",
required=True,
option_type=6,
),
create_option(
name="amount",
description="количество аров",
required=True,
option_type=10,
),
]
)
@commands.has_any_role(971817475543035975)
async def takecash(ctx, member: discord.Member, amount:str):
if amount < 1:
await ctx.send(f"**{ctx.author}**, укажите сумму больше 1")
else:
cursor.execute("UPDATE users SET cash = cash - {} WHERE id = {}".format(amount, member.id))
connection.commit()