动态auth完成。
This commit is contained in:
21
robot.py
21
robot.py
@@ -1,33 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import time
|
||||
import asyncio
|
||||
import threading
|
||||
import time
|
||||
import tomllib
|
||||
import toml
|
||||
|
||||
import wechat_ipad
|
||||
import toml
|
||||
from loguru import logger
|
||||
|
||||
import wechat_ipad
|
||||
from base.func_epic import is_friday, get_free
|
||||
from base.func_news import News
|
||||
from configuration import Config
|
||||
from base.plugin_common.event_system import EventType, EventSystem
|
||||
from base.plugin_common.message_plugin_interface import MessagePluginInterface
|
||||
from base.plugin_common.plugin_interface import PluginStatus
|
||||
from base.plugin_common.plugin_manager import PluginManager
|
||||
from base.plugin_common.plugin_registry import PluginRegistry
|
||||
from utils.sehuatang.shehuatang import pdf_file_path
|
||||
from configuration import Config
|
||||
from db.connection import DBConnectionManager
|
||||
from db.contacts_db import ContactsDBOperator
|
||||
from plugins.xiuren_image.meitu_dl import meitu_dowload_pub_pic
|
||||
from utils.email_util import EmailSender
|
||||
from utils.revoke.message_auto_revoke import MessageAutoRevoke
|
||||
from utils.robot_cmd.robot_command import GroupBotManager, Feature, PermissionStatus
|
||||
|
||||
from db.connection import DBConnectionManager
|
||||
from db.contacts_db import ContactsDBOperator
|
||||
from utils.sehuatang.shehuatang import pdf_file_path
|
||||
from utils.wechat.contact_manager import ContactManager
|
||||
from utils.wechat.message_to_db import MessageStorage
|
||||
from wechat_ipad import WechatAPIClient
|
||||
from wechat_ipad.models.message import WxMessage, MessageType
|
||||
from plugins.xiuren_image.meitu_dl import meitu_dowload_pub_pic
|
||||
|
||||
|
||||
class Robot:
|
||||
@@ -685,8 +684,10 @@ class Robot:
|
||||
receivers = self.gbm.get_group_list()
|
||||
if not receivers:
|
||||
return
|
||||
|
||||
feature = getattr(Feature, "DAILY_SUMMARY", None)
|
||||
for r in receivers:
|
||||
if self.gbm.get_group_permission(r, Feature.DAILY_SUMMARY) == PermissionStatus.ENABLED:
|
||||
if self.gbm.get_group_permission(r, feature) == PermissionStatus.ENABLED:
|
||||
output = await self.message_storage.generate_and_send_ranking(r, self.allContacts)
|
||||
await self.ipad_bot.send_text_message(r, output)
|
||||
except Exception as e:
|
||||
|
||||
@@ -27,12 +27,13 @@ class PermissionStatus(Enum):
|
||||
class Feature(Enum):
|
||||
"""功能权限枚举,带序号"""
|
||||
ROBOT = 1, "🔧 群机器人 [总开关]"
|
||||
# DAILY_NEWS = 2, "📰 每日新闻自动播报 [每日8:30定时发送]"
|
||||
DAILY_NEWS = 2, "📰 每日新闻自动播报 [每日8:30定时发送]"
|
||||
PDF_CAPABILITY = 3, "📄 sehuatang PDF能力 [无]"
|
||||
EPIC = 4, "📊 EPIC自动播报 [每周五自动发送]" # 新增的功能
|
||||
|
||||
# DAILY_SUMMARY = 3, "🕤 每日群发言总结 [每日9:30定时发送]"
|
||||
# AI_CAPABILITY = 4, "🤖 AI对话 [ai, 聊天, AI] 用法:ai 如何写一个机器人?"
|
||||
# SUMMARY_CAPABILITY = 5, "📝 群总结能力 [#总结]"
|
||||
# PDF_CAPABILITY = 6, "📄 sehuatang PDF能力 [无]"
|
||||
# EPIC = 7, "📊 EPIC自动播报 [每周五自动发送]" # 新增的功能
|
||||
# PIC = 8, "🖼️ 图来能力 [图来, 秀人]"
|
||||
# TASK_GAME = 9, "📚 百科答题 [/t, /s, /a 任务ID 答案]"
|
||||
# MUSIC = 10, "🎵 点歌功能 [点歌, 音乐, 音乐点播, 点播音乐, 音乐点歌]"
|
||||
@@ -99,10 +100,10 @@ class Feature(Enum):
|
||||
@classmethod
|
||||
def get_feature(cls, key: str) -> 'Feature':
|
||||
"""获取已注册的功能
|
||||
|
||||
|
||||
Args:
|
||||
key: 功能键名
|
||||
|
||||
|
||||
Returns:
|
||||
Feature: 功能枚举实例
|
||||
"""
|
||||
@@ -111,7 +112,7 @@ class Feature(Enum):
|
||||
@classmethod
|
||||
def get_all_features(cls) -> List['Feature']:
|
||||
"""获取所有功能
|
||||
|
||||
|
||||
Returns:
|
||||
List[Feature]: 所有功能列表
|
||||
"""
|
||||
@@ -365,7 +366,7 @@ if __name__ == '__main__':
|
||||
print(f"最大VALUE:{Feature.get_max_value()}")
|
||||
# 测试注册新功能
|
||||
print("\n注册新功能...")
|
||||
new_feature = Feature.register_feature("TEST_FEATURE", "🧪 测试功能 [测试]")
|
||||
new_feature = Feature.register_feature("TEST_FEATURE", "🧪 测试功能 [测试]")
|
||||
print(f"新功能: {new_feature.name} = {new_feature.value} - {new_feature.description}")
|
||||
|
||||
# 验证新功能是否添加成功
|
||||
|
||||
Reference in New Issue
Block a user