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.3 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.

from config import Config
from core.dirty_check import check
from core.logger import Logger
from modules.wiki.utils.UTC8 import UTC8
from modules.wiki.utils.wikilib import WikiLib
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 + ('\n tips复制粘贴下面的任一消息到聊天窗口发送可获取此次改动详细信息的截图。'
if wiki.wiki_info.in_allowlist else '')}}]
}
}]
ablist = []
userlist = []
titlelist = []
for x in query["query"]["abuselog"]:
if 'title' in x:
userlist.append(x['user'])
titlelist.append(x['title'])
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']]}")
t.append(f"过滤器名:{x['filter']}")
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}}],
}
})
Logger.debug(nodelist)
return nodelist