mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
新增喜报悲报功能
This commit is contained in:
parent
d9d71cd716
commit
f77fc046f5
3 changed files with 40 additions and 2 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -15,4 +15,5 @@ chat_history.json
|
|||
/chat_bot.db-wal
|
||||
/chat_bot.db-shm
|
||||
error.log
|
||||
.log
|
||||
*.log
|
||||
.mp4
|
||||
|
|
@ -20,7 +20,7 @@ with open(os.getcwd() + '/src/ai_chat/config/chat_ai.yaml', 'r', encoding='utf-8
|
|||
|
||||
|
||||
menu = ['/今日运势','/图','/点歌','/摸摸头','/群老婆','/今日老婆', "/开启ai","/关闭ai","/角色列表","/添加人设", "/更新人设", "/删除人设", "/切换人设", "/管理员注册",
|
||||
'/待办', '/test','/天气','我喜欢你', "❤", "/待办查询", "/新建待办", "/删除待办" ,"/cf", "/奶龙", "/repo", "/info", "/B站搜索", "/BV搜索"]
|
||||
'/待办', '/test','/天气','我喜欢你', "❤", "/待办查询", "/新建待办", "/删除待办" ,"/cf", "/奶龙", "/repo", "/info", "/B站搜索", "/BV搜索", "/喜报", "/悲报"]
|
||||
|
||||
|
||||
async def check_value_in_menu(message: MessageEvent) -> bool:
|
||||
|
|
|
|||
37
src/qq_plugins/good_bad_news.py
Normal file
37
src/qq_plugins/good_bad_news.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from pathlib import Path
|
||||
from nonebot.rule import to_me
|
||||
from nonebot.plugin import on_command
|
||||
from nonebot.adapters.qq import Message, MessageEvent, MessageSegment
|
||||
import urllib.parse, requests
|
||||
import httpx
|
||||
|
||||
good_news = on_command("喜报", rule=to_me(), priority=10, block=True, aliases={"悲报"})
|
||||
@good_news.handle()
|
||||
async def good_news_img(message: MessageEvent):
|
||||
if message.get_plaintext().startswith("/喜报"):
|
||||
content = message.get_plaintext().replace("/喜报", "").strip()
|
||||
url = "https://cdn.uuuix.com/api/v1/xbs/xb.php?"
|
||||
else:
|
||||
content = message.get_plaintext().replace("/悲报", "").strip()
|
||||
url = "https://cdn.uuuix.com/api/v1/xbs/biob.php?"
|
||||
|
||||
params = {
|
||||
'msg': content
|
||||
}
|
||||
|
||||
await good_news.send("图片绘制中,请稍后~\n技术支持: JianDan大佬\nwww·uuuix·com")
|
||||
|
||||
query = urllib.parse.urlencode(params)
|
||||
response = requests.get(url + query).json()
|
||||
|
||||
if response['code'] != 1:
|
||||
await good_news.finish("请输入 /喜(悲)报+内容 哦。")
|
||||
|
||||
img_url = response['url']
|
||||
# try:
|
||||
# await good_news.finish(MessageSegment.image(img_url))
|
||||
# except BaseException:
|
||||
# await good_news.finish("出错啦,请重试。")
|
||||
|
||||
await good_news.finish(MessageSegment.image(img_url))
|
||||
|
||||
Loading…
Reference in a new issue