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/bots/kook/bot.py

41 lines
1.4 KiB
Python
Raw Normal View History

2023-06-29 17:32:35 +00:00
import os
from bots.kook.client import bot
from khl import Message, MessageTypes
from core.builtins import PrivateAssets, Url
from core.logger import Logger
from core.parser.message import parser
from core.types import MsgInfo, Session
from core.utils.bot import load_prompt, init_async
from bots.kook.message import MessageSession, FetchTarget
PrivateAssets.set(os.path.abspath(os.path.dirname(__file__) + '/assets'))
@bot.on_message((MessageTypes.TEXT, MessageTypes.IMG))
async def msg_handler(message: Message):
targetId = f'Kook|{message.channel_type.name}|{message.target_id}'
replyId = None
if 'quote' in message.extra:
replyId = message.extra['quote']['rong_id']
msg = MessageSession(MsgInfo(targetId=targetId,
senderId=f'Kook|User|{message.author_id}',
targetFrom=f'Kook|{message.channel_type.name}',
senderFrom='Kook|User', senderName=message.author.nickname,
clientName='Kook',
messageId=message.id,
replyId=replyId),
Session(message=message, target=message.target_id, sender=message.author_id))
await parser(msg)
@bot.on_startup
async def _(b: bot):
await init_async()
await load_prompt(FetchTarget)
if bot:
bot.run()