mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/configs/path_config.py
This commit is contained in:
commit
6b5db57f83
7 changed files with 28 additions and 15 deletions
|
|
@ -43,6 +43,7 @@ class MajorArcana(Model):
|
||||||
await cls.bulk_create(Major_arcana_initial_data)
|
await cls.bulk_create(Major_arcana_initial_data)
|
||||||
arcana = await cls.all()
|
arcana = await cls.all()
|
||||||
tarots = random.choice(arcana)
|
tarots = random.choice(arcana)
|
||||||
|
print(tarots.image)
|
||||||
# 正位
|
# 正位
|
||||||
if ints == 0:
|
if ints == 0:
|
||||||
return await MajorArcanaLog.insertTarotLog(tarots, user_id, tarots_img_path+tarots.image,"正位")
|
return await MajorArcanaLog.insertTarotLog(tarots, user_id, tarots_img_path+tarots.image,"正位")
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import hashlib
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.chrome.options import Options
|
from selenium.webdriver.chrome.options import Options
|
||||||
|
from src.configs.path_config import VIDEO_PATH
|
||||||
|
|
||||||
chrome_options = Options()
|
chrome_options = Options()
|
||||||
chrome_options.add_argument("--headless")
|
chrome_options.add_argument("--headless")
|
||||||
|
|
@ -121,7 +122,7 @@ def video_download(file_url, cid):
|
||||||
# 检查请求是否成功
|
# 检查请求是否成功
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
# 将视频保存到本地文件
|
# 将视频保存到本地文件
|
||||||
with open(f'./src/videos/file/{cid}.mp4', 'wb') as file:
|
with open(VIDEO_PATH / f'{cid}.mp4', 'wb') as file:
|
||||||
for chunk in response.iter_content(chunk_size=1024):
|
for chunk in response.iter_content(chunk_size=1024):
|
||||||
if chunk:
|
if chunk:
|
||||||
file.write(chunk)
|
file.write(chunk)
|
||||||
|
|
@ -131,7 +132,7 @@ def video_download(file_url, cid):
|
||||||
|
|
||||||
def delete_video(cid):
|
def delete_video(cid):
|
||||||
# 指定要删除的文件路径
|
# 指定要删除的文件路径
|
||||||
file_path = f"src/videos/file/{cid}.mp4"
|
file_path = VIDEO_PATH / f"{cid}.mp4"
|
||||||
|
|
||||||
# 检查文件是否存在
|
# 检查文件是否存在
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ ju_he_image_list= "https://api.superbed.cn/timeline" # 聚合图床获取上传
|
||||||
"""
|
"""
|
||||||
AI
|
AI
|
||||||
"""
|
"""
|
||||||
admin_password= "123456"#默认注册管理员密码
|
admin_password= "123456" # 默认注册管理员密码
|
||||||
# 图灵机器人相关配置
|
# 图灵机器人相关配置
|
||||||
v3url= "https://api.vveai.com/v1/chat/completions"
|
v3url= "https://api.vveai.com/v1/chat/completions"
|
||||||
v3key= "<KEY>"
|
v3key= "<KEY>"
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,22 @@ font_path = path+'/font/'
|
||||||
temp_path = os.getcwd()+'/src/resources/temp/'
|
temp_path = os.getcwd()+'/src/resources/temp/'
|
||||||
|
|
||||||
|
|
||||||
# 图片路径
|
|
||||||
IMAGE_PATH = Path() / "resources" / "image"
|
|
||||||
# 语音路径
|
# 语音路径
|
||||||
RECORD_PATH = Path() / "resources" / "record"
|
RECORD_PATH = Path() / "src" / "resources" / "record"
|
||||||
# 文本路径
|
# 文本路径
|
||||||
TEXT_PATH = Path() / "resources" / "text"
|
TEXT_PATH = Path() / "src" / "resources" / "text"
|
||||||
|
# 日志路径
|
||||||
|
LOG_PATH = Path() / "src" / "log"
|
||||||
|
# 字体路径
|
||||||
|
FONT_PATH = Path() / "src" / "resources" / "font"
|
||||||
# 数据路径
|
# 数据路径
|
||||||
DATA_PATH = Path() / "data"
|
DATA_PATH = Path() / "src" / "data"
|
||||||
|
# 临时数据路径
|
||||||
|
TEMP_PATH = Path() / "src" / "resources" / "temp"
|
||||||
# 网页模板路径
|
# 网页模板路径
|
||||||
TEMPLATE_PATH = Path() / "resources" / "template"
|
TEMPLATE_PATH = Path() / "src" / "resources" / "template"
|
||||||
|
# 视频路径
|
||||||
|
VIDEO_PATH = Path() / "src" / "resources" / "videos"
|
||||||
|
|
||||||
|
|
||||||
# IMAGE_PATH.mkdir(parents=True, exist_ok=True)
|
# IMAGE_PATH.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
# https://api.bilibili.com/x/web-interface/search/type?keyword=av28465342&search_type=video&page=1
|
# https://api.bilibili.com/x/web-interface/search/type?keyword=av28465342&search_type=video&page=1
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import nonebot.adapters.qq.exception
|
import nonebot.adapters.qq.exception
|
||||||
from nonebot import on_command
|
from nonebot import on_command
|
||||||
from nonebot.rule import to_me
|
from nonebot.rule import to_me
|
||||||
from nonebot.adapters.qq import MessageSegment,MessageEvent, Message
|
from nonebot.adapters.qq import MessageSegment,MessageEvent, Message
|
||||||
import src.clover_videos.billibili.biliVideos as biliVideos
|
import src.clover_videos.billibili.biliVideos as biliVideos
|
||||||
|
from src.configs.path_config import VIDEO_PATH
|
||||||
|
|
||||||
bili_vid = on_command("B站搜索",rule=to_me(), priority=10, block=True)
|
bili_vid = on_command("B站搜索",rule=to_me(), priority=10, block=True)
|
||||||
@bili_vid.handle()
|
@bili_vid.handle()
|
||||||
|
|
@ -67,10 +70,10 @@ async def get_video_file(message: MessageEvent):
|
||||||
cid = pages[0]['cid']
|
cid = pages[0]['cid']
|
||||||
video_url = biliVideos.get_video_file_url(keyword[0], cid)
|
video_url = biliVideos.get_video_file_url(keyword[0], cid)
|
||||||
# biliVideos.video_download(video_url, cid)
|
# biliVideos.video_download(video_url, cid)
|
||||||
# biliVideos.transcode_video(f"{cid}.mp4",f"{cid}-o.mp4")
|
# biliVideos.transcode_video(f"./src/resources/videos/{cid}.mp4",f"./src/resources/videos/{cid}-o.mp4")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# await bili_bv_search.send(Message(MessageSegment.file_video(Path(f"./src/clover_videos/file/{cid}.mp4"))))
|
# await bili_bv_search.send(Message(MessageSegment.file_video(Path(VIDEO_PATH / f"{cid}-o.mp4"))))
|
||||||
await bili_bv_search.send(MessageSegment.video(video_url))
|
await bili_bv_search.send(MessageSegment.video(video_url))
|
||||||
except nonebot.adapters.qq.exception.ActionFailed as e:
|
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))
|
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))
|
||||||
|
|
@ -100,9 +103,10 @@ async def get_video_file(message: MessageEvent):
|
||||||
cid = pages[page_num - 1]['cid']
|
cid = pages[page_num - 1]['cid']
|
||||||
video_url = biliVideos.get_video_file_url(keyword[0], cid)
|
video_url = biliVideos.get_video_file_url(keyword[0], cid)
|
||||||
# biliVideos.video_download(video_url, cid)
|
# biliVideos.video_download(video_url, cid)
|
||||||
|
# biliVideos.transcode_video(VIDEO_PATH / f"{cid}.mp4", VIDEO_PATH / f"{cid}-o.mp4")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# await bili_bv_search.send(Message(MessageSegment.file_video(Path(f"./src/clover_videos/file/{cid}.mp4"))))
|
# await bili_bv_search.send(Message(MessageSegment.file_video(Path(VIDEO_PATH / f"{cid}.mp4"))))
|
||||||
await bili_bv_search.send(MessageSegment.video(video_url))
|
await bili_bv_search.send(MessageSegment.video(video_url))
|
||||||
except nonebot.adapters.qq.exception.ActionFailed as e:
|
except nonebot.adapters.qq.exception.ActionFailed as e:
|
||||||
print("\033[32m" + str(time.strftime("%m-%d %H:%M:%S")) +
|
print("\033[32m" + str(time.strftime("%m-%d %H:%M:%S")) +
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ from nonebot.plugin import on_command
|
||||||
from nonebot.rule import to_me
|
from nonebot.rule import to_me
|
||||||
from nonebot.adapters.qq import Message, MessageEvent, MessageSegment
|
from nonebot.adapters.qq import Message, MessageEvent, MessageSegment
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from src.configs.path_config import IMAGE_PATH
|
||||||
|
|
||||||
cf_query = on_command("cf", rule=to_me(), priority=10, block=True)
|
cf_query = on_command("cf", rule=to_me(), priority=10, block=True)
|
||||||
@cf_query.handle()
|
@cf_query.handle()
|
||||||
|
|
@ -24,7 +25,7 @@ async def get_cf_rounds():
|
||||||
if matches["phase"] == "FINISHED":
|
if matches["phase"] == "FINISHED":
|
||||||
break
|
break
|
||||||
|
|
||||||
cf_image_path = './src/resources/clover_image/codeforces/cfContestQR.png'
|
cf_image_path = IMAGE_PATH / "codeforces" / "cfContestQR.png"
|
||||||
msg = Message([
|
msg = Message([
|
||||||
MessageSegment.file_image(Path(cf_image_path)),
|
MessageSegment.file_image(Path(cf_image_path)),
|
||||||
MessageSegment.text(all_matches),
|
MessageSegment.text(all_matches),
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ from nonebot.rule import to_me
|
||||||
from nonebot.plugin import on_command
|
from nonebot.plugin import on_command
|
||||||
from nonebot.adapters.qq import Message, MessageEvent, MessageSegment,exception
|
from nonebot.adapters.qq import Message, MessageEvent, MessageSegment,exception
|
||||||
from src.clover_image.get_image import get_image_names
|
from src.clover_image.get_image import get_image_names
|
||||||
from src.clover_sqlite.models.fortune import QrFortune,QrFortuneLog
|
from src.clover_sqlite.models.fortune import QrFortune, QrFortuneLog
|
||||||
from src.clover_sqlite.models.tarot import MajorArcana
|
from src.clover_sqlite.models.tarot import MajorArcana
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
@ -54,4 +54,4 @@ async def get_tarot(message: MessageEvent):
|
||||||
print("\033[32m" + str(time.strftime("%m-%d %H:%M:%S")) +
|
print("\033[32m" + str(time.strftime("%m-%d %H:%M:%S")) +
|
||||||
"\033[0m [" + "\033[31;1mFAILED\033[0m" + "]" +
|
"\033[0m [" + "\033[31;1mFAILED\033[0m" + "]" +
|
||||||
"\033[31;1m nonebot.adapters.qq.exception.ActionFailed \033[0m" + str(e))
|
"\033[31;1m nonebot.adapters.qq.exception.ActionFailed \033[0m" + str(e))
|
||||||
await tarot.finish("您的塔罗拍被未来人抢走啦,请重试。这绝对不是咱的错,绝对不是!")
|
await tarot.finish("您的塔罗牌被未来人抢走啦,请重试。这绝对不是咱的错,绝对不是!")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue