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/newbie.py

23 lines
926 B
Python
Raw Normal View History

2023-05-21 04:42:17 +00:00
from core.builtins import Bot
2021-11-12 14:25:53 +00:00
from core.dirty_check import check
from modules.wiki.utils.wikilib import WikiLib
2021-11-12 14:25:53 +00:00
2023-05-21 04:42:17 +00:00
async def newbie(msg: Bot.MessageSession, wiki_url):
2021-11-12 14:25:53 +00:00
wiki = WikiLib(wiki_url)
query = await wiki.get_json(action='query', list='logevents', letype='newusers')
2022-04-08 07:17:39 +00:00
pageurl = wiki.wiki_info.articlepath.replace(
'$1', 'Special:Log?type=newusers')
2021-11-12 14:25:53 +00:00
d = []
for x in query['query']['logevents'][:5]:
2023-01-16 07:54:07 +00:00
if 'title' in x:
d.append(x['title'])
2021-11-12 14:25:53 +00:00
y = await check(*d)
y = '\n'.join(z['content'] for z in y)
2023-12-13 14:50:05 +00:00
g = f'{pageurl}\n{y}\n{msg.locale.t("message.collapse", amount="5")}'
if g.find("<吃掉了>") != -1 or g.find("<全部吃掉了>") != -1:
2023-12-13 14:50:05 +00:00
g = g.replace("<吃掉了>", msg.locale.t("check.redacted"))
g = g.replace("<全部吃掉了>", msg.locale.t("check.redacted.all"))
2023-05-21 04:42:17 +00:00
g += f'\n{msg.locale.t("wiki.message.utils.banned")}'
2021-11-12 14:25:53 +00:00
return g