Messages command updated

This commit is contained in:
Profitroll
2022-12-11 18:50:50 +01:00
parent 091c0abace
commit 03ebeafdd4
2 changed files with 13 additions and 16 deletions

View File

@@ -3,6 +3,7 @@ from app import app, isAnAdmin
from pyrogram import filters
from pyrogram.errors import bad_request_400
from modules.utils import jsonLoad, jsonSave, logWrite, locale, configGet, should_quote
from modules.database import col_messages
# Message command ==============================================================================================================
@app.on_message(~ filters.scheduled & filters.command(["message"], prefixes=["/"]))
@@ -35,9 +36,7 @@ async def cmd_message(app, msg):
new_message = await app.send_message(destination.id, message+locale("message_reply_notice", "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.id}")
messages = jsonLoad(f"{configGet('data', 'locations')}{sep}messages.json")
messages.append({"origin": {"chat": msg.chat.id, "id": msg.id}, "destination": {"chat": new_message.chat.id, "id": new_message.id}})
jsonSave(messages, f"{configGet('data', 'locations')}{sep}messages.json")
col_messages.insert_one({"origin": {"chat": msg.chat.id, "id": msg.id}, "destination": {"chat": new_message.chat.id, "id": new_message.id}})
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.id} but 'PeerIdInvalid'")