blob: a49c8fc694633a8fa08ba26defb56e1ce43950bb (
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
31
32
33
34
|
import json
from nonebot import on_command, on_natural_language, CommandSession
from nonebot import NLPSession, NLPResult
from ATRI.modules.response import request_api
from ATRI.modules.error import errorBack
from ATRI.modules.time import sleepTime
from ATRI.modules.funcControl import checkNoob
url = 'https://api.imjad.cn/hitokoto/?cat=a&charset=utf-8&length=50&encode=json&fun=sync&source='
@on_command('hitokoto', aliases = ['一言'], only_to_me = False)
async def hitokoto(session: CommandSession):
user = session.event.user_id
group = session.event.group_id
if checkNoob(user, group):
if sleepTime():
await session.send(sleepTime())
else:
try:
rep = request_api(url)
except:
session.finish(errorBack('请求错误'))
dc = json.loads(rep)
await session.send(dc["hitokoto"])
@on_natural_language('一言', only_to_me = False)
async def _(session: NLPSession):
return NLPResult(60.0, ('hitokoto'), None)
|