From 74d76543072a89fd7f4edbbde94eb665cc24275d Mon Sep 17 00:00:00 2001 From: Kyomotoi <1172294279@qq.com> Date: Sun, 31 May 2020 15:05:33 +0800 Subject: =?UTF-8?q?=E5=BC=80=E6=96=B0=E5=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AyaBot/plugins/hitokoto.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 AyaBot/plugins/hitokoto.py (limited to 'AyaBot/plugins/hitokoto.py') diff --git a/AyaBot/plugins/hitokoto.py b/AyaBot/plugins/hitokoto.py new file mode 100644 index 0000000..d621bb5 --- /dev/null +++ b/AyaBot/plugins/hitokoto.py @@ -0,0 +1,30 @@ +import json +import requests +import pandas as pd +from nonebot import on_command, CommandSession +from datetime import datetime + + +url_1 = 'https://api.imjad.cn/hitokoto/?cat=a&charset=utf-8&length=50&encode=json&fun=sync&source=' +response_1 = requests.get(url=url_1).json() +data_1 = json.load(response_1) + +filename1 = "data_1.json" + +LIST = """一言 +{hitokoto} +by {source} +""" + +@on_command('hitokoto', aliases=['一言'], only_to_me=False) +async def _(session: CommandSession): + f = open(filename1, encoding='utf-8') + setting = json.load(f) + await session.send(LIST.format( + hitokoto=setting["hitokoto"], + source=setting["source"] + ) + ) + + +#开发ing \ No newline at end of file -- cgit v1.2.3