summaryrefslogtreecommitdiff
path: root/AyaBot/plugins/hitokoto.py
blob: d621bb5019d5f887bd34964a65d136905b653528 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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