Bug fixes and improvements #8
@ -34,14 +34,21 @@ async def cmd_reapply(app: Client, msg: Message):
|
||||
await welcome_pass(app, msg, once_again=True)
|
||||
|
||||
else:
|
||||
await msg.reply_text(locale("reapply_left_chat", "message", locale=holo_user), reply_markup=InlineKeyboardMarkup([
|
||||
[
|
||||
InlineKeyboardButton(locale("reapply_old_one", "button", locale=holo_user), f"reapply_old_{msg.id}")
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(locale("reapply_new_one", "button", locale=holo_user), f"reapply_new_{msg.id}")
|
||||
]
|
||||
]))
|
||||
|
||||
if holo_user.sponsorship_state()[1] is True:
|
||||
|
||||
await msg.reply_text(locale("reapply_left_chat", "message", locale=holo_user), reply_markup=InlineKeyboardMarkup([
|
||||
[
|
||||
InlineKeyboardButton(locale("reapply_old_one", "button", locale=holo_user), f"reapply_old_{msg.id}")
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(locale("reapply_new_one", "button", locale=holo_user), f"reapply_new_{msg.id}")
|
||||
]
|
||||
]))
|
||||
|
||||
else:
|
||||
holo_user.application_restart(reapply=True)
|
||||
await welcome_pass(app, msg, once_again=True)
|
||||
|
||||
else:
|
||||
|
||||
|
@ -24,42 +24,35 @@ async def cmd_resetcommands(app: Client, msg: Message):
|
||||
if entry.endswith(".json"):
|
||||
valid_locales.append(".".join(entry.split(".")[:-1]))
|
||||
|
||||
if configGet("debug") is True:
|
||||
logWrite(f'Resetting commands in groups {configGet("admin", "groups")} and {configGet("users", "groups")}')
|
||||
logWrite(f'Resetting commands in groups {configGet("admin", "groups")} and {configGet("users", "groups")}', debug=True)
|
||||
await app.delete_bot_commands(scope=BotCommandScopeChat(chat_id=configGet("admin", "groups")))
|
||||
await app.delete_bot_commands(scope=BotCommandScopeChat(chat_id=configGet("users", "groups")))
|
||||
|
||||
for admin in configGet("admins"):
|
||||
try:
|
||||
if configGet("debug") is True:
|
||||
logWrite(f'Resetting commands for admin {admin}')
|
||||
logWrite(f'Resetting commands for admin {admin}', debug=True)
|
||||
await app.delete_bot_commands(scope=BotCommandScopeChat(chat_id=admin))
|
||||
except bad_request_400.PeerIdInvalid:
|
||||
pass
|
||||
|
||||
try:
|
||||
if configGet("debug") is True:
|
||||
logWrite(f'Resetting commands for owner {configGet("owner")}')
|
||||
logWrite(f'Resetting commands for owner {configGet("owner")}', debug=True)
|
||||
for lc in valid_locales:
|
||||
if configGet("debug") is True:
|
||||
logWrite(f'Resetting commands for owner {configGet("owner")} [{lc}]')
|
||||
logWrite(f'Resetting commands for owner {configGet("owner")} [{lc}]', debug=True)
|
||||
await app.delete_bot_commands(scope=BotCommandScopeChat(chat_id=configGet("owner")), language_code=lc)
|
||||
await app.delete_bot_commands(scope=BotCommandScopeChat(chat_id=configGet("owner")))
|
||||
except bad_request_400.PeerIdInvalid:
|
||||
pass
|
||||
|
||||
for lc in valid_locales:
|
||||
if configGet("debug") is True:
|
||||
logWrite(f'Resetting commands for locale {lc}')
|
||||
logWrite(f'Resetting commands for locale {lc}', debug=True)
|
||||
await app.delete_bot_commands(scope=BotCommandScopeDefault(), language_code=lc)
|
||||
|
||||
if configGet("debug") is True:
|
||||
logWrite(f'Resetting default commands')
|
||||
logWrite(f'Resetting default commands', debug=True)
|
||||
await app.delete_bot_commands()
|
||||
|
||||
await msg.reply_text("OK", quote=should_quote(msg))
|
||||
|
||||
if configGet("debug") is True:
|
||||
logWrite(str(await app.get_bot_commands()))
|
||||
logWrite(str(await app.get_bot_commands(scope=BotCommandScopeChat(chat_id=configGet("owner")))))
|
||||
logWrite(str(await app.get_bot_commands()), debug=True)
|
||||
logWrite(str(await app.get_bot_commands(scope=BotCommandScopeChat(chat_id=configGet("owner")))), debug=True)
|
||||
# ==============================================================================================================================
|
@ -78,8 +78,7 @@ async def inline_answer(client: Client, inline_query: InlineQuery):
|
||||
try:
|
||||
holo_user = HoloUser(inline_query.from_user)
|
||||
except (UserNotFoundError, UserInvalidError):
|
||||
if configGet("debug") is True:
|
||||
logWrite(f"Could not find application of {inline_query.from_user.id}, ignoring inline query")
|
||||
logWrite(f"Could not find application of {inline_query.from_user.id}, ignoring inline query", debug=True)
|
||||
await inline_query.answer(
|
||||
results=results_forbidden
|
||||
)
|
||||
@ -87,8 +86,7 @@ async def inline_answer(client: Client, inline_query: InlineQuery):
|
||||
|
||||
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"))):
|
||||
if path.exists(path.join(configGet("cache", "locations"), "admins")) and (inline_query.from_user.id not in jsonLoad(path.join(configGet("cache", "locations"), "admins"))):
|
||||
if configGet("debug") is True:
|
||||
logWrite(f"{inline_query.from_user.id} is not an admin and not in members group, ignoring inline query")
|
||||
logWrite(f"{inline_query.from_user.id} is not an admin and not in members group, ignoring inline query", debug=True)
|
||||
await inline_query.answer(
|
||||
results=results_forbidden
|
||||
)
|
||||
|
@ -24,8 +24,7 @@ if configGet("enabled", "scheduler", "cache_members"):
|
||||
list_of_users.append(member.user.id)
|
||||
makedirs(configGet("cache", "locations"), exist_ok=True)
|
||||
jsonSave(list_of_users, path.join(configGet("cache", "locations"), "group_members"))
|
||||
if configGet("debug") is True:
|
||||
logWrite("User group caching performed")
|
||||
logWrite("User group caching performed", debug=True)
|
||||
|
||||
if configGet("enabled", "scheduler", "cache_admins"):
|
||||
@scheduler.scheduled_job(trigger="interval", seconds=configGet("interval", "scheduler", "cache_admins"))
|
||||
@ -35,8 +34,7 @@ if configGet("enabled", "scheduler", "cache_admins"):
|
||||
list_of_users.append(member.user.id)
|
||||
makedirs(configGet("cache", "locations"), exist_ok=True)
|
||||
jsonSave(list_of_users, path.join(configGet("cache", "locations"), "admins"))
|
||||
if configGet("debug") is True:
|
||||
logWrite("Admin group caching performed")
|
||||
logWrite("Admin group caching performed", debug=True)
|
||||
|
||||
# Cache the avatars of group members
|
||||
if configGet("enabled", "scheduler", "cache_avatars"):
|
||||
@ -159,8 +157,7 @@ async def commands_register():
|
||||
enabled = True
|
||||
|
||||
if enabled is False:
|
||||
if configGet("debug") is True:
|
||||
logWrite(f"Not registering {command} at all")
|
||||
logWrite(f"Not registering {command} at all", debug=True)
|
||||
continue
|
||||
|
||||
for permission in config_commands[command]["permissions"]:
|
||||
@ -223,4 +220,4 @@ async def commands_register():
|
||||
|
||||
if configGet("debug") is True:
|
||||
print(commands, flush=True)
|
||||
logWrite(f"Complete commands registration:\n{dumps(commands_raw, indent=4, ensure_ascii=False, encode_html_chars=False)}")
|
||||
logWrite(f"Complete commands registration:\n{dumps(commands_raw, indent=4, ensure_ascii=False, encode_html_chars=False)}", debug=True)
|
Reference in New Issue
Block a user