猛男视频迁移成插件。删除原有逻辑
This commit is contained in:
@@ -5,7 +5,7 @@ api-key = "app-u5EnYq3ill19bm6pWJwGkY4D" # Dify的API Key
|
|||||||
base-url = "http://192.168.2.240/v1" #Dify API接口base url
|
base-url = "http://192.168.2.240/v1" #Dify API接口base url
|
||||||
|
|
||||||
commands = ["ai", "dify", "聊天", "AI"]
|
commands = ["ai", "dify", "聊天", "AI"]
|
||||||
command-tip = """-----Bot-----
|
command-tip = """
|
||||||
💬AI聊天指令:
|
💬AI聊天指令:
|
||||||
聊天 请求内容
|
聊天 请求内容
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,83 +0,0 @@
|
|||||||
import logging
|
|
||||||
import tomllib
|
|
||||||
import os
|
|
||||||
import requests
|
|
||||||
from wcferry import WxMsg, Wcf
|
|
||||||
|
|
||||||
from robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager
|
|
||||||
|
|
||||||
|
|
||||||
class BotVideo:
|
|
||||||
def __init__(self, wcf: Wcf, gbm: GroupBotManager):
|
|
||||||
self.LOG = logging.getLogger(__name__)
|
|
||||||
self.wcf = wcf # 假设 wcf 对象在此类中初始化
|
|
||||||
self.gbm = gbm # 权限功能
|
|
||||||
with open("group_video/config.toml", "rb") as f:
|
|
||||||
plugin_config = tomllib.load(f)
|
|
||||||
|
|
||||||
config = plugin_config["Video"]
|
|
||||||
|
|
||||||
self.enable = config["enable"]
|
|
||||||
self.command = config["command"]
|
|
||||||
self.LOG.info(f"[点视频] 组件初始化完成,指令: {self.command}")
|
|
||||||
|
|
||||||
def download_stream(self, url, save_path):
|
|
||||||
"""
|
|
||||||
从指定URL读取视频流并保存到本地
|
|
||||||
:param url: 视频流的URL
|
|
||||||
:param save_path: 本地保存路径(包含文件名,例如 "video.mp4")
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
# 发送GET请求,启用流式传输
|
|
||||||
response = requests.get(url, stream=True)
|
|
||||||
|
|
||||||
# 检查请求是否成功
|
|
||||||
response.raise_for_status() # 如果状态码不是200,将抛出异常
|
|
||||||
|
|
||||||
# 确保保存路径的目录存在
|
|
||||||
os.makedirs(os.path.dirname(save_path) or ".", exist_ok=True)
|
|
||||||
|
|
||||||
# 检查是否是视频流(可选,根据Content-Type判断)
|
|
||||||
content_type = response.headers.get("Content-Type", "").lower()
|
|
||||||
if "video" not in content_type and "application/octet-stream" not in content_type:
|
|
||||||
print(f"警告: 返回的可能不是视频流,Content-Type: {content_type}")
|
|
||||||
print("响应内容预览:", response.text[:100]) # 打印前100字符查看
|
|
||||||
return
|
|
||||||
|
|
||||||
# 以二进制写入模式保存流数据
|
|
||||||
with open(save_path, "wb") as file:
|
|
||||||
for chunk in response.iter_content(chunk_size=1024): # 分块读取,每块1KB
|
|
||||||
if chunk: # 过滤空块
|
|
||||||
file.write(chunk)
|
|
||||||
print(f"视频已下载到: {save_path}")
|
|
||||||
return os.path.abspath(save_path)
|
|
||||||
except requests.RequestException as e:
|
|
||||||
print(f"请求失败: {e}")
|
|
||||||
except IOError as e:
|
|
||||||
print(f"文件写入失败: {e}")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"发生未知错误: {e}")
|
|
||||||
|
|
||||||
def get_video(self, message: WxMsg):
|
|
||||||
if not self.enable:
|
|
||||||
return
|
|
||||||
|
|
||||||
content = str(message.content).strip()
|
|
||||||
command = content.split(" ")
|
|
||||||
|
|
||||||
if command[0] not in self.command:
|
|
||||||
return
|
|
||||||
|
|
||||||
# 如果触发了指令,但是没有权限,则返回权限不足
|
|
||||||
if self.gbm.get_group_permission(message.roomid, Feature.VIDEO) == PermissionStatus.DISABLED:
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
file_abspath = self.download_stream("https://api.guiguiya.com/api/hook/heisis", "down_load_dir/video.mp4")
|
|
||||||
except requests.RequestException as e:
|
|
||||||
self.wcf.send_text(f"❌请求出错:{e}",
|
|
||||||
(message.roomid if message.from_group() else message.sender), message.sender)
|
|
||||||
return
|
|
||||||
|
|
||||||
if file_abspath.endswith("mp4"):
|
|
||||||
self.wcf.send_file(file_abspath, (message.roomid if message.from_group() else message.sender))
|
|
||||||
return
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
[Video]
|
|
||||||
enable = true
|
|
||||||
command = ["黑丝视频", "黑丝", "来个黑丝","搞个黑丝"]
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
import logging
|
|
||||||
import tomllib
|
|
||||||
import os
|
|
||||||
import requests
|
|
||||||
from wcferry import WxMsg, Wcf
|
|
||||||
|
|
||||||
from robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager
|
|
||||||
|
|
||||||
|
|
||||||
class BotVideoMan:
|
|
||||||
def __init__(self, wcf: Wcf, gbm: GroupBotManager):
|
|
||||||
self.LOG = logging.getLogger(__name__)
|
|
||||||
self.wcf = wcf # 假设 wcf 对象在此类中初始化
|
|
||||||
self.gbm = gbm # 权限功能
|
|
||||||
with open("group_video_man/config.toml", "rb") as f:
|
|
||||||
plugin_config = tomllib.load(f)
|
|
||||||
|
|
||||||
config = plugin_config["VideoMan"]
|
|
||||||
|
|
||||||
self.enable = config["enable"]
|
|
||||||
self.command = config["command"]
|
|
||||||
self.LOG.info(f"[猛男视频] 组件初始化完成,指令: {self.command}")
|
|
||||||
|
|
||||||
def get_video(self, message: WxMsg):
|
|
||||||
if not self.enable:
|
|
||||||
return
|
|
||||||
|
|
||||||
content = str(message.content).strip()
|
|
||||||
command = content.split(" ")
|
|
||||||
|
|
||||||
if command[0] not in self.command:
|
|
||||||
return
|
|
||||||
|
|
||||||
# 如果触发了指令,但是没有权限,则返回权限不足
|
|
||||||
if self.gbm.get_group_permission(message.roomid, Feature.VIDEO_MAN) == PermissionStatus.DISABLED:
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
file_abspath = self.download_video("https://api.guiguiya.com/api/video/fuji?type=json",
|
|
||||||
"group_video_man/down_load_dir")
|
|
||||||
self.wcf.send_file(file_abspath, (message.roomid if message.from_group() else message.sender))
|
|
||||||
return
|
|
||||||
except requests.RequestException as e:
|
|
||||||
self.wcf.send_text(f"❌请求出错:{e}",
|
|
||||||
(message.roomid if message.from_group() else message.sender), message.sender)
|
|
||||||
return
|
|
||||||
|
|
||||||
def download_video(self, api_url, save_dir):
|
|
||||||
# 确保 save_dir 是一个目录
|
|
||||||
if os.path.isfile(save_dir):
|
|
||||||
print(f"错误: {save_dir} 是一个文件,不能作为目录使用。")
|
|
||||||
return None
|
|
||||||
|
|
||||||
os.makedirs(save_dir, exist_ok=True)
|
|
||||||
save_path = os.path.join(save_dir, "video.mp4")
|
|
||||||
|
|
||||||
response = requests.get(api_url)
|
|
||||||
if response.status_code == 200:
|
|
||||||
data = response.json()
|
|
||||||
video_url = data.get("url")
|
|
||||||
if video_url:
|
|
||||||
video_response = requests.get(video_url, stream=True)
|
|
||||||
if video_response.status_code == 200:
|
|
||||||
with open(save_path, "wb") as file:
|
|
||||||
for chunk in video_response.iter_content(chunk_size=1024):
|
|
||||||
file.write(chunk)
|
|
||||||
abs_path = os.path.abspath(save_path)
|
|
||||||
print(f"视频已下载至: {abs_path}")
|
|
||||||
return abs_path
|
|
||||||
else:
|
|
||||||
print("无法下载视频,HTTP 状态码:", video_response.status_code)
|
|
||||||
else:
|
|
||||||
print("API 响应中没有找到视频 URL")
|
|
||||||
else:
|
|
||||||
print("API 请求失败,HTTP 状态码:", response.status_code)
|
|
||||||
return None
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
[VideoMan]
|
|
||||||
enable = true
|
|
||||||
command = ["猛男", "肌肉", "帅哥"]
|
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
enable = true
|
enable = true
|
||||||
command = ["美腿", "腿来"]
|
command = ["美腿", "腿来"]
|
||||||
command-format = """
|
command-format = """
|
||||||
-----Bot-----
|
|
||||||
🦵美腿图片指令:
|
🦵美腿图片指令:
|
||||||
美腿
|
美腿
|
||||||
腿来
|
腿来
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
enable = true
|
enable = true
|
||||||
command = ["点歌", "音乐", "音乐点播", "点播音乐", "音乐点歌"]
|
command = ["点歌", "音乐", "音乐点播", "点播音乐", "音乐点歌"]
|
||||||
command-format = """
|
command-format = """
|
||||||
-----Bot-----
|
|
||||||
🎵点歌指令:
|
🎵点歌指令:
|
||||||
点歌 歌曲名
|
点歌 歌曲名
|
||||||
"""
|
"""
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
enable = true
|
enable = true
|
||||||
command = ["插件", "plugin", "插件管理"]
|
command = ["插件", "plugin", "插件管理"]
|
||||||
command-format = """
|
command-format = """
|
||||||
-----Bot-----
|
|
||||||
🔧插件管理指令:
|
🔧插件管理指令:
|
||||||
插件 列表 - 查看所有插件
|
插件 列表 - 查看所有插件
|
||||||
插件 启用 [插件名] - 启用插件
|
插件 启用 [插件名] - 启用插件
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ class PluginManagerPlugin(MessagePluginInterface):
|
|||||||
|
|
||||||
# 构建插件详情消息
|
# 构建插件详情消息
|
||||||
status_text = "✅ 已启用" if plugin.status == PluginStatus.RUNNING else "❌ 已禁用"
|
status_text = "✅ 已启用" if plugin.status == PluginStatus.RUNNING else "❌ 已禁用"
|
||||||
message = f"""-----Bot-----
|
message = f"""
|
||||||
📦 插件详情:{plugin.name}
|
📦 插件详情:{plugin.name}
|
||||||
📝 描述:{plugin.description}
|
📝 描述:{plugin.description}
|
||||||
🔢 版本:{plugin.version}
|
🔢 版本:{plugin.version}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
enable = true
|
enable = true
|
||||||
command = ["黑丝视频", "黑丝", "来个黑丝", "搞个黑丝"]
|
command = ["黑丝视频", "黑丝", "来个黑丝", "搞个黑丝"]
|
||||||
command-format = """
|
command-format = """
|
||||||
-----Bot-----
|
|
||||||
🎬视频指令:
|
🎬视频指令:
|
||||||
黑丝
|
黑丝
|
||||||
"""
|
"""
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
enable = true
|
enable = true
|
||||||
command = ["图来", "秀人", "美图", "随机图片"]
|
command = ["图来", "秀人", "美图", "随机图片"]
|
||||||
command-format = """
|
command-format = """
|
||||||
-----Bot-----
|
|
||||||
🖼️秀人图片指令:
|
🖼️秀人图片指令:
|
||||||
图来
|
图来
|
||||||
秀人
|
秀人
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
enable = true
|
enable = true
|
||||||
command = ["积分交易", "积分转账", "转账积分", "积分赠送", "赠送积分", "积分转移", "转移积分", "送积分", "积分送人", "送人积分", "积分赠予", "赠予"]
|
command = ["积分交易", "积分转账", "转账积分", "积分赠送", "赠送积分", "积分转移", "转移积分", "送积分", "积分送人", "送人积分", "积分赠予", "赠予"]
|
||||||
command-format = """
|
command-format = """
|
||||||
-----Bot-----
|
|
||||||
🔄转账积分:
|
🔄转账积分:
|
||||||
积分转账 积分数 @用户
|
积分转账 积分数 @用户
|
||||||
"""
|
"""
|
||||||
8
robot.py
8
robot.py
@@ -28,7 +28,6 @@ from game_task.game_task_encyclopedia import game_process_message, get_group_ids
|
|||||||
from group_add.main import GroupAdd
|
from group_add.main import GroupAdd
|
||||||
from group_auto.group_auto_invite import get_first_group_id, process_command
|
from group_auto.group_auto_invite import get_first_group_id, process_command
|
||||||
from group_auto.group_member_change import GroupMemberChange
|
from group_auto.group_member_change import GroupMemberChange
|
||||||
from group_video_man.bot_video_man import BotVideoMan
|
|
||||||
from message_sign.main import SignInSystem
|
from message_sign.main import SignInSystem
|
||||||
from message_storage.message_to_db import MessageStorage
|
from message_storage.message_to_db import MessageStorage
|
||||||
from plugin_common.event_system import EventType, EventSystem
|
from plugin_common.event_system import EventType, EventSystem
|
||||||
@@ -122,8 +121,6 @@ class Robot(Job):
|
|||||||
self.signin = SignInSystem(wcf, self.gbm, self.allContacts, self.db_pool, self.redis_pool, self.message_util)
|
self.signin = SignInSystem(wcf, self.gbm, self.allContacts, self.db_pool, self.redis_pool, self.message_util)
|
||||||
# 积分赠送功能加载
|
# 积分赠送功能加载
|
||||||
self.trade = PointTrade(wcf, self.gbm, self.db_pool)
|
self.trade = PointTrade(wcf, self.gbm, self.db_pool)
|
||||||
# 肌肉男视频
|
|
||||||
self.videoman = BotVideoMan(wcf, self.gbm)
|
|
||||||
# 加群测试
|
# 加群测试
|
||||||
self.group_add = GroupAdd(wcf, self.gbm)
|
self.group_add = GroupAdd(wcf, self.gbm)
|
||||||
# 抖音转视频
|
# 抖音转视频
|
||||||
@@ -328,11 +325,6 @@ class Robot(Job):
|
|||||||
self.trade.handle_text(message=msg)
|
self.trade.handle_text(message=msg)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.LOG.error(f"point trade error: {e}")
|
self.LOG.error(f"point trade error: {e}")
|
||||||
# 加入肌肉男视频功能
|
|
||||||
try:
|
|
||||||
self.videoman.get_video(message=msg)
|
|
||||||
except Exception as e:
|
|
||||||
self.LOG.error(f"videoman get_video error: {e}")
|
|
||||||
# 抖音组件
|
# 抖音组件
|
||||||
try:
|
try:
|
||||||
self.douyin.handle_douyin_links(message=msg)
|
self.douyin.handle_douyin_links(message=msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user