2021-02-01 15:25:57 +00:00
|
|
|
|
import asyncio
|
|
|
|
|
import traceback
|
|
|
|
|
|
|
|
|
|
from graia.application import MessageChain
|
|
|
|
|
from graia.application.message.elements.internal import Plain
|
|
|
|
|
|
|
|
|
|
from core.dirty_check import check
|
2021-02-19 12:20:00 +00:00
|
|
|
|
from core.loader import logger_info
|
2021-02-01 15:25:57 +00:00
|
|
|
|
from modules.user.userlib import get_data
|
|
|
|
|
from modules.utils.UTC8 import UTC8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def newbie(app):
|
2021-02-03 14:43:24 +00:00
|
|
|
|
logger_info('Subbot newbie launched')
|
2021-02-01 15:25:57 +00:00
|
|
|
|
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'])
|
|
|
|
|
while True:
|
|
|
|
|
c = 'f'
|
|
|
|
|
try:
|
|
|
|
|
qqqq = await get_data(url, 'json')
|
|
|
|
|
for xz in qqqq['query']['logevents'][:]:
|
|
|
|
|
if xz['title'] in qq:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
2021-02-19 11:26:55 +00:00
|
|
|
|
s = await check(UTC8(xz['timestamp'], 'onlytime') + '新增新人:' + xz['title'])
|
2021-02-02 05:36:35 +00:00
|
|
|
|
if s.find("<吃掉了>") != -1 or s.find("<全部吃掉了>") != -1:
|
2021-02-02 09:33:55 +00:00
|
|
|
|
await app.sendGroupMessage(731397727, MessageChain.create(
|
2021-03-21 06:57:02 +00:00
|
|
|
|
[Plain(s + '\n检测到外来信息介入,请前往日志查看所有消息。https://minecraft-zh.gamepedia.com/Special:%E6%97%A5%E5%BF%97?type=newusers')]).asSendable())
|
2021-02-01 15:25:57 +00:00
|
|
|
|
else:
|
|
|
|
|
await app.sendGroupMessage(731397727,
|
2021-02-02 05:36:35 +00:00
|
|
|
|
MessageChain.create([Plain(s)]).asSendable())
|
2021-02-01 15:25:57 +00:00
|
|
|
|
c = 't'
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
if c == 't':
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
await asyncio.sleep(10)
|
|
|
|
|
await asyncio.sleep(5)
|
|
|
|
|
except Exception:
|
|
|
|
|
traceback.print_exc()
|