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 pyrogram.client import Client
from pyrogram.errors import bad_request_400
from convopyro import Conversation
app = Client(
"holochecker",
@ -12,6 +13,8 @@ app = Client(
api_hash=configGet("api_hash", "bot"),
)
Conversation(app)
async def isAnAdmin(admin_id):
# 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.types import Message
from pyrogram.client import Client
from convopyro import listen_message
from classes.errors.holo_user import UserInvalidError
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.database import col_messages
@app.on_message(
custom_filters.enabled_general
& ~filters.scheduled
& filters.command(["message"], prefixes=["/"])
& custom_filters.admin
# & custom_filters.admin
)
async def cmd_message(app: Client, msg: Message):
try:
if await isAnAdmin(msg.from_user.id):
try:
destination = HoloUser(int(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):
await destination.message(
context=msg,
@ -57,6 +59,17 @@ async def cmd_message(app: Client, msg: Message):
animation=msg.animation,
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:
await msg.reply_text(

View File

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