This commit closes #28
This commit is contained in:
parent
fd992e89e7
commit
5c55af9e65
3
app.py
3
app.py
@ -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
|
||||
|
@ -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:
|
||||
|
@ -9,4 +9,5 @@ python_dateutil==2.8.2
|
||||
starlette==0.26.1
|
||||
ujson~=5.7.0
|
||||
ftfy~=6.1.1
|
||||
xmltodict==0.13.0
|
||||
xmltodict==0.13.0
|
||||
convopyro==0.5
|
Reference in New Issue
Block a user