Messages command updated
This commit is contained in:
@@ -5,19 +5,19 @@ import asyncio
|
||||
from pyrogram import filters
|
||||
from pyrogram.types import ForceReply, ReplyKeyboardMarkup, Message
|
||||
from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite, should_quote
|
||||
from modules.database import col_messages
|
||||
|
||||
async def message_involved(msg: Message):
|
||||
messages = jsonLoad(f"{configGet('data', 'locations')}{sep}messages.json")
|
||||
for message in messages:
|
||||
if (message["destination"]["id"] == msg.reply_to_message.id) and (message["destination"]["chat"] == msg.reply_to_message.chat.id):
|
||||
return True
|
||||
async def message_involved(msg: Message) -> bool:
|
||||
message = col_messages.find_one({"destination.id": msg.reply_to_message.id, "destination.chat": msg.reply_to_message.chat.id})
|
||||
if message is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
async def message_context(msg: Message):
|
||||
messages = jsonLoad(f"{configGet('data', 'locations')}{sep}messages.json")
|
||||
for message in messages:
|
||||
if (message["destination"]["id"] == msg.reply_to_message.id) and (message["destination"]["chat"] == msg.reply_to_message.chat.id):
|
||||
return message["origin"]["chat"], message["origin"]["id"]
|
||||
async def message_context(msg: Message) -> tuple:
|
||||
message = col_messages.find_one({"destination.id": msg.reply_to_message.id, "destination.chat": msg.reply_to_message.chat.id})
|
||||
if message is not None:
|
||||
return message["origin"]["chat"], message["origin"]["id"]
|
||||
return 0, 0
|
||||
|
||||
# Any other input ==============================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.private)
|
||||
@@ -32,9 +32,7 @@ async def any_stage(app, msg):
|
||||
else:
|
||||
new_message = await (await app.get_messages(context[0], context[1])).reply_text(locale("message_from", "message").format(msg.from_user.first_name, msg.from_user.id)+msg.text+locale("message_reply_notice", "message"), quote=True)
|
||||
await msg.reply_text(locale("message_sent", "message"), quote=should_quote(msg))
|
||||
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}})
|
||||
return
|
||||
|
||||
user_stage = configGet("stage", file=str(msg.from_user.id))
|
||||
|
Reference in New Issue
Block a user