diff options
Diffstat (limited to 'AyaBot/plugins/hitokoto.py')
-rw-r--r-- | AyaBot/plugins/hitokoto.py | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/AyaBot/plugins/hitokoto.py b/AyaBot/plugins/hitokoto.py deleted file mode 100644 index d5f05a3..0000000 --- a/AyaBot/plugins/hitokoto.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding:utf-8 -*- -import asyncio -import requests -from typing import Any -from functools import partial -from nonebot import on_command, CommandSession - - -class AsyncResponse: - def __init__(self, response: requests.Response): - self.raw_response = response - -async def run_sync_func(func, *args, **kwargs) -> Any: - return await asyncio.get_event_loop().run_in_executor( - None, partial(func, *args, **kwargs)) - -async def request(method, url, **kwargs) -> AsyncResponse: - return AsyncResponse(await run_sync_func(requests.request, - method=method, url=url, **kwargs)) - - -url = "https://api.imjad.cn/hitokoto/?cat=a&charset=utf-8&length=50&encode=&fun=sync&source=" - - -@on_command('hitokoto', aliases=['一言'], only_to_me=False) -async def _(session: CommandSession): - res = requests.get(url) - if not res.ok: - session.finish('获取失败') - session.finish(res.text)
\ No newline at end of file |