29 lines
1.8 KiB
Python
29 lines
1.8 KiB
Python
from app import app, isAnAdmin
|
|
from pyrogram import filters
|
|
from pyrogram.errors import bad_request_400
|
|
from modules.utils import logWrite, locale, configGet, should_quote
|
|
|
|
# Message command ==============================================================================================================
|
|
@app.on_message(~ filters.scheduled & filters.command(["message"], prefixes=["/"]))
|
|
async def cmd_message(app, msg):
|
|
|
|
if msg.chat.id == configGet("admin_group") or await isAnAdmin(msg.from_user.id):
|
|
|
|
try:
|
|
destination = int(msg.command[1])
|
|
void = msg.command[2]
|
|
message = " ".join(msg.command[2:])
|
|
try:
|
|
await app.send_message(destination, message)
|
|
await msg.reply_text(locale("message_sent", "message"), quote=should_quote(msg))
|
|
logWrite(f"Admin {msg.from_user.id} sent message '{' '.join(msg.command[2:])}' to {destination}")
|
|
except bad_request_400.PeerIdInvalid:
|
|
await msg.reply_text(locale("message_no_user", "message"), quote=should_quote(msg))
|
|
logWrite(f"Admin {msg.from_user.id} tried to send message '{' '.join(msg.command[2:])}' to {destination} but 'PeerIdInvalid'")
|
|
except IndexError:
|
|
await msg.reply_text(locale("message_invalid_syntax", "message"), quote=should_quote(msg))
|
|
logWrite(f"Admin {msg.from_user.id} tried to send message but 'IndexError'")
|
|
except ValueError:
|
|
await msg.reply_text(locale("message_invalid_syntax", "message"), quote=should_quote(msg))
|
|
logWrite(f"Admin {msg.from_user.id} tried to send message but 'ValueError'")
|
|
# ============================================================================================================================== |