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

69 lines
2.2 KiB
Python
Raw Normal View History

import traceback
from core.builtins import Bot
2023-03-04 08:51:56 +00:00
from core.component import module
from modules.wiki.utils.dbutils import WikiTargetInfo, Audit
from modules.wiki.utils.wikilib import WikiLib, WhatAreUDoingError, PageInfo, InvalidWikiError, QueryInfo
from .ab import ab
from .ab_qq import ab_qq
from .newbie import newbie
from .rc import rc
from .rc_qq import rc_qq
2023-05-19 04:46:29 +00:00
rc_ = module('rc', desc='{wiki.help.rc.desc}', developers=['OasisAkari'])
@rc_.handle()
async def rc_loader(msg: Bot.MessageSession):
start_wiki = WikiTargetInfo(msg).get_start_wiki()
if start_wiki is None:
2023-04-15 06:06:42 +00:00
return await msg.finish(msg.locale.t('wiki.message.not_set'))
legacy = True
if msg.Feature.forward and msg.target.targetFrom == 'QQ|Group':
try:
nodelist = await rc_qq(start_wiki)
await msg.fake_forward_msg(nodelist)
legacy = False
except Exception:
traceback.print_exc()
2023-05-31 15:28:15 +00:00
await msg.sendMessage(msg.locale.t('wiki.message.rollback'))
legacy = True
if legacy:
2023-05-31 15:21:57 +00:00
res = await rc(msg, start_wiki)
await msg.finish(res)
2023-05-19 04:46:29 +00:00
a = module('ab', desc='{wiki.help.ab.desc}', developers=['OasisAkari'])
@a.handle()
async def ab_loader(msg: Bot.MessageSession):
start_wiki = WikiTargetInfo(msg).get_start_wiki()
if start_wiki is None:
2023-04-15 06:06:42 +00:00
return await msg.finish(msg.locale.t('wiki.message.not_set'))
legacy = True
if msg.Feature.forward and msg.target.targetFrom == 'QQ|Group':
try:
nodelist = await ab_qq(start_wiki)
await msg.fake_forward_msg(nodelist)
legacy = False
except Exception:
traceback.print_exc()
2023-05-31 15:28:15 +00:00
await msg.sendMessage(msg.locale.t('wiki.message.rollback'))
legacy = True
if legacy:
2023-04-26 03:03:12 +00:00
res = await ab(msg, start_wiki)
await msg.finish(res)
2023-05-19 04:46:29 +00:00
n = module('newbie', desc='{wiki.help.newbie.desc}', developers=['OasisAkari'])
@n.handle()
async def newbie_loader(msg: Bot.MessageSession):
start_wiki = WikiTargetInfo(msg).get_start_wiki()
if start_wiki is None:
2023-04-15 06:06:42 +00:00
return await msg.finish(msg.locale.t('wiki.message.not_set'))
2023-05-21 11:56:17 +00:00
res = await newbie(msg, start_wiki)
await msg.finish(res)