Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/newbie/__init__.py
2020-09-19 14:21:06 +08:00

33 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding:utf-8 -*-
import aiohttp
import json
import re
from modules.pbc import pbc
async def new():
url = 'https://minecraft-zh.gamepedia.com/api.php?action=query&list=logevents&letype=newusers&format=json'
async with aiohttp.ClientSession() as session:
async with session.get(url, timeout=aiohttp.ClientTimeout(total=20)) as req:
if req.status != 200:
return f"请求时发生错误:{req.status}"
else:
text1 = await req.text()
file = json.loads(text1)
d = []
for x in file['query']['logevents']:
d.append(x['title'])
print(str(d))
y = await pbc(d)
space = '\n'
print(str(y))
j = space.join(y)
f = re.findall(r'.*\n.*\n.*\n.*\n.*', j)
g = '这是当前的新人列表:\n' + f[0] + '\n...仅显示前5条内容'
if g.find('<吃掉了>') != -1 or g.find('<全部吃掉了>') != -1:
return (g + '\n检测到外来信息介入请前往日志查看所有消息。Special:日志?type=newusers')
else:
return (g)
command = '新人'