5 Commits

Author SHA1 Message Date
Profitroll
0bf5ae70eb Improved inline query usage filters 2023-01-07 10:20:58 +01:00
Profitroll
bcaf80e2e1 Fixed reply_document() issue 2023-01-07 00:38:53 +01:00
Profitroll
21bf460b28 Fixes + improved logging 2023-01-07 00:38:35 +01:00
Profitroll
a4bbb837d7 Added delay for label setting 2023-01-06 21:27:47 +01:00
Profitroll
1a438fc32e Fixed api method 2023-01-06 21:27:32 +01:00
4 changed files with 28 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
from datetime import datetime
from asyncio import sleep
from traceback import format_exc
from app import app, isAnAdmin
from typing import Any, List, Literal, Union
@@ -123,11 +124,11 @@ class HoloUser():
# Check if any text available and log message sending
if text is not None:
logWrite(f"{context.from_user.id} sent message '{text}' to {self.id}")
logWrite(f"{context.from_user.id} sent message '{text}' to {self.id} (source message: {context.id})")
elif caption is not None:
logWrite(f"{context.from_user.id} sent message '{caption}' to {self.id}")
logWrite(f"{context.from_user.id} sent message '{caption}' to {self.id} (source message: {context.id})")
else:
logWrite(f"{context.from_user.id} sent message to {self.id}")
logWrite(f"{context.from_user.id} sent message to {self.id} (source message: {context.id})")
# Add notices for admin or user
if text is not None:
@@ -164,7 +165,7 @@ class HoloUser():
elif file is not None:
if isinstance(file, Document):
file = file.file_id
new_message = await origin.reply_document(file, caption=caption, quote=True)
new_message = await origin.reply_cached_media(file, caption=caption, quote=True)
elif animation is not None:
if isinstance(animation, Animation):
animation = animation.file_id
@@ -189,7 +190,7 @@ class HoloUser():
elif file is not None:
if isinstance(file, Document):
file = file.file_id
new_message = await app.send_document(self.id, file, caption=caption)
new_message = await app.send_cached_media(self.id, file, caption=caption)
elif animation is not None:
if isinstance(animation, Animation):
animation = animation.file_id
@@ -227,6 +228,7 @@ class HoloUser():
try:
await app.promote_chat_member(configGet("users", "groups"), self.id, privileges=ChatPrivileges(can_pin_messages=True, can_manage_video_chats=True))
if not await isAnAdmin(self.id):
await sleep(0.5)
await app.set_administrator_title(configGet("users", "groups"), self.id, label)
self.set("label", label)
except Exception as exp:

View File

@@ -33,13 +33,13 @@ async def cmd_start(app: Client, msg: Message):
try:
spoiler = col_spoilers.find_one( {"_id": ObjectId(msg.command[1])} )
if spoiler["photo"] is not None:
await msg.reply_document(spoiler["photo"], caption=spoiler["caption"])
await msg.reply_cached_media(spoiler["photo"], caption=spoiler["caption"])
if spoiler["video"] is not None:
await msg.reply_cached_media(spoiler["video"], caption=spoiler["caption"])
if spoiler["animation"] is not None:
await msg.reply_cached_media(spoiler["animation"], caption=spoiler["caption"])
if spoiler["document"] is not None:
await msg.reply_document(spoiler["document"], caption=spoiler["caption"])
await msg.reply_cached_media(spoiler["document"], caption=spoiler["caption"])
if spoiler["text"] is not None:
await msg.reply_text(spoiler["text"])
except InvalidId:

View File

@@ -117,7 +117,7 @@ async def confirm_yes(app: Client, msg: Message, kind: Literal["application", "s
else:
sponsorship_content.append(f"{locale(f'question_{question}', 'message', 'sponsor_titles')} {tmp_sponsorship['sponsorship'][question]}")
await app.send_cached_media(chat_id=configGet("admin", "groups"), photo=tmp_sponsorship["sponsorship"]["proof"], caption=(locale("sponsor_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(sponsorship_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(
await app.send_cached_media(configGet("admin", "groups"), tmp_sponsorship["sponsorship"]["proof"], caption=(locale("sponsor_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(sponsorship_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton(text=str(locale("sponsor_yes", "button")), callback_data=f"sponsor_yes_{holo_user.id}")

View File

@@ -11,7 +11,7 @@ from pyrogram.enums.chat_members_filter import ChatMembersFilter
from dateutil.relativedelta import relativedelta
from classes.errors.holo_user import UserNotFoundError, UserInvalidError
from classes.holo_user import HoloUser
from modules.utils import configGet, locale
from modules.utils import configGet, jsonLoad, locale
from modules.database import col_applications, col_spoilers
from bson.objectid import ObjectId
from bson.errors import InvalidId
@@ -64,19 +64,27 @@ async def inline_answer(client: Client, inline_query: InlineQuery):
)
return
results_forbidden = [
InlineQueryResultArticle(
title=locale("title", "inline", "forbidden", locale=inline_query.from_user),
input_message_content=InputTextMessageContent(
locale("message_content", "inline", "forbidden", locale=inline_query.from_user)
),
description=locale("description", "inline", "forbidden", locale=inline_query.from_user)
)
]
try:
holo_user = HoloUser(inline_query.from_user)
except (UserNotFoundError, UserInvalidError):
await inline_query.answer(
results=[
InlineQueryResultArticle(
title=locale("title", "inline", "forbidden", locale=inline_query.from_user),
input_message_content=InputTextMessageContent(
locale("message_content", "inline", "forbidden", locale=inline_query.from_user)
),
description=locale("description", "inline", "forbidden", locale=inline_query.from_user)
)
]
results=results_forbidden
)
return
if path.exists(path.join(configGet("cache", "locations"), "group_members")) and (inline_query.from_user.id not in jsonLoad(path.join(configGet("cache", "locations"), "group_members"))):
await inline_query.answer(
results=results_forbidden
)
return