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/hitokoto/__init__.py
2023-05-04 20:12:21 +08:00

17 lines
776 B
Python

from core.builtins import Bot
from core.component import module
from core.builtins.message import MessageSession
from core.dirty_check import check
from core.utils.http import get_url
hitokoto = module('hitokoto', developers=['bugungu', 'DoroWolf'], desc='{hitokoto.help.desc}')
@hitokoto.handle('{{hitokoto.help}}')
async def _(msg: Bot.MessageSession):
url = 'https://v1.hitokoto.cn/?encode=json'
data = await get_url(url, 200, fmt = 'json')
from_who = data["from_who"] or ""
types = msg.locale.t('hitokoto.message.type') + msg.locale.t('hitokoto.message.type.' + data['type'])
link = 'https://hitokoto.cn?id=' + {data["id"]}
await msg.sendMessage(f'''{data["hitokoto"]}\n——{from_who}{data["from"]}\n{types}\n{link}''')