Rename self-destruct to auto-delete functions

pull/179/head
J-Rios 2023-01-07 23:28:45 +01:00
rodzic bdc38d30f8
commit 1d433f63d1
Nie znaleziono w bazie danych klucza dla tego podpisu
1 zmienionych plików z 76 dodań i 79 usunięć

Wyświetl plik

@ -278,27 +278,24 @@ def get_chat_config_file(chat_id):
async def tlg_send_msg_type_chat(
bot, chat_type, chat_id, text, **kwargs_for_send_message):
'''
Send a telegram message normal or schedule to self-destruct
Send a telegram message normal or schedule to auto-delete
depending of chat type (private chat - normal;
group - selfdestruct).
'''
if chat_type == "private":
await tlg_send_msg(bot, chat_id, text, **kwargs_for_send_message)
else:
await tlg_send_selfdestruct_msg(
await tlg_send_autodelete_msg(
bot, chat_id, text, **kwargs_for_send_message)
async def tlg_send_selfdestruct_msg(
bot, chat_id, message, **kwargs_for_send_message):
'''tlg_send_selfdestruct_msg_in() with default delete time'''
return await tlg_send_selfdestruct_msg_in(
bot, chat_id, message, CONST["T_DEL_MSG"],
**kwargs_for_send_message)
async def tlg_send_selfdestruct_msg_in(
bot, chat_id, message, time_delete_sec, **kwargs_for_send_message):
async def tlg_send_autodelete_msg(
bot,
chat_id,
message,
time_delete_sec=CONST["T_DEL_MSG"],
**kwargs_for_send_message
):
'''
Send a telegram message that will be auto-delete in specified time.
'''
@ -306,11 +303,11 @@ async def tlg_send_selfdestruct_msg_in(
bot, chat_id, message, **kwargs_for_send_message)
if sent_result["msg"] is None:
return None
tlg_msg_to_selfdestruct_in(sent_result["msg"], time_delete_sec)
tlg_autodelete_msg(sent_result["msg"], time_delete_sec)
return sent_result["msg"].message_id
def tlg_msg_to_selfdestruct_in(message, time_delete_sec=CONST["T_DEL_MSG"]):
def tlg_autodelete_msg(message, time_delete_sec=CONST["T_DEL_MSG"]):
'''
Add a telegram message to be auto-delete in specified time.
'''
@ -775,7 +772,7 @@ async def captcha_fail_kick_ban_member(
join_retries = join_retries + 1
msg_text = TEXT[lang]["NEW_USER_KICK"].format(user_name)
if rm_result_msg:
await tlg_send_selfdestruct_msg_in(
await tlg_send_autodelete_msg(
bot, chat_id, msg_text, CONST["T_FAST_DEL_MSG"])
else:
await tlg_send_msg(bot, chat_id, msg_text)
@ -788,7 +785,7 @@ async def captcha_fail_kick_ban_member(
msg_text = TEXT[lang]["NEW_USER_KICK_NOT_IN_CHAT"].format(
user_name)
if rm_result_msg:
await tlg_send_selfdestruct_msg_in(
await tlg_send_autodelete_msg(
bot, chat_id, msg_text, CONST["T_FAST_DEL_MSG"])
else:
await tlg_send_msg(bot, chat_id, msg_text)
@ -803,7 +800,7 @@ async def captcha_fail_kick_ban_member(
# For other reason, the Bot can't ban
msg_text = TEXT[lang]["BOT_CANT_KICK"].format(user_name)
if rm_result_msg:
await tlg_send_selfdestruct_msg_in(
await tlg_send_autodelete_msg(
bot, chat_id, msg_text, CONST["T_FAST_DEL_MSG"])
else:
await tlg_send_msg(bot, chat_id, msg_text)
@ -838,7 +835,7 @@ async def captcha_fail_kick_ban_member(
# Send ban notify message
logger.info("[%s] %s", chat_id, msg_text)
if rm_result_msg:
await tlg_send_selfdestruct_msg(bot, chat_id, msg_text)
await tlg_send_autodelete_msg(bot, chat_id, msg_text)
else:
await tlg_send_msg(bot, chat_id, msg_text)
# Update user info (join_retries & kick_ban)
@ -1035,7 +1032,7 @@ async def chat_member_status_change(
if ((poll_question == "") or
(num_config_poll_options(poll_options) < 2) or
(poll_correct_option == 0)):
await tlg_send_selfdestruct_msg_in(
await tlg_send_autodelete_msg(
bot, chat_id, TEXT[lang]["POLL_NEW_USER_NOT_CONFIG"],
CONST["T_FAST_DEL_MSG"])
return
@ -1044,7 +1041,7 @@ async def chat_member_status_change(
# Send request to solve the poll text message
poll_request_msg_text = TEXT[lang]["POLL_NEW_USER"].format(
join_user_name, chat_title, timeout_str)
sent_result = await tlg_send_selfdestruct_msg(
sent_result = await tlg_send_autodelete_msg(
bot, chat_id, poll_request_msg_text)
solve_poll_request_msg_id = None
if sent_result is not None:
@ -1120,9 +1117,9 @@ async def chat_member_status_change(
if path.exists(captcha["image"]):
remove(captcha["image"])
if not send_problem:
# Add sent captcha message to self-destruct list
# Add sent captcha message to auto-delete list
if sent_result["msg"] is not None:
tlg_msg_to_selfdestruct_in(
tlg_autodelete_msg(
sent_result["msg"], captcha_timeout + 10)
# Default user join data
join_data = {
@ -1276,7 +1273,7 @@ async def media_msg_rx(update: Update, context: ContextTypes.DEFAULT_TYPE):
await delete_tlg_msg(bot, chat_id, msg_id)
lang = get_chat_config(chat_id, "Language")
bot_msg = TEXT[lang]["NOT_TEXT_MSG_ALLOWED"].format(user_name)
await tlg_send_selfdestruct_msg_in(
await tlg_send_autodelete_msg(
bot, chat_id, bot_msg, CONST["T_FAST_DEL_MSG"],
topic_id=tlg_get_msg_topic(update_msg))
@ -1368,7 +1365,7 @@ async def text_msg_rx(update: Update, context: ContextTypes.DEFAULT_TYPE):
if await delete_tlg_msg(bot, chat_id, msg_id):
bot_msg = TEXT[lang]["URL_MSG_NOT_ALLOWED_DETECTED"].format(
user_name)
await tlg_send_selfdestruct_msg_in(
await tlg_send_autodelete_msg(
bot, chat_id, bot_msg,
CONST["T_FAST_DEL_MSG"],
topic_id=topic_id)
@ -1403,12 +1400,12 @@ async def text_msg_rx(update: Update, context: ContextTypes.DEFAULT_TYPE):
# Try to remove the message and notify detection
if await delete_tlg_msg(bot, chat_id, msg_id):
bot_msg = TEXT[lang]["SPAM_DETECTED_RM"].format(user_name)
await tlg_send_selfdestruct_msg_in(
await tlg_send_autodelete_msg(
bot, chat_id, bot_msg, CONST["T_FAST_DEL_MSG"],
topic_id=topic_id)
else:
bot_msg = TEXT[lang]["SPAM_DETECTED_NOT_RM"].format(user_name)
await tlg_send_selfdestruct_msg_in(
await tlg_send_autodelete_msg(
bot, chat_id, bot_msg, CONST["T_FAST_DEL_MSG"],
topic_id=topic_id)
logger.info("Message can't be deleted.")
@ -1441,7 +1438,7 @@ async def text_msg_rx(update: Update, context: ContextTypes.DEFAULT_TYPE):
# Send message solve message
bot_msg = TEXT[lang]["CAPTCHA_SOLVED"].format(user_name)
if rm_result_msg:
await tlg_send_selfdestruct_msg_in(
await tlg_send_autodelete_msg(
bot, chat_id, bot_msg, CONST["T_FAST_DEL_MSG"])
else:
await tlg_send_msg(bot, chat_id, bot_msg)
@ -1453,7 +1450,7 @@ async def text_msg_rx(update: Update, context: ContextTypes.DEFAULT_TYPE):
rm_welcome_msg = get_chat_config(chat_id, "Rm_Welcome_Msg")
if rm_welcome_msg:
welcome_msg_time = get_chat_config(chat_id, "Welcome_Time")
sent_result = await tlg_send_selfdestruct_msg_in(
sent_result = await tlg_send_autodelete_msg(
bot, chat_id, welcome_msg, welcome_msg_time,
parse_mode="MARKDOWN")
else:
@ -1496,8 +1493,8 @@ async def text_msg_rx(update: Update, context: ContextTypes.DEFAULT_TYPE):
clueless_user = True
# Tell the user that is wrong
if clueless_user:
tlg_msg_to_selfdestruct_in(update_msg)
sent_msg_id = await tlg_send_selfdestruct_msg_in(
tlg_autodelete_msg(update_msg)
sent_msg_id = await tlg_send_autodelete_msg(
bot, chat_id, TEXT[lang]["CAPTCHA_INCORRECT_MATH"],
CONST["T_FAST_DEL_MSG"], topic_id=topic_id)
Global.new_users[chat_id][user_id]["msg_to_rm"].append(
@ -1507,8 +1504,8 @@ async def text_msg_rx(update: Update, context: ContextTypes.DEFAULT_TYPE):
else:
# Check if the message has 4 chars
if len(msg_text) == 4:
tlg_msg_to_selfdestruct_in(update_msg)
sent_msg_id = await tlg_send_selfdestruct_msg_in(
tlg_autodelete_msg(update_msg)
sent_msg_id = await tlg_send_autodelete_msg(
bot, chat_id, TEXT[lang]["CAPTCHA_INCORRECT_0"],
CONST["T_FAST_DEL_MSG"], topic_id=topic_id)
Global.new_users[chat_id][user_id]["msg_to_rm"].append(
@ -1516,8 +1513,8 @@ async def text_msg_rx(update: Update, context: ContextTypes.DEFAULT_TYPE):
Global.new_users[chat_id][user_id]["msg_to_rm"].append(msg_id)
# Check if the message was just a 4 numbers msg
elif is_int(msg_text):
tlg_msg_to_selfdestruct_in(update_msg)
sent_msg_id = await tlg_send_selfdestruct_msg_in(
tlg_autodelete_msg(update_msg)
sent_msg_id = await tlg_send_autodelete_msg(
bot, chat_id, TEXT[lang]["CAPTCHA_INCORRECT_1"],
CONST["T_FAST_DEL_MSG"], topic_id=topic_id)
Global.new_users[chat_id][user_id]["msg_to_rm"].append(
@ -1582,7 +1579,7 @@ async def poll_answer_rx(
# Send captcha solved message
bot_msg = TEXT[lang]["CAPTCHA_SOLVED"].format(user_name)
if rm_result_msg:
await tlg_send_selfdestruct_msg_in(
await tlg_send_autodelete_msg(
bot, chat_id, bot_msg, CONST["T_FAST_DEL_MSG"])
else:
await tlg_send_msg(bot, chat_id, bot_msg)
@ -1591,7 +1588,7 @@ async def poll_answer_rx(
if welcome_msg != "-":
if rm_welcome_msg:
welcome_msg_time = get_chat_config(chat_id, "Welcome_Time")
sent_result = await tlg_send_selfdestruct_msg_in(
sent_result = await tlg_send_autodelete_msg(
bot, chat_id, welcome_msg, welcome_msg_time,
parse_mode="MARKDOWN")
else:
@ -1622,7 +1619,7 @@ async def poll_answer_rx(
logger.info("[%s] User %s fail poll.", chat_id, user_name)
bot_msg = TEXT[lang]["CAPTCHA_POLL_FAIL"].format(user_name)
if rm_result_msg:
await tlg_send_selfdestruct_msg_in(
await tlg_send_autodelete_msg(
bot, chat_id, bot_msg, CONST["T_FAST_DEL_MSG"])
else:
await tlg_send_msg(bot, chat_id, bot_msg)
@ -1790,7 +1787,7 @@ async def button_im_not_a_bot_press(bot, query):
# Send captcha solved message
bot_msg = TEXT[lang]["CAPTCHA_SOLVED"].format(user_name)
if rm_result_msg:
await tlg_send_selfdestruct_msg_in(
await tlg_send_autodelete_msg(
bot, chat_id, bot_msg, CONST["T_FAST_DEL_MSG"])
else:
await tlg_send_msg(bot, chat_id, bot_msg)
@ -1803,7 +1800,7 @@ async def button_im_not_a_bot_press(bot, query):
rm_welcome_msg = get_chat_config(chat_id, "Rm_Welcome_Msg")
if rm_welcome_msg:
welcome_msg_time = get_chat_config(chat_id, "Welcome_Time")
sent_result = await tlg_send_selfdestruct_msg_in(
sent_result = await tlg_send_autodelete_msg(
bot, chat_id, welcome_msg, welcome_msg_time,
parse_mode="MARKDOWN")
else:
@ -1855,7 +1852,7 @@ async def cmd_start(update: Update, context: ContextTypes.DEFAULT_TYPE):
await tlg_send_msg(bot, chat_id, TEXT[lang]["START"])
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
user_id = update_msg.from_user.id
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
@ -1863,7 +1860,7 @@ async def cmd_start(update: Update, context: ContextTypes.DEFAULT_TYPE):
return
# Send the response message
lang = get_chat_config(chat_id, "Language")
await tlg_send_selfdestruct_msg(
await tlg_send_autodelete_msg(
bot, chat_id, TEXT[lang]["START"],
topic_id=tlg_get_msg_topic(update_msg))
@ -1884,7 +1881,7 @@ async def cmd_help(update: Update, context: ContextTypes.DEFAULT_TYPE):
await tlg_send_msg(bot, chat_id, TEXT[lang]["HELP"])
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
user_id = update_msg.from_user.id
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
@ -1892,7 +1889,7 @@ async def cmd_help(update: Update, context: ContextTypes.DEFAULT_TYPE):
return
# Send the response message
lang = get_chat_config(chat_id, "Language")
await tlg_send_selfdestruct_msg(
await tlg_send_autodelete_msg(
bot, chat_id, TEXT[lang]["HELP"],
topic_id=tlg_get_msg_topic(update_msg))
@ -1913,7 +1910,7 @@ async def cmd_commands(update: Update, context: ContextTypes.DEFAULT_TYPE):
await tlg_send_msg(bot, chat_id, TEXT[lang]["COMMANDS"])
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
user_id = update_msg.from_user.id
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
@ -1921,7 +1918,7 @@ async def cmd_commands(update: Update, context: ContextTypes.DEFAULT_TYPE):
return
# Send the response message
lang = get_chat_config(chat_id, "Language")
await tlg_send_selfdestruct_msg(
await tlg_send_autodelete_msg(
bot, chat_id, TEXT[lang]["COMMANDS"],
topic_id=tlg_get_msg_topic(update_msg))
@ -1946,7 +1943,7 @@ async def cmd_connect(update: Update, context: ContextTypes.DEFAULT_TYPE):
# Ignore if command is not in private chat
if chat_type != "private":
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2005,7 +2002,7 @@ async def cmd_disconnect(update: Update, context: ContextTypes.DEFAULT_TYPE):
# Ignore if command is not in private chat
if chat_type != "private":
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2055,7 +2052,7 @@ async def cmd_checkcfg(update: Update, context: ContextTypes.DEFAULT_TYPE):
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2096,7 +2093,7 @@ async def cmd_language(update: Update, context: ContextTypes.DEFAULT_TYPE):
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2156,7 +2153,7 @@ async def cmd_time(update: Update, context: ContextTypes.DEFAULT_TYPE):
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2242,7 +2239,7 @@ async def cmd_difficulty(update: Update, context: ContextTypes.DEFAULT_TYPE):
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2295,7 +2292,7 @@ async def cmd_captcha_mode(update: Update, context: ContextTypes.DEFAULT_TYPE):
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2346,7 +2343,7 @@ async def cmd_welcome_msg(update: Update, context: ContextTypes.DEFAULT_TYPE):
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2406,7 +2403,7 @@ async def cmd_welcome_msg_time(
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2492,7 +2489,7 @@ async def cmd_captcha_poll(update: Update, context: ContextTypes.DEFAULT_TYPE):
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2638,7 +2635,7 @@ async def cmd_restrict_non_text(
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2704,7 +2701,7 @@ async def cmd_add_ignore(update: Update, context: ContextTypes.DEFAULT_TYPE):
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2766,7 +2763,7 @@ async def cmd_remove_ignore(
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2817,7 +2814,7 @@ async def cmd_ignore_list(update: Update, context: ContextTypes.DEFAULT_TYPE):
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2864,7 +2861,7 @@ async def cmd_remove_solve_kick_msg(
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2920,7 +2917,7 @@ async def cmd_remove_welcome_msg(
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -2975,7 +2972,7 @@ async def cmd_remove_all_msg_kick_on(
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -3022,7 +3019,7 @@ async def cmd_remove_all_msg_kick_off(
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -3066,7 +3063,7 @@ async def cmd_url_enable(update: Update, context: ContextTypes.DEFAULT_TYPE):
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -3110,7 +3107,7 @@ async def cmd_url_disable(update: Update, context: ContextTypes.DEFAULT_TYPE):
group_id = Global.connections[user_id]["group_id"]
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -3149,7 +3146,7 @@ async def cmd_enable(update: Update, context: ContextTypes.DEFAULT_TYPE):
await tlg_send_msg(bot, chat_id, TEXT[lang]["CMD_NOT_ALLOW_PRIVATE"])
return
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -3164,7 +3161,7 @@ async def cmd_enable(update: Update, context: ContextTypes.DEFAULT_TYPE):
enable = True
save_config_property(chat_id, "Enabled", enable)
bot_msg = TEXT[lang]["ENABLE"]
await tlg_send_selfdestruct_msg(
await tlg_send_autodelete_msg(
bot, chat_id, bot_msg,
topic_id=tlg_get_msg_topic(update_msg))
@ -3187,7 +3184,7 @@ async def cmd_disable(update: Update, context: ContextTypes.DEFAULT_TYPE):
await tlg_send_msg(bot, chat_id, TEXT[lang]["CMD_NOT_ALLOW_PRIVATE"])
return
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -3202,7 +3199,7 @@ async def cmd_disable(update: Update, context: ContextTypes.DEFAULT_TYPE):
enable = False
save_config_property(chat_id, "Enabled", enable)
bot_msg = TEXT[lang]["DISABLE"]
await tlg_send_selfdestruct_msg(
await tlg_send_autodelete_msg(
bot, chat_id, bot_msg,
topic_id=tlg_get_msg_topic(update_msg))
@ -3223,8 +3220,8 @@ async def cmd_chatid(update: Update, context: ContextTypes.DEFAULT_TYPE):
await tlg_send_msg(bot, chat_id, msg_text)
else:
msg_text = f"Group Chat ID:\n—————————\n{chat_id}"
tlg_msg_to_selfdestruct_in(update_msg)
await tlg_send_selfdestruct_msg(
tlg_autodelete_msg(update_msg)
await tlg_send_autodelete_msg(
bot, chat_id, msg_text,
topic_id=tlg_get_msg_topic(update_msg))
@ -3247,7 +3244,7 @@ async def cmd_version(update: Update, context: ContextTypes.DEFAULT_TYPE):
await tlg_send_msg(bot, chat_id, msg_text)
else:
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Ignore if not requested by a group Admin
is_admin = await tlg_user_is_admin(bot, chat_id, user_id)
if (is_admin is None) or (is_admin is False):
@ -3255,7 +3252,7 @@ async def cmd_version(update: Update, context: ContextTypes.DEFAULT_TYPE):
# Send the message
lang = get_chat_config(chat_id, "Language")
msg_text = TEXT[lang]["VERSION"].format(CONST["VERSION"])
await tlg_send_selfdestruct_msg(
await tlg_send_autodelete_msg(
bot, chat_id, msg_text,
topic_id=tlg_get_msg_topic(update_msg))
@ -3299,11 +3296,11 @@ async def cmd_captcha(update: Update, context: ContextTypes.DEFAULT_TYPE):
if user.username is not None:
user_alias = f"@{user.username}"
# Remove command message automatically after a while
tlg_msg_to_selfdestruct_in(update_msg)
tlg_autodelete_msg(update_msg)
# Check if command was execute by Bot owner
if ((str(user_id) != CONST["BOT_OWNER"]) and
(user_alias != CONST["BOT_OWNER"])):
await tlg_send_selfdestruct_msg(
await tlg_send_autodelete_msg(
bot, chat_id, CONST["CMD_JUST_ALLOW_OWNER"],
topic_id=tlg_get_msg_topic(update_msg))
return
@ -3362,7 +3359,7 @@ async def cmd_allowuserlist(
# Check if command was execute by Bot owner
if ((str(user_id) != CONST["BOT_OWNER"]) and
(user_alias != CONST["BOT_OWNER"])):
await tlg_send_selfdestruct_msg(
await tlg_send_autodelete_msg(
bot, chat_id, CONST["CMD_JUST_ALLOW_OWNER"], topic_id=topic_id)
return
# Check if no argument was provided with the command
@ -3452,7 +3449,7 @@ async def cmd_allowgroup(update: Update, context: ContextTypes.DEFAULT_TYPE):
# Check if command was execute by Bot owner
if ((str(user_id) != CONST["BOT_OWNER"]) and
(user_alias != CONST["BOT_OWNER"])):
await tlg_send_selfdestruct_msg(
await tlg_send_autodelete_msg(
bot, chat_id, CONST["CMD_JUST_ALLOW_OWNER"], topic_id=topic_id)
return
# Check if no argument was provided with the command
@ -3518,7 +3515,7 @@ async def cmd_allowgroup(update: Update, context: ContextTypes.DEFAULT_TYPE):
async def auto_delete_messages(bot):
'''
Handle remove messages sent by the Bot with the timed self-delete
Handle remove messages sent by the Bot with the timed auto-delete
function.
'''
while not Global.force_exit:
@ -3557,7 +3554,7 @@ async def auto_delete_messages(bot):
bot, sent_msg["Chat_id"], TEXT[lang]["CANT_DEL_MSG"],
reply_to_message_id=sent_msg["Msg_id"])
if sent_result["msg"] is not None:
tlg_msg_to_selfdestruct_in(sent_result["msg"])
tlg_autodelete_msg(sent_result["msg"])
list_remove_element(
Global.to_delete_in_time_messages_list, sent_msg)
await asyncio_sleep(0.01)