Messenger is ready

This commit is contained in:
2022-12-13 14:24:31 +01:00
parent bf7c23bb34
commit a54d78ccb6
5 changed files with 136 additions and 26 deletions

View File

@@ -4,6 +4,7 @@ from app import app, isAnAdmin
import asyncio
from pyrogram import filters
from pyrogram.types import ForceReply, ReplyKeyboardMarkup, Message
from classes.holo_user import HoloUser
from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite, should_quote
from modules.database import col_messages
@@ -20,20 +21,35 @@ async def message_context(msg: Message) -> tuple:
return 0, 0
# Any other input ==============================================================================================================
# @app.on_message(~ filters.scheduled & filters.private)
# async def any_stage(app, msg):
@app.on_message(~ filters.scheduled & filters.private)
async def any_stage(app, msg):
# if msg.via_bot is None:
if msg.via_bot is None:
# if (msg.reply_to_message != None) and (await message_involved(msg)):
# context = await message_context(msg)
# if msg.chat.id == configGet("admin_group") or await isAnAdmin(msg.from_user.id):
# new_message = await (await app.get_messages(context[0], context[1])).reply_text(msg.text+locale("message_reply_notice", "message"), quote=True)
# 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))
# col_messages.insert_one({"origin": {"chat": msg.chat.id, "id": msg.id}, "destination": {"chat": new_message.chat.id, "id": new_message.id}})
# return
if (msg.reply_to_message != None) and (await message_involved(msg)):
context = await message_context(msg)
context_message = await app.get_messages(context[0], context[1])
holo_user = HoloUser(msg.from_user)
destination_user = HoloUser(context_message.from_user)
await destination_user.message(
origin=context_message,
context=msg,
text=msg.text,
caption=msg.caption,
photo=msg.photo,
video=msg.video,
file=msg.document,
adm_origin=await isAnAdmin(context_message.from_user.id),
adm_context=await isAnAdmin(msg.from_user.id)
)
# await msg.reply_text(locale("message_sent", "message"), quote=should_quote(msg))
# 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))