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/core/builtins/__init__.py
2023-05-05 23:33:19 +08:00

41 lines
1.3 KiB
Python

from typing import Union, List
from core.types.message import FetchTarget, FetchedSession
from database import BotDBUtil
from .message import *
from .message.chain import *
from .message.internal import *
from .tasks import *
from .temp import *
from .utils import *
class Bot:
MessageSession = MessageSession
FetchTarget = FetchTarget
@staticmethod
async def sendMessage(target: Union[FetchedSession, MessageSession, str], msg: Union[MessageChain, list],
disable_secret_check=False,
allow_split_image=True):
if isinstance(target, str):
target = Bot.FetchTarget.fetch_target(target)
if not target:
raise ValueError("Target not found")
if isinstance(msg, list):
msg = MessageChain(msg)
await target.sendDirectMessage(msg, disable_secret_check, allow_split_image)
@staticmethod
async def fetch_target(target: str):
return Bot.FetchTarget.fetch_target(target)
@staticmethod
async def get_enabled_this_module(module: str) -> List[FetchedSession]:
lst = BotDBUtil.TargetInfo.get_enabled_this(module)
fetched = []
for x in lst:
x = Bot.FetchTarget.fetch_target(x)
if isinstance(x, FetchedSession):
fetched.append(x)
return fetched