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/legacy_subbot.py
2021-02-02 17:33:55 +08:00

47 lines
1.9 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.

import asyncio
import traceback
from graia.application import MessageChain
from graia.application.message.elements.internal import Plain
from core.dirty_check import check
from modules.user.userlib import get_data
from modules.utils.UTC8 import UTC8
async def newbie(app):
print('subbot newbie launched')
url = 'https://minecraft-zh.gamepedia.com/api.php?action=query&list=logevents&letype=newusers&format=json'
while True:
try:
file = await get_data(url, 'json')
qq = []
for x in file['query']['logevents'][:]:
qq.append(x['title'])
print('!' + x['title'])
while True:
c = 'f'
try:
qqqq = await get_data(url, 'json')
for xz in qqqq['query']['logevents'][:]:
if xz['title'] in qq:
pass
else:
s = await check([UTC8(xz['timestamp'], 'onlytime') + '新增新人:' + xz['title']])
print(s)
if s.find("<吃掉了>") != -1 or s.find("<全部吃掉了>") != -1:
await app.sendGroupMessage(731397727, MessageChain.create(
[Plain(s + '\n检测到外来信息介入请前往日志查看所有消息。Special:日志?type=newusers')]).asSendable())
else:
await app.sendGroupMessage(731397727,
MessageChain.create([Plain(s)]).asSendable())
c = 't'
except Exception:
pass
if c == 't':
break
else:
await asyncio.sleep(10)
await asyncio.sleep(5)
except Exception:
traceback.print_exc()