2020-08-12 16:01:34 +00:00
|
|
|
|
import json
|
2020-07-25 16:51:08 +00:00
|
|
|
|
import re
|
2020-08-12 16:01:34 +00:00
|
|
|
|
|
2020-09-19 10:35:13 +00:00
|
|
|
|
import aiohttp
|
|
|
|
|
|
2021-02-01 15:13:11 +00:00
|
|
|
|
from core.dirty_check import check
|
|
|
|
|
from modules.wiki.database import get_start_wiki
|
2020-08-12 16:01:34 +00:00
|
|
|
|
|
|
|
|
|
|
2021-02-01 15:13:11 +00:00
|
|
|
|
async def newbie(table, id):
|
|
|
|
|
get_wiki_url = get_start_wiki(table, id)
|
|
|
|
|
if get_wiki_url:
|
|
|
|
|
url = get_wiki_url + '?action=query&list=logevents&letype=newusers&format=json'
|
2020-08-07 13:13:12 +00:00
|
|
|
|
async with aiohttp.ClientSession() as session:
|
2020-08-12 16:01:34 +00:00
|
|
|
|
async with session.get(url, timeout=aiohttp.ClientTimeout(total=20)) as req:
|
2020-08-07 13:13:12 +00:00
|
|
|
|
if req.status != 200:
|
2020-08-15 06:41:56 +00:00
|
|
|
|
return f"请求时发生错误:{req.status}"
|
2020-08-07 13:13:12 +00:00
|
|
|
|
else:
|
|
|
|
|
text1 = await req.text()
|
2020-08-07 13:17:47 +00:00
|
|
|
|
file = json.loads(text1)
|
2020-08-07 13:13:12 +00:00
|
|
|
|
d = []
|
|
|
|
|
for x in file['query']['logevents']:
|
|
|
|
|
d.append(x['title'])
|
|
|
|
|
print(str(d))
|
2021-02-01 15:13:11 +00:00
|
|
|
|
m = '\n'.join(d)
|
|
|
|
|
y = await check([m])
|
2020-08-07 13:13:12 +00:00
|
|
|
|
print(str(y))
|
2021-02-01 15:13:11 +00:00
|
|
|
|
f = re.findall(r'.*\n.*\n.*\n.*\n.*', str(y))
|
2020-08-12 16:01:34 +00:00
|
|
|
|
g = '这是当前的新人列表:\n' + f[0] + '\n...仅显示前5条内容'
|
|
|
|
|
if g.find('<吃掉了>') != -1 or g.find('<全部吃掉了>') != -1:
|
|
|
|
|
return (g + '\n检测到外来信息介入,请前往日志查看所有消息。Special:日志?type=newusers')
|
2020-08-07 13:13:12 +00:00
|
|
|
|
else:
|
2020-08-12 16:01:34 +00:00
|
|
|
|
return (g)
|