Compare commits

..

2 Commits

Author SHA1 Message Date
5c55af9e65 This commit closes #28 2023-03-26 19:32:07 +02:00
fd992e89e7 Bump fastapi to 0.95.0 and starlette to 0.26.1 2023-03-26 19:09:45 +02:00
3 changed files with 63 additions and 46 deletions

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,61 +1,74 @@
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:
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,
text=" ".join(str(msg.text).split()[2:]),
caption=msg.caption,
photo=msg.photo,
video=msg.video,
file=msg.document,
voice=msg.voice,
animation=msg.animation,
adm_context=True,
)
elif (msg.caption is not None) and (len(msg.caption.split()) > 2):
await destination.message(
context=msg,
text=str(msg.text),
caption=" ".join(msg.caption.split()[2:]),
photo=msg.photo,
video=msg.video,
file=msg.document,
voice=msg.voice,
animation=msg.animation,
adm_context=True,
)
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,
text=" ".join(str(msg.text).split()[2:]),
caption=msg.caption,
photo=msg.photo,
video=msg.video,
file=msg.document,
voice=msg.voice,
animation=msg.animation,
adm_context=True,
)
elif (msg.caption is not None) and (len(msg.caption.split()) > 2):
await destination.message(
context=msg,
text=str(msg.text),
caption=" ".join(msg.caption.split()[2:]),
photo=msg.photo,
video=msg.video,
file=msg.document,
voice=msg.voice,
animation=msg.animation,
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:
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,
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:

View File

@@ -1,12 +1,13 @@
APScheduler==3.10.1
fastapi~=0.88.0
APScheduler~=3.10.1
fastapi~=0.95.0
psutil==5.9.4
pymongo==4.3.3
Pyrogram~=2.0.102
requests==2.28.2
tgcrypto==1.2.5
python_dateutil==2.8.2
starlette~=0.22.0
starlette==0.26.1
ujson~=5.7.0
ftfy~=6.1.1
xmltodict~=0.13.0
xmltodict==0.13.0
convopyro==0.5