Commit 9150eab

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-03-08 16:35:00
fix: remove unnecessary `ENABLE` config
function control has been done in the `permission.py`
1 parent 3dc371c
src/asr/voice_recognition.py
@@ -9,7 +9,7 @@ from pyrogram.client import Client
 from pyrogram.types import Message
 
 from asr.tecent_asr import Credential, FlashRecognitionRequest, FlashRecognizer
-from config import ASR_MAX_DURATION, CAPTION_LENGTH, ENABLE, PREFIX, TOKEN, cache
+from config import ASR_MAX_DURATION, CAPTION_LENGTH, PREFIX, TOKEN, cache
 from messages.parser import parse_msg
 from messages.progress import modify_progress
 from messages.sender import send2tg, send_texts
@@ -197,8 +197,6 @@ def get_trigger_message(
     By default, "/asr" prefix is needed in in Group & Channel & Bot chats to trigger this function.
     In private chat, no need to add "/asr" prefix for voice message, but the video & audio message still need it.
     """
-    if not ENABLE.ASR:
-        return None
     info = parse_msg(message)
     this_text = info["text"]  # this message
     if info["ctype"].lower() in ["group", "supergroup", "channel", "bot"]:
src/bridge/ocr.py
@@ -7,7 +7,7 @@ from loguru import logger
 from pyrogram.client import Client
 from pyrogram.types import Message, ReplyParameters
 
-from config import ENABLE, PREFIX, cache
+from config import PREFIX, cache
 from messages.parser import parse_msg
 from messages.sender import send2tg
 from messages.utils import equal_prefix, startswith_prefix
@@ -28,8 +28,6 @@ async def send_to_ocr_bridge(client: Client, message: Message, **kwargs):
                                             If set to 0, reply to the trigger message itself.
                                             If set to -1, do not send as a reply message.
     """
-    if not ENABLE.OCR:
-        return
     # send docs if message == "/ocr", without reply
     if equal_prefix(message.text, prefix=[PREFIX.OCR]) and not message.reply_to_message:
         await send2tg(client, message, texts=f"**图片转文字**: 以`{PREFIX.OCR}`回复图片消息即可提取文字", **kwargs)
src/llm/gpt.py
@@ -5,7 +5,7 @@ from loguru import logger
 from pyrogram.client import Client
 from pyrogram.types import Message
 
-from config import ENABLE, GPT, PREFIX, cache
+from config import GPT, PREFIX, cache
 from llm.contexts import get_conversation_contexts, get_conversations
 from llm.models import get_model_config_with_contexts, get_model_type
 from llm.response import merge_tools_response, send_to_gpt
@@ -54,8 +54,6 @@ async def gpt_response(client: Client, message: Message, **kwargs):
         message (Message): The trigger message object.
     """
     # ruff: noqa: RET502, RET503
-    if not ENABLE.GPT:
-        return
     info = parse_msg(message)
     # send docs if message == "/ai", without reply
     if equal_prefix(info["text"], prefix=[PREFIX.GPT, "/gpt", "/gemini", "/ds"]) and not message.reply_to_message:
src/llm/summary.py
@@ -7,7 +7,7 @@ from zoneinfo import ZoneInfo
 from pyrogram.client import Client
 from pyrogram.types import Message
 
-from config import ENABLE, GPT, MAX_MESSAGE_SUMMARY, PREFIX, TZ, cache
+from config import GPT, MAX_MESSAGE_SUMMARY, PREFIX, TZ, cache
 from llm.models import get_model_config_with_contexts
 from llm.prompts import refine_prompts
 from llm.response import send_to_gpt
@@ -61,8 +61,6 @@ async def ai_summary(client: Client, message: Message, **kwargs):
         client (Client): The Pyrogram client.
         message (Message): The trigger message object.
     """
-    if not ENABLE.AI_SUMMARY:
-        return
     # send docs if message == "/summary"
     if equal_prefix(message.text, prefix=[PREFIX.AI_SUMMARY]):
         await send2tg(client, message, texts=HELP, **kwargs)
src/others/combine_history.py
@@ -6,7 +6,7 @@ import re
 from pyrogram.client import Client
 from pyrogram.types import Message
 
-from config import ENABLE, MAX_MESSAGE_RETRIEVED, PREFIX, READING_SPEED
+from config import MAX_MESSAGE_RETRIEVED, PREFIX, READING_SPEED
 from llm.utils import count_tokens
 from messages.chat_history import get_parsed_chat_history
 from messages.parser import parse_msg
@@ -36,8 +36,6 @@ HELP = f"""
 
 async def combine_history(client: Client, message: Message, **kwargs):
     """Download the url from the message."""
-    if not ENABLE.COMBINATION:
-        return
     if not startswith_prefix(message.text, prefix=[PREFIX.COMBINATION]):
         return
     # send docs if message == "/combine", without reply
src/others/download_external.py
@@ -10,7 +10,7 @@ from loguru import logger
 from pyrogram.client import Client
 from pyrogram.types import Message
 
-from config import ENABLE, MAX_FILE_BYTES, PREFIX
+from config import MAX_FILE_BYTES, PREFIX
 from messages.parser import parse_msg
 from messages.progress import modify_progress
 from messages.sender import send2tg
@@ -29,8 +29,6 @@ HELP = f"""
 
 async def download_url_in_message(client: Client, message: Message, **kwargs):
     """Download the url from the message."""
-    if not ENABLE.WGET:
-        return
     info = parse_msg(message)
     if not startswith_prefix(info["text"], prefix=[PREFIX.WGET]):
         return
src/others/extract_audio.py
@@ -6,7 +6,7 @@ from loguru import logger
 from pyrogram.client import Client
 from pyrogram.types import Message
 
-from config import ENABLE, PREFIX, cache
+from config import PREFIX, cache
 from messages.parser import parse_msg
 from messages.progress import modify_progress
 from messages.sender import send2tg
@@ -27,8 +27,6 @@ HELP = f"""
 @cache.memoize(ttl=60)
 async def extract_audio_file(client: Client, message: Message, **kwargs) -> None:
     """Extract audio from video message."""
-    if not ENABLE.AUDIO:
-        return
     # send docs if message == "/audio", without reply
     if equal_prefix(message.text, prefix=[PREFIX.AUDIO]) and not message.reply_to_message:
         await send2tg(client, message, texts=HELP, **kwargs)
src/others/raw_img_file.py
@@ -6,15 +6,12 @@ from loguru import logger
 from pyrogram.client import Client
 from pyrogram.types import Message
 
-from config import ENABLE
 from messages.parser import parse_msg
 from messages.sender import send2tg
 from multimedia import split_long_img
 
 
 async def convert_raw_img_file(client: Client, message: Message, **kwargs):
-    if not ENABLE.RAW_IMG_CONVERT:
-        return
     mime_type = message.document.mime_type if message.document else ""
     if mime_type not in ["image/png", "image/jpeg", "image/heic"]:
         return
src/others/subtitle.py
@@ -11,7 +11,7 @@ from pyrogram.client import Client
 from pyrogram.types import Message
 from youtube_transcript_api import YouTubeTranscriptApi
 
-from config import API, ENABLE, PREFIX, PROXY, TOKEN
+from config import API, PREFIX, PROXY, TOKEN
 from database import cache
 from llm.utils import count_tokens
 from messages.parser import parse_msg
@@ -33,8 +33,6 @@ HELP = f"""📃**提取字幕**
 @cache.memoize(ttl=30)
 async def get_subtitle(client: Client, message: Message, **kwargs):
     """Get YouTube Subtitle."""
-    if not ENABLE.SUBTITLE:
-        return
     target_chat = kwargs["target_chat"] if kwargs.get("target_chat") else message.chat.id
     # send docs if message == "/subtitle", without reply
     if equal_prefix(message.text, prefix=[PREFIX.SUBTITLE]) and not message.reply_to_message:
src/price/entrypoint.py
@@ -5,7 +5,7 @@ import re
 from pyrogram.client import Client
 from pyrogram.types import Message, ReplyParameters
 
-from config import ENABLE, PREFIX, TZ, cache
+from config import PREFIX, TZ, cache
 from messages.parser import parse_msg
 from messages.progress import modify_progress
 from messages.sender import send2tg
@@ -68,8 +68,6 @@ K线Interval (可选):
 @cache.memoize(ttl=60)
 async def get_asset_price(client: Client, message: Message, **kwargs):
     """Get asset price."""
-    if not ENABLE.PRICE:
-        return
     info = parse_msg(message)
     # send docs if message == "/price"
     if equal_prefix(info["text"], prefix=[PREFIX.PRICE, PREFIX.CRYPTO, PREFIX.STOCK]):
@@ -148,8 +146,6 @@ async def get_asset_price(client: Client, message: Message, **kwargs):
 
 @cache.memoize(ttl=3600)
 async def match_symbol_category(symbol: str = "", *, crypto_only: bool = False, stock_only: bool = False) -> dict[str, str]:
-    if not ENABLE.PRICE:
-        return {}
     category = {}
     # Crypto market
     if not stock_only: