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.py
2023-04-26 11:03:12 +08:00

22 lines
1.1 KiB
Python

from core.builtins import Url, Bot
from core.dirty_check import check
from modules.wiki.utils.UTC8 import UTC8
from modules.wiki.utils.wikilib import WikiLib
async def ab(msg: Bot.MessageSession, wiki_url):
wiki = WikiLib(wiki_url)
query = await wiki.get_json(action='query', list='abuselog', aflprop='user|title|action|result|filter|timestamp')
pageurl = wiki.wiki_info.articlepath.replace('$1', 'Special:AbuseLog')
d = []
for x in query['query']['abuselog'][:5]:
if 'title' in x:
d.append(msg.locale.t("wiki.ab.message.slice", title=x['title'], user=x['user'],
time=UTC8(x['timestamp'], 'onlytimenoutc'),
filter_name=x['filter'], result=x['result']))
y = await check(*d)
y = '\n'.join(z['content'] for z in y)
if y.find('<吃掉了>') != -1 or y.find('<全部吃掉了>') != -1:
return f'{str(Url(pageurl))}\n{y}\n{msg.locale.t("wiki.ab.message.only_last_5")}\n{msg.locale.t("wiki.ab.message.ban")}'
else:
return f'{str(Url(pageurl))}\n{y}\n' + msg.locale.t("wiki.ab.message.only_last_5")