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/wiki/utils/ab_qq.py

62 lines
2.1 KiB
Python
Raw Normal View History

2021-11-12 14:25:53 +00:00
from config import Config
from core.dirty_check import check
2022-08-04 07:52:42 +00:00
from core.logger import Logger
2021-11-12 14:25:53 +00:00
from modules.wiki.utils.UTC8 import UTC8
from modules.wiki.utils.wikilib import WikiLib
2021-11-12 14:25:53 +00:00
async def ab_qq(wiki_url):
wiki = WikiLib(wiki_url)
qq_account = Config("qq_account")
query = await wiki.get_json(action='query', list='abuselog', aflprop='user|title|action|result|filter|timestamp',
afllimit=99)
pageurl = wiki.wiki_info.articlepath.replace("$1", 'Special:AbuseLog')
nodelist = [{
"type": "node",
"data": {
"name": f"滥用过滤器日志地址",
"uin": qq_account,
"content": [
{"type": "text", "data": {"text": pageurl}}]
}
}]
ablist = []
userlist = []
titlelist = []
for x in query["query"]["abuselog"]:
2023-01-16 07:54:07 +00:00
if 'title' in x:
userlist.append(x['user'])
titlelist.append(x['title'])
2021-11-12 14:25:53 +00:00
checked_userlist = await check(*userlist)
user_checked_map = {}
for u in checked_userlist:
user_checked_map[u['original']] = u['content']
checked_titlelist = await check(*titlelist)
title_checked_map = {}
for t in checked_titlelist:
title_checked_map[t['original']] = t['content']
for x in query["query"]["abuselog"]:
t = []
t.append(f"用户:{user_checked_map[x['user']]}")
t.append(f"页面标题:{title_checked_map[x['title']]}")
2022-01-05 11:14:45 +00:00
t.append(f"过滤器名:{x['filter']}")
2021-11-12 14:25:53 +00:00
t.append(f"操作:{x['action']}")
result = x['result']
if result == '':
result = 'pass'
t.append(f"处理结果:{result}")
t.append(UTC8(x['timestamp'], 'full'))
ablist.append('\n'.join(t))
for x in ablist:
nodelist.append(
{
"type": "node",
"data": {
"name": f"滥用过滤器日志",
"uin": qq_account,
"content": [{"type": "text", "data": {"text": x}}],
}
})
2022-08-04 07:52:42 +00:00
Logger.debug(nodelist)
2021-11-12 14:25:53 +00:00
return nodelist