mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-16 05:45:24 +00:00
hitokoto 一言
This commit is contained in:
parent
b034b716d0
commit
f70ff43a6b
36
hitokoto/main.py
Normal file
36
hitokoto/main.py
Normal file
@ -0,0 +1,36 @@
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.single_utils import Message
|
||||
from pagermaid.utils import lang
|
||||
|
||||
|
||||
@listener(command="hitokoto",
|
||||
description=lang('hitokoto_des'))
|
||||
async def hitokoto(message: Message):
|
||||
hitokoto_while = 1
|
||||
hitokoto_json = None
|
||||
try:
|
||||
hitokoto_json = (await message.request.get("https://v1.hitokoto.cn/?charset=utf-8")).json()
|
||||
except ValueError:
|
||||
while hitokoto_while < 10:
|
||||
hitokoto_while += 1
|
||||
try:
|
||||
hitokoto_json = (await message.request.get("https://v1.hitokoto.cn/?charset=utf-8")).json()
|
||||
break
|
||||
except Exception:
|
||||
continue
|
||||
if not hitokoto_json:
|
||||
return
|
||||
hitokoto_type = {'a': lang('hitokoto_type_anime'), 'b': lang('hitokoto_type_manga'),
|
||||
'c': lang('hitokoto_type_game'), 'd': lang('hitokoto_type_article'),
|
||||
'e': lang('hitokoto_type_original'), 'f': lang('hitokoto_type_web'),
|
||||
'g': lang('hitokoto_type_other'), 'h': lang('hitokoto_type_movie'),
|
||||
'i': lang('hitokoto_type_poem'), 'j': lang('hitokoto_type_netease_music'),
|
||||
'k': lang('hitokoto_type_philosophy'), 'l': lang('hitokoto_type_meme')}
|
||||
add = ""
|
||||
if works := hitokoto_json["from"]:
|
||||
add += f"《{works}》"
|
||||
if works_type := hitokoto_json["type"]:
|
||||
add += f"({hitokoto_type[works_type]})"
|
||||
if from_who := hitokoto_json["from_who"]:
|
||||
add += f"{from_who}"
|
||||
await message.edit(f"{hitokoto_json['hitokoto']} {add}")
|
10
list.json
10
list.json
@ -429,6 +429,16 @@
|
||||
"supported": true,
|
||||
"des-short": "获取当前群组的死号数。",
|
||||
"des": "获取当前群组的死号数。\n指令:,getdel"
|
||||
},
|
||||
{
|
||||
"name": "hitokoto",
|
||||
"version": "1.0",
|
||||
"section": "chat",
|
||||
"maintainer": "xtaodada",
|
||||
"size": "1.6 kb",
|
||||
"supported": true,
|
||||
"des-short": "一言。",
|
||||
"des": "一言。\n指令:,hitokoto"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user