Commit 4847efa
Changed files (2)
src
others
src/others/alias.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+from pyrogram.types import Message
+from pyrogram.types.messages_and_media.message import Str
+
+from config import PREFIX
+
+
+def command_alias(message: Message) -> Message:
+ texts = message.content.lstrip()
+ # AI image generation
+ if texts.startswith("/flux"):
+ texts = texts.replace("/flux", f"{PREFIX.GENIMG} @flux")
+ elif texts.startswith("/sd"):
+ texts = texts.replace("/sd", f"{PREFIX.GENIMG} @doubao")
+ elif texts.startswith("/stable"):
+ texts = texts.replace("/stable", f"{PREFIX.GENIMG} @sd")
+ elif texts.startswith("/nano"):
+ texts = texts.replace("/nano", f"{PREFIX.GENIMG} @gemini")
+
+ if message.text:
+ message.text = Str(texts)
+ elif message.caption:
+ message.caption = Str(texts)
+ return message
src/handler.py
@@ -19,6 +19,7 @@ from messages.parser import parse_msg
from messages.sender import send2tg
from messages.utils import delete_message, equal_prefix, startswith_prefix
from networking import match_social_media_link
+from others.alias import command_alias
from others.convert_chinese import chinese_conversion
from others.download_external import download_url_in_message
from others.extract_audio import extract_audio_file
@@ -116,6 +117,7 @@ async def handle_utilities(
detail_progress (bool, optional): Show detailed progress (Only if show_proress is set to True). Defaults to False.
"""
kwargs |= {"target_chat": target_chat, "reply_msg_id": reply_msg_id, "show_progress": show_progress, "detail_progress": detail_progress}
+ message = command_alias(message)
info = parse_msg(message)
kwargs |= params_from_msg_text(info["text"]) # merge the parameters from the message text
if ai: