1.添加手动添加群组的能力
2.添加异步入库的能力
This commit is contained in:
@@ -255,7 +255,7 @@ class DouyinParserPlugin(MessagePluginInterface):
|
||||
try:
|
||||
api_url = "http://192.168.2.240:9081/api/hybrid/video_data"
|
||||
clean_url = self._clean_url(url)
|
||||
params = {'url': clean_url, 'type': 'json'}
|
||||
params = {'url': clean_url, 'minimal': True}
|
||||
|
||||
self.LOG.info(f"[抖音] 请求API: {api_url}, 参数: {repr(params)}")
|
||||
proxy = {"http": self.http_proxy, "https": self.http_proxy} if self.http_proxy else None
|
||||
|
||||
@@ -159,6 +159,46 @@ class DashboardServer:
|
||||
self.logger.error(f"批量操作失败: {e}")
|
||||
return jsonify({"success": False, "error": str(e)}), 400
|
||||
|
||||
# 添加:手动添加群组的API接口
|
||||
@app.route('/api/robot/add_group', methods=['POST'])
|
||||
def api_add_group():
|
||||
try:
|
||||
data = request.json
|
||||
group_id = data.get('group_id')
|
||||
|
||||
if not group_id or not group_id.strip():
|
||||
return jsonify({"success": False, "error": "群组ID不能为空"}), 400
|
||||
|
||||
group_id = group_id.strip()
|
||||
|
||||
# 检查群组是否已存在
|
||||
if group_id in GroupBotManager.local_cache["group_list"]:
|
||||
return jsonify({"success": False, "error": "该群组已存在"}), 400
|
||||
|
||||
# 添加群组到列表并启用机器人功能
|
||||
GroupBotManager.local_cache["group_list"].add(group_id)
|
||||
r = self.db_manager.get_redis_connection()
|
||||
r.sadd("group:list", group_id)
|
||||
|
||||
# 设置ROBOT功能为启用状态
|
||||
GroupBotManager.set_group_permission(group_id, Feature.ROBOT, PermissionStatus.ENABLED)
|
||||
|
||||
# 获取群组名称(如果可能)
|
||||
group_name = self.contact_manager.get_nickname(group_id)
|
||||
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"message": f"群组 {group_id} 已成功添加",
|
||||
"group": {
|
||||
"group_id": group_id,
|
||||
"group_name": group_name,
|
||||
"robot_status": "enabled"
|
||||
}
|
||||
})
|
||||
except Exception as e:
|
||||
self.logger.error(f"添加群组失败: {e}")
|
||||
return jsonify({"success": False, "error": str(e)}), 500
|
||||
|
||||
@app.route('/api/plugin_stats')
|
||||
def api_plugin_stats():
|
||||
days = request.args.get('days', 7, type=int)
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
<el-card shadow="hover">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>群机器人管理</span>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
style="float: right; margin-left: 10px;"
|
||||
@click="showAddGroupDialog">
|
||||
添加群组
|
||||
</el-button>
|
||||
<el-input
|
||||
placeholder="搜索群组..."
|
||||
v-model="searchQuery"
|
||||
@@ -107,6 +114,22 @@
|
||||
<el-button @click="permissionDialogVisible = false">关闭</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 添加群组对话框 -->
|
||||
<el-dialog
|
||||
title="添加群组"
|
||||
:visible.sync="addGroupDialogVisible"
|
||||
width="30%">
|
||||
<el-form :model="addGroupForm" :rules="addGroupRules" ref="addGroupForm">
|
||||
<el-form-item label="群组ID" prop="groupId">
|
||||
<el-input v-model="addGroupForm.groupId" placeholder="请输入群组ID"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="addGroupDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="submitAddGroup">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -123,7 +146,18 @@
|
||||
currentGroupName: '',
|
||||
searchQuery: '',
|
||||
selectedGroups: [],
|
||||
permissionDialogVisible: false
|
||||
permissionDialogVisible: false,
|
||||
// 添加群组相关数据
|
||||
addGroupDialogVisible: false,
|
||||
addGroupForm: {
|
||||
groupId: ''
|
||||
},
|
||||
addGroupRules: {
|
||||
groupId: [
|
||||
{ required: true, message: '请输入群组ID', trigger: 'blur' },
|
||||
{ pattern: /^\S+$/, message: '群组ID不能包含空格', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -237,6 +271,38 @@
|
||||
this.$message.error('更新权限失败: ' + error.message);
|
||||
});
|
||||
},
|
||||
// 显示添加群组对话框
|
||||
showAddGroupDialog() {
|
||||
this.addGroupForm.groupId = '';
|
||||
this.addGroupDialogVisible = true;
|
||||
},
|
||||
|
||||
// 提交添加群组
|
||||
submitAddGroup() {
|
||||
this.$refs.addGroupForm.validate((valid) => {
|
||||
if (valid) {
|
||||
axios.post('/api/robot/add_group', {
|
||||
group_id: this.addGroupForm.groupId
|
||||
})
|
||||
.then(response => {
|
||||
if (response.data.success) {
|
||||
this.$message.success(response.data.message);
|
||||
// 添加新群组到列表
|
||||
if (response.data.group) {
|
||||
this.groups.push(response.data.group);
|
||||
}
|
||||
this.addGroupDialogVisible = false;
|
||||
} else {
|
||||
this.$message.error(response.data.error || '添加失败');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('添加群组失败:', error);
|
||||
this.$message.error('添加群组失败: ' + (error.response?.data?.error || error.message));
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
enableAllPermissions() {
|
||||
this.$confirm('确定要启用所有功能吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
@@ -419,4 +485,4 @@
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user