mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
错误信息美观输出
This commit is contained in:
parent
f0e957d2fc
commit
7293d96962
3 changed files with 17 additions and 8 deletions
|
|
@ -1,10 +1,7 @@
|
|||
# https://api.bilibili.com/x/web-interface/search/type?keyword=av28465342&search_type=video&page=1
|
||||
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import nonebot.adapters.qq.exception
|
||||
import requests
|
||||
from nonebot import on_command
|
||||
from nonebot.rule import to_me
|
||||
from nonebot.adapters.qq import MessageSegment,MessageEvent, Message
|
||||
|
|
@ -75,7 +72,8 @@ async def get_video_file(message: MessageEvent):
|
|||
try:
|
||||
# await bili_bv_search.send(Message(MessageSegment.file_video(Path(f"./src/videos/file/{cid}.mp4"))))
|
||||
await bili_bv_search.send(MessageSegment.video(video_url))
|
||||
except nonebot.adapters.qq.exception.ActionFailed:
|
||||
except nonebot.adapters.qq.exception.ActionFailed as e:
|
||||
print("\033[32m" + str(time.strftime("%m-%d %H:%M:%S")) +"\033[0m [" + "\033[31;1mFAILED\033[0m" + "]" + "\033[31;1m nonebot.adapters.qq.exception.ActionFailed \033[0m" + str(e))
|
||||
await bili_bv_search.finish("发送失败惹,可能是视频过长,请尽量搜索1分钟以内的视频吧。")
|
||||
|
||||
# biliVideos.delete_video(cid)
|
||||
|
|
@ -106,7 +104,10 @@ async def get_video_file(message: MessageEvent):
|
|||
try:
|
||||
# await bili_bv_search.send(Message(MessageSegment.file_video(Path(f"./src/videos/file/{cid}.mp4"))))
|
||||
await bili_bv_search.send(MessageSegment.video(video_url))
|
||||
except nonebot.adapters.qq.exception.ActionFailed:
|
||||
except nonebot.adapters.qq.exception.ActionFailed as e:
|
||||
print("\033[32m" + str(time.strftime("%m-%d %H:%M:%S")) +
|
||||
"\033[0m [" + "\033[31;1mFAILED\033[0m" + "]" +
|
||||
"\033[31;1m nonebot.adapters.qq.exception.ActionFailed \033[0m" + str(e))
|
||||
await bili_bv_search.finish("发送失败惹,可能是视频过长,请尽量搜索1分钟以内的视频吧。")
|
||||
|
||||
# biliVideos.delete_video(cid)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from nonebot.adapters.qq import Message, MessageEvent, MessageSegment,exception
|
|||
from src.image.get_image import get_image_names
|
||||
from src.my_sqlite.models.fortune import QrFortune,QrFortuneLog
|
||||
from src.my_sqlite.models.tarot import MajorArcana
|
||||
import time
|
||||
|
||||
fortune_by_sqlite = on_command("今日运势", rule=to_me(), priority=10, block=True)
|
||||
@fortune_by_sqlite.handle()
|
||||
|
|
@ -28,7 +29,9 @@ async def get_today_fortune(message: MessageEvent):
|
|||
try:
|
||||
await fortune_by_sqlite.finish(msg)
|
||||
except exception.ActionFailed as e:
|
||||
print(e)
|
||||
print("\033[32m" + str(time.strftime("%m-%d %H:%M:%S")) +
|
||||
"\033[0m [" + "\033[31;1mFAILED\033[0m" + "]" +
|
||||
"\033[31;1m nonebot.adapters.qq.exception.ActionFailed \033[0m" + str(e))
|
||||
await fortune_by_sqlite.finish("您的今日运势被外星人抢走啦,请重试。这绝对不是咱的错,绝对不是!")
|
||||
|
||||
|
||||
|
|
@ -48,5 +51,7 @@ async def get_tarot(message: MessageEvent):
|
|||
try:
|
||||
await tarot.finish(msg)
|
||||
except exception.ActionFailed as e:
|
||||
print(e)
|
||||
print("\033[32m" + str(time.strftime("%m-%d %H:%M:%S")) +
|
||||
"\033[0m [" + "\033[31;1mFAILED\033[0m" + "]" +
|
||||
"\033[31;1m nonebot.adapters.qq.exception.ActionFailed \033[0m" + str(e))
|
||||
await tarot.finish("您的塔罗拍被未来人抢走啦,请重试。这绝对不是咱的错,绝对不是!")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from nonebot.rule import to_me
|
|||
from nonebot.plugin import on_command
|
||||
from nonebot.adapters.qq import Message, MessageEvent, MessageSegment, exception
|
||||
import urllib.parse, requests
|
||||
import time
|
||||
import httpx
|
||||
|
||||
good_news = on_command("喜报", rule=to_me(), priority=10, block=True, aliases={"悲报"})
|
||||
|
|
@ -36,6 +37,8 @@ async def good_news_img(message: MessageEvent):
|
|||
try:
|
||||
await good_news.finish(MessageSegment.image(img_url))
|
||||
except exception.ActionFailed as e:
|
||||
print(e)
|
||||
print("\033[32m" + str(time.strftime("%m-%d %H:%M:%S")) +
|
||||
"\033[0m [" + "\033[31;1mFAILED\033[0m" + "]" +
|
||||
"\033[31;1m nonebot.adapters.qq.exception.ActionFailed \033[0m" + str(e))
|
||||
await good_news.finish("图片发送失败,请重试。这绝对不是咱的错,绝对不是!")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue