This commit closes #28

This commit is contained in:
Profitroll 2023-03-26 19:32:07 +02:00
parent fd992e89e7
commit 5c55af9e65
3 changed files with 60 additions and 43 deletions

3
app.py
View File

@ -4,6 +4,7 @@ from modules.logging import logWrite
from modules.utils import configGet, jsonLoad from modules.utils import configGet, jsonLoad
from pyrogram.client import Client from pyrogram.client import Client
from pyrogram.errors import bad_request_400 from pyrogram.errors import bad_request_400
from convopyro import Conversation
app = Client( app = Client(
"holochecker", "holochecker",
@ -12,6 +13,8 @@ app = Client(
api_hash=configGet("api_hash", "bot"), api_hash=configGet("api_hash", "bot"),
) )
Conversation(app)
async def isAnAdmin(admin_id): async def isAnAdmin(admin_id):
# Check if user is mentioned in config # Check if user is mentioned in config

View File

@ -1,26 +1,28 @@
from app import app from app import app, isAnAdmin
from pyrogram import filters from pyrogram import filters
from pyrogram.types import Message from pyrogram.types import Message
from pyrogram.client import Client from pyrogram.client import Client
from convopyro import listen_message
from classes.errors.holo_user import UserInvalidError from classes.errors.holo_user import UserInvalidError
from classes.holo_user import HoloUser from classes.holo_user import HoloUser
from modules.utils import logWrite, locale, should_quote, find_user from modules.utils import configGet, logWrite, locale, should_quote, find_user
from modules import custom_filters from modules import custom_filters
from modules.database import col_messages
@app.on_message( @app.on_message(
custom_filters.enabled_general custom_filters.enabled_general
& ~filters.scheduled & ~filters.scheduled
& filters.command(["message"], prefixes=["/"]) & filters.command(["message"], prefixes=["/"])
& custom_filters.admin # & custom_filters.admin
) )
async def cmd_message(app: Client, msg: Message): async def cmd_message(app: Client, msg: Message):
try: try:
if await isAnAdmin(msg.from_user.id):
try: try:
destination = HoloUser(int(msg.command[1])) destination = HoloUser(int(msg.command[1]))
except (ValueError, UserInvalidError): except (ValueError, UserInvalidError):
destination = HoloUser(await find_user(app, query=msg.command[1])) destination = HoloUser(await find_user(app, query=msg.command[1]))
if (msg.text is not None) and (len(str(msg.text).split()) > 2): if (msg.text is not None) and (len(str(msg.text).split()) > 2):
await destination.message( await destination.message(
context=msg, context=msg,
@ -57,6 +59,17 @@ async def cmd_message(app: Client, msg: Message):
animation=msg.animation, animation=msg.animation,
adm_context=True, adm_context=True,
) )
else:
message = await listen_message(app, msg.chat.id, timeout=None)
sent = await app.forward_messages(
configGet("admin", "groups"), msg.chat.id, message.id
)
col_messages.insert_one(
{
"origin": {"chat": message.chat.id, "id": message.id},
"destination": {"chat": sent.chat.id, "id": sent.id},
}
)
except IndexError: except IndexError:
await msg.reply_text( await msg.reply_text(

View File

@ -10,3 +10,4 @@ starlette==0.26.1
ujson~=5.7.0 ujson~=5.7.0
ftfy~=6.1.1 ftfy~=6.1.1
xmltodict==0.13.0 xmltodict==0.13.0
convopyro==0.5