Data export, warnings' improvements, bug fixes #35

Merged
profitroll merged 30 commits from dev into master 2023-04-02 23:27:31 +03:00
3 changed files with 60 additions and 43 deletions
Showing only changes of commit 5c55af9e65 - Show all commits

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,61 +1,74 @@
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:
try: if await isAnAdmin(msg.from_user.id):
destination = HoloUser(int(msg.command[1])) try:
except (ValueError, UserInvalidError): destination = HoloUser(int(msg.command[1]))
destination = HoloUser(await find_user(app, query=msg.command[1])) except (ValueError, UserInvalidError):
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,
text=" ".join(str(msg.text).split()[2:]), text=" ".join(str(msg.text).split()[2:]),
caption=msg.caption, caption=msg.caption,
photo=msg.photo, photo=msg.photo,
video=msg.video, video=msg.video,
file=msg.document, file=msg.document,
voice=msg.voice, voice=msg.voice,
animation=msg.animation, animation=msg.animation,
adm_context=True, adm_context=True,
) )
elif (msg.caption is not None) and (len(msg.caption.split()) > 2): elif (msg.caption is not None) and (len(msg.caption.split()) > 2):
await destination.message( await destination.message(
context=msg, context=msg,
text=str(msg.text), text=str(msg.text),
caption=" ".join(msg.caption.split()[2:]), caption=" ".join(msg.caption.split()[2:]),
photo=msg.photo, photo=msg.photo,
video=msg.video, video=msg.video,
file=msg.document, file=msg.document,
voice=msg.voice, voice=msg.voice,
animation=msg.animation, animation=msg.animation,
adm_context=True, adm_context=True,
) )
else:
await destination.message(
context=msg,
text=None,
caption=None,
photo=msg.photo,
video=msg.video,
file=msg.document,
voice=msg.voice,
animation=msg.animation,
adm_context=True,
)
else: else:
await destination.message( message = await listen_message(app, msg.chat.id, timeout=None)
context=msg, sent = await app.forward_messages(
text=None, configGet("admin", "groups"), msg.chat.id, message.id
caption=None, )
photo=msg.photo, col_messages.insert_one(
video=msg.video, {
file=msg.document, "origin": {"chat": message.chat.id, "id": message.id},
voice=msg.voice, "destination": {"chat": sent.chat.id, "id": sent.id},
animation=msg.animation, }
adm_context=True,
) )
except IndexError: except IndexError:

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