Changed config keys

This commit is contained in:
Profitroll 2023-01-04 19:14:02 +01:00
parent ccbc135ee4
commit d59a1671b3
19 changed files with 54 additions and 48 deletions

View File

@ -32,15 +32,16 @@ You can see config file with all the comments below:
"locale": "uk", "locale": "uk",
"debug": false, "debug": false,
"owner": 0, "owner": 0,
"bot_id": 0,
"age_allowed": 0, "age_allowed": 0,
"api": "http://example.com", "api": "http://example.com",
"inline_preview_count": 7, "inline_preview_count": 7,
"admin_group": 0,
"destination_group": 0,
"remove_application_time": -1, "remove_application_time": -1,
"search_radius": 50, "search_radius": 50,
"admins": [], "admins": [],
"groups": {
"admin": 0,
"users": 0
},
"bot": { "bot": {
"api_id": 0, "api_id": 0,
"api_hash": "", "api_hash": "",
@ -61,6 +62,9 @@ You can see config file with all the comments below:
"location": "logs" "location": "logs"
}, },
"features": { "features": {
"general": {
"enabled": true
},
"applications": { "applications": {
"enabled": true "enabled": true
}, },

2
app.py
View File

@ -22,7 +22,7 @@ async def isAnAdmin(admin_id):
# Check if user is in admin group # Check if user is in admin group
try: try:
async for member in app.get_chat_members(configGet("admin_group")): async for member in app.get_chat_members(configGet("admin", "groups")):
if member.user.id == admin_id: if member.user.id == admin_id:
return True return True
except bad_request_400.ChannelInvalid: except bad_request_400.ChannelInvalid:

View File

@ -284,9 +284,9 @@ class HoloUser():
raise LabelTooLongError(label) raise LabelTooLongError(label)
self.label = label self.label = label
try: try:
await app.promote_chat_member(configGet("destination_group"), self.id, privileges=ChatPrivileges(can_pin_messages=True, can_manage_video_chats=True)) await app.promote_chat_member(configGet("admin", "users"), self.id, privileges=ChatPrivileges(can_pin_messages=True, can_manage_video_chats=True))
if not await isAnAdmin(self.id): if not await isAnAdmin(self.id):
await app.set_administrator_title(configGet("destination_group"), self.id, label) await app.set_administrator_title(configGet("admin", "users"), self.id, label)
self.set("label", label) self.set("label", label)
except bad_request_400.UserCreator: except bad_request_400.UserCreator:
logWrite(f"Could not set {self.id}'s title to '{self.label}' because of bad_request_400.UserCreator") logWrite(f"Could not set {self.id}'s title to '{self.label}' because of bad_request_400.UserCreator")
@ -301,9 +301,9 @@ class HoloUser():
""" """
self.label = "" self.label = ""
self.set("label", "") self.set("label", "")
await app.set_administrator_title(configGet("destination_group"), self.id, "") await app.set_administrator_title(configGet("admin", "users"), self.id, "")
if not await isAnAdmin(self.id): if not await isAnAdmin(self.id):
await app.promote_chat_member(configGet("destination_group"), self.id, privileges=ChatPrivileges( await app.promote_chat_member(configGet("admin", "users"), self.id, privileges=ChatPrivileges(
can_manage_chat=False, can_manage_chat=False,
can_pin_messages=False, can_pin_messages=False,
can_manage_video_chats=False can_manage_video_chats=False

View File

@ -5,11 +5,13 @@
"age_allowed": 0, "age_allowed": 0,
"api": "http://example.com", "api": "http://example.com",
"inline_preview_count": 7, "inline_preview_count": 7,
"admin_group": 0,
"destination_group": 0,
"remove_application_time": -1, "remove_application_time": -1,
"search_radius": 50, "search_radius": 50,
"admins": [], "admins": [],
"groups": {
"admin": 0,
"users": 0
},
"bot": { "bot": {
"api_id": 0, "api_id": 0,
"api_hash": "", "api_hash": "",

View File

@ -16,7 +16,7 @@ async def callback_reapply_query_accept(app: Client, clb: CallbackQuery):
fullclb = clb.data.split("_") fullclb = clb.data.split("_")
holo_user = HoloUser(int(fullclb[2])) holo_user = HoloUser(int(fullclb[2]))
await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True) await app.send_message(configGet("admin", "groups"), locale("approved_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
logWrite(f"User {holo_user.id} got their reapplication approved by {clb.from_user.id}") logWrite(f"User {holo_user.id} got their reapplication approved by {clb.from_user.id}")
await app.send_message(holo_user.id, locale("approved_joined", "message", locale=holo_user)) await app.send_message(holo_user.id, locale("approved_joined", "message", locale=holo_user))
@ -32,12 +32,12 @@ async def callback_reapply_query_accept(app: Client, clb: CallbackQuery):
need_link = True need_link = True
async for member in app.get_chat_members(configGet("destination_group")): async for member in app.get_chat_members(configGet("admin", "users")):
if member.user.id == holo_user.id: if member.user.id == holo_user.id:
need_link = False need_link = False
if need_link: if need_link:
link = await app.create_chat_invite_link(configGet("destination_group"), name=f"Invite for {holo_user.id}", member_limit=1) #, expire_date=datetime.now()+timedelta(days=1)) link = await app.create_chat_invite_link(configGet("admin", "users"), name=f"Invite for {holo_user.id}", member_limit=1) #, expire_date=datetime.now()+timedelta(days=1))
await app.send_message(holo_user.id, locale("read_rules", "message", locale=holo_user)) await app.send_message(holo_user.id, locale("read_rules", "message", locale=holo_user))
@ -62,7 +62,7 @@ async def callback_query_reapply_reject(app: Client, clb: CallbackQuery):
fullclb = clb.data.split("_") fullclb = clb.data.split("_")
holo_user = HoloUser(int(fullclb[2])) holo_user = HoloUser(int(fullclb[2]))
await app.send_message(configGet("admin_group"), locale("rejected_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True) await app.send_message(configGet("admin", "groups"), locale("rejected_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True)
await app.send_message(holo_user.id, locale("rejected", "message", locale=holo_user)) await app.send_message(holo_user.id, locale("rejected", "message", locale=holo_user))
logWrite(f"User {fullclb[2]} got their reapplication rejected by {clb.from_user.id}") logWrite(f"User {fullclb[2]} got their reapplication rejected by {clb.from_user.id}")

View File

@ -34,7 +34,7 @@ async def callback_query_sponsor_yes(app: Client, clb: CallbackQuery):
fullclb = clb.data.split("_") fullclb = clb.data.split("_")
holo_user = HoloUser(int(fullclb[2])) holo_user = HoloUser(int(fullclb[2]))
await app.send_message(configGet("admin_group"), locale("sponsor_approved_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True) await app.send_message(configGet("admin", "groups"), locale("sponsor_approved_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
await app.send_message(holo_user.id, locale("sponsor_approved", "message", locale=holo_user)) await app.send_message(holo_user.id, locale("sponsor_approved", "message", locale=holo_user))
logWrite(f"User {holo_user.id} got sponsorship approved by {clb.from_user.id}") logWrite(f"User {holo_user.id} got sponsorship approved by {clb.from_user.id}")
@ -67,7 +67,7 @@ async def callback_query_sponsor_yes(app: Client, clb: CallbackQuery):
} }
) )
await holo_user.label_set(configGet("destination_group"), col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}})["sponsorship"]["label"]) await holo_user.label_set(configGet("admin", "users"), col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}})["sponsorship"]["label"])
edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]] edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]
@ -80,7 +80,7 @@ async def callback_query_sponsor_no(app: Client, clb: CallbackQuery):
fullclb = clb.data.split("_") fullclb = clb.data.split("_")
holo_user = HoloUser(int(fullclb[2])) holo_user = HoloUser(int(fullclb[2]))
await app.send_message(configGet("admin_group"), locale("sponsor_rejected_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True) await app.send_message(configGet("admin", "groups"), locale("sponsor_rejected_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
await app.send_message(holo_user.id, locale("sponsor_rejected", "message", locale=holo_user)) await app.send_message(holo_user.id, locale("sponsor_rejected", "message", locale=holo_user))
logWrite(f"User {holo_user.id} got sponsorship rejected by {clb.from_user.id}") logWrite(f"User {holo_user.id} got sponsorship rejected by {clb.from_user.id}")

View File

@ -15,17 +15,17 @@ async def callback_query_accept(app: Client, clb: CallbackQuery):
fullclb = clb.data.split("_") fullclb = clb.data.split("_")
holo_user = HoloUser(int(fullclb[2])) holo_user = HoloUser(int(fullclb[2]))
await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True) await app.send_message(configGet("admin", "groups"), locale("approved_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
logWrite(f"User {holo_user.id} got approved by {clb.from_user.id}") logWrite(f"User {holo_user.id} got approved by {clb.from_user.id}")
need_link = True need_link = True
async for member in app.get_chat_members(configGet("destination_group")): async for member in app.get_chat_members(configGet("admin", "users")):
if member.user.id == holo_user.id: if member.user.id == holo_user.id:
need_link = False need_link = False
if need_link: if need_link:
link = await app.create_chat_invite_link(configGet("destination_group"), name=f"Invite for {holo_user.id}", member_limit=1) #, expire_date=datetime.now()+timedelta(days=1)) link = await app.create_chat_invite_link(configGet("admin", "users"), name=f"Invite for {holo_user.id}", member_limit=1) #, expire_date=datetime.now()+timedelta(days=1))
await app.send_message(holo_user.id, locale("read_rules", "message", locale=holo_user)) await app.send_message(holo_user.id, locale("read_rules", "message", locale=holo_user))
@ -57,7 +57,7 @@ async def callback_query_reject(app: Client, clb: CallbackQuery):
fullclb = clb.data.split("_") fullclb = clb.data.split("_")
holo_user = HoloUser(int(fullclb[2])) holo_user = HoloUser(int(fullclb[2]))
await app.send_message(configGet("admin_group"), locale("rejected_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True) await app.send_message(configGet("admin", "groups"), locale("rejected_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
await app.send_message(holo_user.id, locale("rejected", "message", locale=holo_user)) await app.send_message(holo_user.id, locale("rejected", "message", locale=holo_user))
logWrite(f"User {holo_user.id} got rejected by {clb.from_user.id}") logWrite(f"User {holo_user.id} got rejected by {clb.from_user.id}")
@ -74,7 +74,7 @@ async def callback_query_reject_aggressive(app: Client, clb: CallbackQuery):
fullclb = clb.data.split("_") fullclb = clb.data.split("_")
holo_user = HoloUser(int(fullclb[2])) holo_user = HoloUser(int(fullclb[2]))
await app.send_message(configGet("admin_group"), locale("rejected_by_agr", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True) await app.send_message(configGet("admin", "groups"), locale("rejected_by_agr", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
await app.send_message(holo_user.id, locale("rejected_aggressive", "message", locale=holo_user)) await app.send_message(holo_user.id, locale("rejected_aggressive", "message", locale=holo_user))
logWrite(f"User {holo_user.id} got rejected by {clb.from_user.id} due to being aggressive") logWrite(f"User {holo_user.id} got rejected by {clb.from_user.id} due to being aggressive")
@ -91,7 +91,7 @@ async def callback_query_reject_russian(app: Client, clb: CallbackQuery):
fullclb = clb.data.split("_") fullclb = clb.data.split("_")
holo_user = HoloUser(int(fullclb[2])) holo_user = HoloUser(int(fullclb[2]))
await app.send_message(configGet("admin_group"), locale("rejected_by_rus", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True) await app.send_message(configGet("admin", "groups"), locale("rejected_by_rus", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
await app.send_message(holo_user.id, locale("rejected_russian", "message", locale=holo_user)) await app.send_message(holo_user.id, locale("rejected_russian", "message", locale=holo_user))
logWrite(f"User {holo_user.id} got rejected by {clb.from_user.id} due to being russian") logWrite(f"User {holo_user.id} got rejected by {clb.from_user.id} due to being russian")

View File

@ -13,7 +13,7 @@ async def callback_query_sus_allow(app: Client, clb: CallbackQuery):
fullclb = clb.data.split("_") fullclb = clb.data.split("_")
holo_user = HoloUser(int(fullclb[2])) holo_user = HoloUser(int(fullclb[2]))
await app.send_message(configGet("admin_group"), locale("sus_allowed_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True) await app.send_message(configGet("admin", "groups"), locale("sus_allowed_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
logWrite(f"User {holo_user.id} was allowed to join with another link by {clb.from_user.id}") logWrite(f"User {holo_user.id} was allowed to join with another link by {clb.from_user.id}")
edited_markup = [[InlineKeyboardButton(text=str(locale("sus_allowed", "button")), callback_data="nothing")]] edited_markup = [[InlineKeyboardButton(text=str(locale("sus_allowed", "button")), callback_data="nothing")]]
@ -21,7 +21,7 @@ async def callback_query_sus_allow(app: Client, clb: CallbackQuery):
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)) await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
await clb.answer(text=locale("sus_allowed", "callback", locale=clb.from_user).format(holo_user.id), show_alert=True) await clb.answer(text=locale("sus_allowed", "callback", locale=clb.from_user).format(holo_user.id), show_alert=True)
await app.restrict_chat_member(configGet("destination_group"), holo_user.id, permissions=ChatPermissions( await app.restrict_chat_member(configGet("admin", "users"), holo_user.id, permissions=ChatPermissions(
can_send_messages=True, can_send_messages=True,
can_send_media_messages=True, can_send_media_messages=True,
can_send_other_messages=True, can_send_other_messages=True,
@ -35,7 +35,7 @@ async def callback_query_sus_reject(app: Client, clb: CallbackQuery):
fullclb = clb.data.split("_") fullclb = clb.data.split("_")
holo_user = HoloUser(int(fullclb[2])) holo_user = HoloUser(int(fullclb[2]))
await app.send_message(configGet("admin_group"), locale("sus_rejected_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True) await app.send_message(configGet("admin", "groups"), locale("sus_rejected_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
logWrite(f"User {holo_user.id} was rejected to join with another link by {clb.from_user.id}") logWrite(f"User {holo_user.id} was rejected to join with another link by {clb.from_user.id}")
edited_markup = [[InlineKeyboardButton(text=str(locale("sus_rejected", "button")), callback_data="nothing")]] edited_markup = [[InlineKeyboardButton(text=str(locale("sus_rejected", "button")), callback_data="nothing")]]
@ -43,7 +43,7 @@ async def callback_query_sus_reject(app: Client, clb: CallbackQuery):
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)) await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
await clb.answer(text=locale("sus_rejected", "callback", locale=clb.from_user).format(holo_user.id), show_alert=True) await clb.answer(text=locale("sus_rejected", "callback", locale=clb.from_user).format(holo_user.id), show_alert=True)
await app.ban_chat_member(configGet("destination_group"), holo_user.id) await app.ban_chat_member(configGet("admin", "users"), holo_user.id)
col_tmp.update_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}}, {"$set": {"state": "rejected", "sent": False}}) col_tmp.update_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}}, {"$set": {"state": "rejected", "sent": False}})
# ============================================================================================================================== # ==============================================================================================================================

View File

@ -60,7 +60,7 @@ async def cmd_application(app: Client, msg: Message):
# user_id = int(msg.command[1]) # user_id = int(msg.command[1])
# else: # else:
# list_of_users = [] # list_of_users = []
# async for m in app.get_chat_members(configGet("destination_group"), filter=ChatMembersFilter.SEARCH, query=msg.command[1]): # async for m in app.get_chat_members(configGet("admin", "users"), filter=ChatMembersFilter.SEARCH, query=msg.command[1]):
# list_of_users.append(m) # list_of_users.append(m)
# user_id = list_of_users[0].user.id # user_id = list_of_users[0].user.id
# try: # try:

View File

@ -11,7 +11,7 @@ from modules.database import col_applications, col_users
from classes.errors.geo import PlaceNotFoundError from classes.errors.geo import PlaceNotFoundError
# Nearby command =============================================================================================================== # Nearby command ===============================================================================================================
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & (filters.private | (filters.chat(configGet("admin_group")) | filters.chat(configGet("destination_group")))) & filters.command(["nearby"], prefixes=["/"]) & (custom_filters.allowed | custom_filters.admin)) @app.on_message(custom_filters.enabled_applications & ~filters.scheduled & (filters.private | (filters.chat(configGet("admin", "groups")) | filters.chat(configGet("admin", "users")))) & filters.command(["nearby"], prefixes=["/"]) & (custom_filters.allowed | custom_filters.admin))
async def cmd_nearby(app: Client, msg: Message): async def cmd_nearby(app: Client, msg: Message):
holo_user = HoloUser(msg.from_user) holo_user = HoloUser(msg.from_user)

View File

@ -22,7 +22,7 @@ async def cmd_reapply(app: Client, msg: Message):
left_chat = True left_chat = True
async for member in app.get_chat_members(configGet("destination_group")): async for member in app.get_chat_members(configGet("admin", "users")):
if member.user.id == msg.from_user.id: if member.user.id == msg.from_user.id:
left_chat = False left_chat = False

View File

@ -11,7 +11,7 @@ from modules import custom_filters
@app.on_message(custom_filters.enabled_warnings & ~filters.scheduled & filters.command(["warn"], prefixes=["/"]) & custom_filters.admin) @app.on_message(custom_filters.enabled_warnings & ~filters.scheduled & filters.command(["warn"], prefixes=["/"]) & custom_filters.admin)
async def cmd_warn(app: Client, msg: Message): async def cmd_warn(app: Client, msg: Message):
if msg.chat.id == configGet("destination_group"): if msg.chat.id == configGet("admin", "users"):
if msg.reply_to_message_id != None: if msg.reply_to_message_id != None:
message = " ".join(msg.command[1:]) if len(msg.command) > 1 else "" message = " ".join(msg.command[1:]) if len(msg.command) > 1 else ""
col_warnings.insert_one({"user": msg.reply_to_message.from_user.id, "admin": msg.from_user.id, "date": datetime.now(), "reason": message}) col_warnings.insert_one({"user": msg.reply_to_message.from_user.id, "admin": msg.from_user.id, "date": datetime.now(), "reason": message})

View File

@ -21,7 +21,7 @@ async def cmd_warnings(app: Client, msg: Message):
target_name = user_db["tg_name"] target_name = user_db["tg_name"]
except: except:
list_of_users = [] list_of_users = []
async for m in app.get_chat_members(configGet("destination_group"), filter=ChatMembersFilter.SEARCH, query=msg.command[1]): async for m in app.get_chat_members(configGet("admin", "users"), filter=ChatMembersFilter.SEARCH, query=msg.command[1]):
list_of_users.append(m) list_of_users.append(m)
if len(list_of_users) != 0: if len(list_of_users) != 0:

View File

@ -57,7 +57,7 @@ async def confirm_yes(app: Client, msg: Message, kind: Literal["application", "s
i += 1 i += 1
if tmp_application["reapply"]: if tmp_application["reapply"]:
await app.send_message(chat_id=configGet("admin_group"), text=(locale("reapply_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(application_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup( await app.send_message(chat_id=configGet("admin", "groups"), text=(locale("reapply_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(application_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(
[ [
[ [
InlineKeyboardButton(text=str(locale("reapply_yes", "button")), callback_data=f"reapply_yes_{holo_user.id}") InlineKeyboardButton(text=str(locale("reapply_yes", "button")), callback_data=f"reapply_yes_{holo_user.id}")
@ -69,7 +69,7 @@ async def confirm_yes(app: Client, msg: Message, kind: Literal["application", "s
) )
) )
else: else:
await app.send_message(chat_id=configGet("admin_group"), text=(locale("application_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(application_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup( await app.send_message(chat_id=configGet("admin", "groups"), text=(locale("application_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(application_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(
[ [
[ [
InlineKeyboardButton(text=str(locale("sub_yes", "button")), callback_data=f"sub_yes_{holo_user.id}") InlineKeyboardButton(text=str(locale("sub_yes", "button")), callback_data=f"sub_yes_{holo_user.id}")
@ -124,7 +124,7 @@ async def confirm_yes(app: Client, msg: Message, kind: Literal["application", "s
else: else:
sponsorship_content.append(f"{locale(f'question_{question}', 'message', 'sponsor_titles')} {tmp_sponsorship['sponsorship'][question]}") sponsorship_content.append(f"{locale(f'question_{question}', 'message', 'sponsor_titles')} {tmp_sponsorship['sponsorship'][question]}")
await app.send_photo(chat_id=configGet("admin_group"), photo=f"tmp{sep}{filename}.jpg", 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_photo(chat_id=configGet("admin", "groups"), photo=f"tmp{sep}{filename}.jpg", 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}") InlineKeyboardButton(text=str(locale("sponsor_yes", "button")), callback_data=f"sponsor_yes_{holo_user.id}")

View File

@ -120,7 +120,7 @@ async def any_stage(app: Client, msg: Message):
@app.on_message(~ filters.scheduled & filters.group) @app.on_message(~ filters.scheduled & filters.group)
async def message_in_group(app: Client, msg: Message): async def message_in_group(app: Client, msg: Message):
if (msg.chat is not None) and (msg.via_bot is not None): if (msg.chat is not None) and (msg.via_bot is not None):
if (msg.via_bot.id == (await app.get_me()).id) and (msg.chat.id == configGet("destination_group")): if (msg.via_bot.id == (await app.get_me()).id) and (msg.chat.id == configGet("admin", "users")):
if configGet("remove_application_time") > 0: if configGet("remove_application_time") > 0:
logWrite(f"User {msg.from_user.id} requested application in destination group, removing in {configGet('remove_application_time')} minutes") logWrite(f"User {msg.from_user.id} requested application in destination group, removing in {configGet('remove_application_time')} minutes")
await asyncio.sleep(configGet("remove_application_time")*60) await asyncio.sleep(configGet("remove_application_time")*60)

View File

@ -7,8 +7,8 @@ from classes.holo_user import HoloUser
from modules import custom_filters from modules import custom_filters
# Filter users on join ========================================================================================================= # Filter users on join =========================================================================================================
@app.on_chat_member_updated(custom_filters.enabled_invites_check, group=configGet("destination_group")) @app.on_chat_member_updated(custom_filters.enabled_invites_check, group=configGet("admin", "users"))
#@app.on_message(filters.new_chat_members, group=configGet("destination_group")) #@app.on_message(filters.new_chat_members, group=configGet("admin", "users"))
async def filter_join(app: Client, member: ChatMemberUpdated): async def filter_join(app: Client, member: ChatMemberUpdated):
if member.invite_link != None: if member.invite_link != None:
@ -25,7 +25,7 @@ async def filter_join(app: Client, member: ChatMemberUpdated):
logWrite(f"User {holo_user.id} joined destination group with stolen/unapproved link {holo_user.link}") logWrite(f"User {holo_user.id} joined destination group with stolen/unapproved link {holo_user.link}")
await app.send_message(configGet("admin_group"), locale("joined_false_link", "message").format(member.from_user.first_name, member.from_user.id), reply_markup=InlineKeyboardMarkup( await app.send_message(configGet("admin", "groups"), locale("joined_false_link", "message").format(member.from_user.first_name, member.from_user.id), reply_markup=InlineKeyboardMarkup(
[ [
[ [
InlineKeyboardButton(text=str(locale("sus_allow", "button")), callback_data=f"sus_allow_{member.from_user.id}") InlineKeyboardButton(text=str(locale("sus_allow", "button")), callback_data=f"sus_allow_{member.from_user.id}")

View File

@ -7,7 +7,7 @@ from modules.logging import logWrite
from modules.utils import configGet, locale from modules.utils import configGet, locale
from modules import custom_filters from modules import custom_filters
@app.on_message(custom_filters.enabled_dinovoice & ~filters.scheduled & filters.voice & filters.chat(configGet("destination_group"))) @app.on_message(custom_filters.enabled_dinovoice & ~filters.scheduled & filters.voice & filters.chat(configGet("admin", "users")))
async def voice_message(app: Client, msg: Message): async def voice_message(app: Client, msg: Message):
logWrite(f"User {msg.from_user.id} sent voice message in destination group") logWrite(f"User {msg.from_user.id} sent voice message in destination group")
await msg.reply_text(choice(locale("voice_message", "message"))) await msg.reply_text(choice(locale("voice_message", "message")))

View File

@ -51,7 +51,7 @@ async def inline_answer(client: Client, inline_query: InlineQuery):
max_results = configGet("inline_preview_count") if inline_query.query != "" else 200 max_results = configGet("inline_preview_count") if inline_query.query != "" else 200
list_of_users = [] list_of_users = []
async for m in app.get_chat_members(configGet("destination_group"), limit=max_results, filter=ChatMembersFilter.SEARCH, query=inline_query.query): async for m in app.get_chat_members(configGet("admin", "users"), limit=max_results, filter=ChatMembersFilter.SEARCH, query=inline_query.query):
list_of_users.append(m) list_of_users.append(m)
results = [] results = []

View File

@ -19,7 +19,7 @@ if configGet("enabled", "scheduler", "cache_members"):
@scheduler.scheduled_job(trigger="interval", seconds=configGet("interval", "scheduler", "cache_members")) @scheduler.scheduled_job(trigger="interval", seconds=configGet("interval", "scheduler", "cache_members"))
async def cache_group_members(): async def cache_group_members():
list_of_users = [] list_of_users = []
async for member in app.get_chat_members(configGet("destination_group")): async for member in app.get_chat_members(configGet("admin", "users")):
list_of_users.append(member.user.id) list_of_users.append(member.user.id)
makedirs("cache", exist_ok=True) makedirs("cache", exist_ok=True)
jsonSave(list_of_users, path.join(configGet("cache", "locations"), "group_members")) jsonSave(list_of_users, path.join(configGet("cache", "locations"), "group_members"))
@ -28,7 +28,7 @@ if configGet("enabled", "scheduler", "cache_admins"):
@scheduler.scheduled_job(trigger="interval", seconds=configGet("interval", "scheduler", "cache_admins")) @scheduler.scheduled_job(trigger="interval", seconds=configGet("interval", "scheduler", "cache_admins"))
async def cache_admins(): async def cache_admins():
list_of_users = [] list_of_users = []
async for member in app.get_chat_members(configGet("admin_group")): async for member in app.get_chat_members(configGet("admin", "groups")):
list_of_users.append(member.user.id) list_of_users.append(member.user.id)
makedirs("cache", exist_ok=True) makedirs("cache", exist_ok=True)
jsonSave(list_of_users, path.join(configGet("cache", "locations"), "admins")) jsonSave(list_of_users, path.join(configGet("cache", "locations"), "admins"))
@ -39,7 +39,7 @@ if configGet("enabled", "scheduler", "cache_avatars"):
@scheduler.scheduled_job(trigger="interval", hours=configGet("interval", "scheduler", "cache_avatars")) @scheduler.scheduled_job(trigger="interval", hours=configGet("interval", "scheduler", "cache_avatars"))
async def cache_avatars(): async def cache_avatars():
list_of_users = [] list_of_users = []
async for member in app.get_chat_members(configGet("destination_group"), filter=ChatMembersFilter.SEARCH, query=""): async for member in app.get_chat_members(configGet("admin", "users"), filter=ChatMembersFilter.SEARCH, query=""):
list_of_users.append(member.user) list_of_users.append(member.user)
for user in list_of_users: for user in list_of_users:
if user.photo != None: if user.photo != None:
@ -58,7 +58,7 @@ if configGet("enabled", "features", "applications") is True:
if entry["application"]["2"].strftime("%d.%m") == datetime.now().strftime("%d.%m"): if entry["application"]["2"].strftime("%d.%m") == datetime.now().strftime("%d.%m"):
try: try:
tg_user = await app.get_users(entry["user"]) tg_user = await app.get_users(entry["user"])
await app.send_message( configGet("admin_group"), locale("birthday", "message").format(str(tg_user.first_name), str(tg_user.username), str(relativedelta(datetime.now(), entry["application"]["2"], '%d.%m.%Y').years)) ) # type: ignore await app.send_message( configGet("admin", "groups"), locale("birthday", "message").format(str(tg_user.first_name), str(tg_user.username), str(relativedelta(datetime.now(), entry["application"]["2"], '%d.%m.%Y').years)) ) # type: ignore
logWrite(f"Notified admins about {entry['user']}'s birthday") logWrite(f"Notified admins about {entry['user']}'s birthday")
except Exception as exp: except Exception as exp:
logWrite(f"Could not find user {entry['user']} to send a message about birthday due to '{exp}'") logWrite(f"Could not find user {entry['user']} to send a message about birthday due to '{exp}'")
@ -84,7 +84,7 @@ if configGet("enabled", "features", "sponsorships") is True:
try: try:
holo_user = HoloUser(entry["user"]) holo_user = HoloUser(entry["user"])
await app.send_message( entry["user"], locale("sponsorships_expired", "message") ) # type: ignore await app.send_message( entry["user"], locale("sponsorships_expired", "message") ) # type: ignore
await holo_user.label_reset(configGet("destination_group")) await holo_user.label_reset(configGet("admin", "users"))
col_sponsorships.find_one_and_delete({"user": holo_user.id}) col_sponsorships.find_one_and_delete({"user": holo_user.id})
try: try:
tg_user = await app.get_users(entry["user"]) tg_user = await app.get_users(entry["user"])
@ -165,14 +165,14 @@ async def commands_register():
# Registering admin group commands # Registering admin group commands
try: try:
await app.set_bot_commands(commands["group_admins"], scope=BotCommandScopeChat(chat_id=configGet("admin_group"))) await app.set_bot_commands(commands["group_admins"], scope=BotCommandScopeChat(chat_id=configGet("admin", "groups")))
logWrite("Registered admin group commands for default locale") logWrite("Registered admin group commands for default locale")
except bad_request_400.ChannelInvalid: except bad_request_400.ChannelInvalid:
logWrite(f"Could not register commands for admin group. Bot is likely not in the group.") logWrite(f"Could not register commands for admin group. Bot is likely not in the group.")
# Registering destination group commands # Registering destination group commands
try: try:
await app.set_bot_commands(commands["group_users"], scope=BotCommandScopeChat(chat_id=configGet("destination_group"))) await app.set_bot_commands(commands["group_users"], scope=BotCommandScopeChat(chat_id=configGet("admin", "users")))
logWrite("Registered destination group commands") logWrite("Registered destination group commands")
except bad_request_400.ChannelInvalid: except bad_request_400.ChannelInvalid:
logWrite(f"Could not register commands for destination group. Bot is likely not in the group.") logWrite(f"Could not register commands for destination group. Bot is likely not in the group.")