Updated Commands
Updated Commands
=
# ✅ Utility: readable timer
def format_time(time_left):
sec = time_left % (24 * 3600)
hour = sec // 3600
sec %= 3600
mins = sec // 60
sec %= 60
return "%d h %02d m %02d s" % (hour, mins, sec)
user_id = message.from_user.id
group_id = [Link]
# --------------------------------------------------
# 📝 FILTERS (trigger/response system)
# --------------------------------------------------
filters = [Link](f"filters_{group_id}") or {}
if filters:
text_content = ([Link] or [Link] or "").lower()
if text_content.strip():
for trigger, response in [Link]():
if trigger in text_content.split(): # exact word match
[Link](group_id, response,
reply_to_message_id=message.message_id)
raise ReturnCommand()
# --------------------------------------------------
# 👋 Welcome + Tracking Join
# --------------------------------------------------
already_tracked = [Link](f"invite_used_{user_id}_{group_id}")
info = [Link](f"invite_current_{user_id}")
# ✅ Track invitee
invited_key = f"invited_users_{group_id}_{inviter}"
invited_list = [Link](invited_key) or ""
invited_ids = invited_list.split(",") if invited_list else []
if str(user_id) not in invited_ids:
invited_ids.append(str(user_id))
[Link](invited_key, ",".join(invited_ids))
# ✅ Resettable tracker
reset_key = f"resettable_invite_keys_{group_id}"
key_list = [Link](reset_key) or []
if key not in key_list:
key_list.append(key)
[Link](reset_key, key_list)
# ✅ Mark used
info["used"] = True
[Link](f"invite_current_{user_id}", info)
[Link](f"invite_used_{user_id}_{group_id}", "ok")
# ✅ Optional notification
settings = [Link](f"group_invite_config_{group_id}") or {"notify": True}
if [Link]("notify", True):
user_mention = f"<a href='tg://user?
id={user_id}'>{message.from_user.first_name}</a>"
inviter_mention = f"<a href='tg://user?id={inviter}'>{inviter_name or 'an
inviter'}</a>"
[Link](
chat_id=group_id,
text=f"🎉 Welcome {user_mention}! Invited by {inviter_mention}. Glad to
have you!",
parse_mode="html"
)
# --------------------------------------------------
# 🚫 BLOCK RULES (admins immune)
# --------------------------------------------------
if not is_admin:
blocks = [Link](f"group_blocks_{group_id}") or []
if "gifs" in blocks:
if check_and_delete("GIF", [Link]):
raise ReturnCommand()
if "forwards" in blocks:
if check_and_delete("Forward", (message.forward_from or
message.forward_from_chat)):
raise ReturnCommand()
if "voice" in blocks:
if check_and_delete("Voice/Audio", ([Link] or [Link])):
raise ReturnCommand()
if "commands" in blocks:
if check_and_delete("Command", ([Link] or "").startswith("/")):
raise ReturnCommand()
if "photos" in blocks:
if check_and_delete("Photo", [Link]):
raise ReturnCommand()
if "videos" in blocks:
if check_and_delete("Video", [Link]):
raise ReturnCommand()
if "documents" in blocks:
if check_and_delete("Document", [Link]):
raise ReturnCommand()
# --------------------------------------------------
# 🚫 AI MODERATION (admins immune)
# --------------------------------------------------
text = [Link] or [Link] or ""
if not [Link]():
raise ReturnCommand()
deleted_flag = False
if not is_admin:
modes = [Link](f"group_modes_{group_id}") or []
prompts = {
"toxicity": "Check if the message below contains bullying, rudeness, or
toxic behavior.\nMessage: \"{text}\"...",
"profanity": "Check if this message contains profanity, swearing, or
offensive language.\nMessage: \"{text}\"...",
"nsfw": "Does this message contain sexually explicit or NSFW content?\
nMessage: \"{text}\"...",
"strict_ai": "Detect if this message is passive-aggressive, sarcastic, or
subtly toxic.\nMessage: \"{text}\"...",
"english_only": "Is this message written in a language other than English?\
nMessage: \"{text}\"...",
"ads": "Does this message promote ads, channels, groups, or links?\
nMessage: \"{text}\"...",
"pm_block": "Does this message ask others to PM, DM, or inbox the sender?\
nMessage: \"{text}\"...",
"tag_block": "Does this message mention admins or users with tags like
@admin or @all?\nMessage: \"{text}\"..."
}
reason_texts = {
"toxicity": "toxic or bullying behavior",
"profanity": "offensive or profane language",
"nsfw": "sexually inappropriate content",
"strict_ai": "passive-aggressive or sarcastic behavior",
"english_only": "non-English content (English only is allowed)",
"ads": "unsolicited promotions or links",
"pm_block": "asking users to DM or inbox",
"tag_block": "tagging admins or groups unnecessarily"
}
api_url = "[Link]
if detected == mode:
try:
[Link](chat_id=group_id,
message_id=message.message_id)
deleted = int([Link]("deleted_total") or 0)
[Link]("deleted_total", deleted + 1)
except:
pass
# --------------------------------------------------
# 🚫 BLOCKED WORDS (admins immune)
# --------------------------------------------------
if not is_admin:
blocked_words = [Link](f"blocked_words_{group_id}") or []
for bw in blocked_words:
word = [Link]("word", "").strip()
mode = [Link]("mode", "included")
if not word:
continue
match_found = False
if mode == "precise" and text_lower == word_lower:
match_found = True
elif mode == "included":
words_in_text = text_lower.split()
if word_lower in words_in_text and len(words_in_text) > 1:
match_found = True
if match_found:
try:
[Link](group_id, message.message_id)
except:
pass
raise ReturnCommand()
# --------------------------------------------------
# ✅ ACTIVITY LOGGER
# --------------------------------------------------
if not deleted_flag:
settings = [Link](f"activity_settings_{group_id}") or {}
count_admins = [Link]("count_admins", False)
msg_cldwn = int([Link]("msg_cldwn", 0))
# ✅ Cooldown check
cooldown_key = f"activity_cooldown_{group_id}_{user_id}"
last_time = float([Link](cooldown_key) or 0)
now = [Link]()
time_left = int(last_time + msg_cldwn - now)
if time_left <= 0:
points_key = f"user_points_{group_id}_{user_id}"
current_points = int([Link](points_key) or 0)
[Link](points_key, current_points + 1)
user_list_key = f"activity_user_list_{group_id}"
user_list = [Link](user_list_key) or []
if str(user_id) not in user_list:
user_list.append(str(user_id))
[Link](user_list_key, user_list)
[Link](cooldown_key, now)
/activity_cooldown
==================
# /activity_cooldown <group_id> [seconds]
if [Link] != "private":
raise ReturnCommand()
split = [Link]().split()
group_id = split[0]
selected = int(split[1]) if len(split) > 1 else None
u = [Link]
ctx = [Link]("settings_context")
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin in the group to manage this
setting.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
# ✅ Message text
text = (
f"<b> Message Cooldown Settings</b>\n\n"
f"This sets the period in seconds in which a user can only gain 1 activity
point per message.\n\n"
f"Current cooldown: <b>{settings['msg_cldwn']} seconds</b>\n\n"
f"Select a new cooldown from the options below:"
)
# ✅ Edit message
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
except:
[Link](
u,
text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
/activity_lb
============
# /activity_lb
# ✅ Configurable cooldown in minutes
COOLDOWN_MINUTES = 10 # Change this value to set cooldown duration
COOLDOWN_SECONDS = COOLDOWN_MINUTES * 60
# ✅ Group validation
if [Link] not in ["group", "supergroup"]:
raise ReturnCommand()
group_id = [Link]
user_id = message.from_user.id
group_title = [Link] or "this group"
# ✅ Admin check
is_admin = False
try:
member = [Link](group_id, user_id)
is_admin = [Link] in ["administrator", "creator"]
except:
pass
# ✅ Trigger permission
if trigger_mode == "admins" and not is_admin:
[Link](
group_id,
"🚫 Only admins can trigger the activity leaderboard. Change this in
/settings"
)
raise ReturnCommand()
if time_left > 0:
last_msg_data = [Link](f"last_activity_lb_msg_{group_id}")
if last_msg_data:
last_msg_id = last_msg_data.get("message_id")
if last_msg_id:
msg_link = f"[Link]
[Link](
group_id,
f"⏳ Please wait {format_time(time_left)} before checking the
activity leaderboard again.\n\n"
f"🔁 You can still view the <a href=\"{msg_link}\">last leaderboard
here</a>.",
parse_mode="HTML"
)
raise ReturnCommand()
[Link](
group_id,
f"⏳ Please wait {format_time(time_left)} before checking the activity
leaderboard again."
)
raise ReturnCommand()
# ✅ Set cooldown
if not is_admin:
[Link](cooldown_key, str(now + COOLDOWN_SECONDS))
entries = []
for uid_str in user_ids:
uid = int(uid_str)
points_key = f"user_points_{group_id}_{uid}"
points = int([Link](points_key) or 0)
[Link]((uid, points))
# ✅ Sort descending
[Link](key=lambda x: x[1], reverse=True)
limit = int([Link](f"group_lb_limit_{group_id}") or 10)
top_users = entries[:limit]
if not top_users:
[Link](group_id, "📭 No activity points recorded yet in this group.")
raise ReturnCommand()
/activity_settings
==================
if [Link] != "private":
raise ReturnCommand()
group_id = [Link]()
u = [Link]
ctx = [Link]("settings_context")
# ✅ Verify session
if not ctx or str(ctx["group_id"]) != group_id:
[Link](u, "❌ Invalid or expired session.")
raise ReturnCommand()
buttons = [
[InlineKeyboardButton(trigger_label, callback_data=f"/toggle_activity
{group_id} trigger")],
[InlineKeyboardButton(count_label, callback_data=f"/toggle_activity {group_id}
count_media")],
[InlineKeyboardButton(cooldown_label, callback_data=f"/activity_cooldown
{group_id}")],
[InlineKeyboardButton(count_admin_label, callback_data=f"/toggle_activity
{group_id} count_admins")],
[InlineKeyboardButton("♻️ Reset Activity", callback_data=f"/reset_activity
{group_id}")],
[InlineKeyboardButton("🔙 Back", callback_data="/settings_dm")]
]
text = (
f"<b>📊 Activity Settings for:</b> {group_title}\n\n"
f"• <b>Leaderboard Trigger</b>: Choose if only admins or everyone can use the
leaderboard.\n"
f"• <b>Count Media</b>: Decide if sending photos, GIFs, or stickers also give
activity points.\n"
f"• <b>Message Cooldown</b>: Limit how often activity points are given.\n"
f"• <b>Count Admins</b>: Decide if admin messages also count.\n"
f"• <b>Reset Activity</b>: Clears all saved activity points for this group."
)
/add_blocked_word
=================
# Command: /add_blocked_word
if [Link] != "private":
raise ReturnCommand()
u = message.from_user.id
ctx = [Link]("settings_context")
group_id = ctx["group_id"]
group_title = ctx["group_title"]
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to manage blocked words.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
if not mode:
# Ask the admin how they want to block the word
text = (
f"🛡 *Add Blocked Word in {group_title}*\n\n"
"Choose how you want to block the word:\n"
"• *Included Block* → Blocks if word/phrase appears anywhere in a message\
n"
"• *Precise Block* → Blocks only if the word/phrase is sent alone"
)
btns = {
"inline_keyboard": [
[{"text": "🔎 Included Block", "callback_data": f"/add_blocked_word
{group_id} included"}],
[{"text": "🎯 Precise Block", "callback_data": f"/add_blocked_word
{group_id} precise"}],
[{"text": "🔙 Back", "callback_data": f"/list_blocked_words
{group_id}"}]
]
}
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="markdown",
reply_markup=btns
)
except:
[Link](
u,
text,
parse_mode="markdown",
reply_markup=btns
)
raise ReturnCommand()
text = (
f"✍️ *Add Blocked Word ({[Link]()} Block)*\n\n"
"Please send the word or phrase you want to block.\n\n"
"👉 Send `X` to cancel."
)
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="markdown"
)
group_id = [Link]()
u = [Link]
ctx = [Link]("settings_context")
# ✅ Verify session
if not ctx or str(ctx["group_id"]) != group_id:
[Link](u, "❌ Invalid or expired session.")
raise ReturnCommand()
# ✅ Back button
[Link]([InlineKeyboardButton("🔙 Back", callback_data="/settings_dm")])
# ✅ Message text
text = (
f"<b>🚫 Block Settings for:</b> {group_title}\n\n"
f"Toggle options below.\n\n"
f"Anything marked ✅ will be deleted by the bot automatically."
)
/check_swr
==========
group_id = [Link]
user_id = message.from_user.id
text = ([Link] or "").strip().lower()
session = [Link](f"swr_session_{group_id}")
if not session or not [Link]("current_word"):
[Link](group_id, "⚠️ No active round found.")
raise ReturnCommand()
correct_word = session["current_word"].lower()
if text == correct_word:
players = [Link]("players", {})
if str(user_id) not in players:
players[str(user_id)] = {"score": 0, "name": message.from_user.first_name}
players[str(user_id)]["score"] += 1
session["players"] = players
[Link](f"swr_session_{group_id}", session)
[Link](10, "/start_swr")
else:
[Link](group_id, f"❌ {message.from_user.first_name} guessed incorrectly.
Try again!")
[Link]("/check_swr")
/edit_goodbye
=============
# /edit_goodbye
if [Link] != "private":
raise ReturnCommand()
u = [Link]
group_id = [Link]()
ctx = [Link]("settings_context")
# ✅ Verify session
if not ctx or str([Link]("group_id")) != group_id:
[Link](u, "❌ Invalid or expired session.")
raise ReturnCommand()
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to manage these settings.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="html"
)
except:
[Link](u, text, parse_mode="html")
/edit_welcome
=============
if [Link] != "private":
raise ReturnCommand()
group_id = [Link]()
u = [Link]
ctx = [Link]("settings_context")
# ✅ Verify session
if not ctx or str([Link]("group_id")) != group_id:
[Link](u, "❌ Invalid or expired session.")
raise ReturnCommand()
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to manage these settings.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
try:
[Link](chat_id=u, message_id=message.message_id, text=text,
parse_mode="html")
except:
[Link](u, text, parse_mode="html")
/filter
=======
# Command: /filter
if [Link] not in ["group", "supergroup"]:
raise ReturnCommand()
group_id = [Link]
u = message.from_user.id
# ✅ Admin check
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](group_id, f"❌ {[Link](u)}, only group admins can set
filters.")
raise ReturnCommand()
except:
[Link](u, "⚠️ Failed to verify admin permissions.")
raise ReturnCommand()
parts = [Link](maxsplit=2)
if len(parts) < 2:
[Link](group_id, "❌ Usage:\n`/filter trigger response`",
parse_mode="markdown")
raise ReturnCommand()
trigger = parts[1].lower()
response = None
filters = [Link](f"filters_{group_id}") or {}
filters[trigger] = response
[Link](f"filters_{group_id}", filters)
[Link](
group_id,
f"✅ Filter added!\nWhenever someone says *{trigger}*, I'll reply with your
response.",
parse_mode="markdown"
)
/filter_list
============
# Command: /filter_list
if [Link] not in ["group", "supergroup"]:
raise ReturnCommand()
group_id = [Link]
u = message.from_user.id
# ✅ Admin check
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](group_id, f"❌ {[Link](u)}, only group admins can
view filters.")
raise ReturnCommand()
except:
[Link](u, "⚠️ Failed to verify admin permissions.")
raise ReturnCommand()
filters = [Link](f"filters_{group_id}") or {}
if not filters:
[Link](group_id, "_No filters set for this group._",
parse_mode="markdown")
else:
triggers = "\n".join([f"• {t}" for t in [Link]()])
[Link](group_id, f"📃 *Active Filters:*\n{triggers}",
parse_mode="markdown")
/filter_settings
================
# Command: /filter_settings <group_id>
if [Link] != "private":
raise ReturnCommand()
u = message.from_user.id
params = [Link]().split() if params else []
if not params:
raise ReturnCommand()
group_id = int(params[0])
ctx = [Link]("settings_context")
text = (
"🧹 *Filter Settings*\n\n"
"Filtered words let the bot automatically respond whenever someone uses them in
the group.\n\n"
"👉 *How to set up:*\n"
"• `/filter trigger response` → Add a filter (trigger = one word, response =
any text)\n"
"• Reply to a message with `/filter trigger` → Makes the replied message the
response\n\n"
"👉 *Managing filters:*\n"
"• `/stop_filter trigger` → Remove a filter\n"
"• `/filter_list` → Show all active triggers\n\n"
"⚠️ Note: Only one word can be the trigger, but the response can be as long as
you want."
)
btns = {
"inline_keyboard": [
[{"text": "⬅️ Back", "callback_data": f"/settings_dm"}],
[{"text": "❌ Close", "callback_data": "/close_dm"}]
]
}
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="markdown",
reply_markup=btns
)
except:
[Link](
u,
text,
parse_mode="markdown",
reply_markup=btns
)
/game
=====
# Command: /game <game_code>
if [Link] not in ["group", "supergroup"]:
raise ReturnCommand()
group_id = [Link]
game_code = [Link]().lower() if params else ""
/games
======
# Command: /games
if [Link] not in ["group", "supergroup"]:
raise ReturnCommand()
group_id = [Link]
buttons = {
"inline_keyboard": [
[{"text": "🏆 Secret Word Race", "callback_data": "/game swr"}],
[{"text": " Catch the Thief", "callback_data": "/game ctt"}]
]
}
/goodbye_message
================
# /goodbye_message
if [Link] != "private":
raise ReturnCommand()
u = [Link]
ctx = [Link]("settings_context")
# ✅ Verify session
if not ctx or str([Link]("group_id")) != group_id:
[Link](u, "❌ Invalid or expired session.")
raise ReturnCommand()
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to manage these settings.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
buttons = [
[InlineKeyboardButton(f"Goodbye Messages: {toggle_label}",
callback_data=f"/toggle_goodbye {group_id}")],
[InlineKeyboardButton("✏️ Customize Goodbye Message",
callback_data=f"/edit_goodbye {group_id}")],
[InlineKeyboardButton("📄 View Current Goodbye Message",
callback_data=f"/view_goodbye {group_id}")],
[InlineKeyboardButton("🔙 Back", callback_data=f"/welcome_goodbye {group_id}")]
]
text = (
f"<b>💔 Goodbye Message Settings for:</b> {group_title}\n\n"
f"• Toggle goodbye messages on or off.\n"
f"• Customize the goodbye message text.\n"
f"• View the current goodbye message."
)
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
except:
[Link](
u,
text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
/handler_chat_member
====================
# /handler_chat_member
try:
if [Link] in ["group", "supergroup"]:
group_id = [Link]
group_title = [Link] or "Unnamed"
welcome_settings = [Link](f"welcome_settings_{group_id}") or {
"enabled": False,
"message": "Welcome {name} to {group}!"
}
if welcome_settings.get("enabled"):
saved = [Link](f"welcome_message_{group_id}") or {}
welcome_text = [Link]("text", welcome_settings["message"])
welcome_text = welcome_text.replace("{name}", first_name)
welcome_text = welcome_text.replace("{username}", username)
welcome_text = welcome_text.replace("{group}", group_title)
welcome_photo = [Link]("photo")
welcome_video = [Link]("video")
buttons = []
btns = [Link](f"welcome_buttons_{group_id}") or []
for row in btns:
row_buttons = []
for btn in row:
row_buttons.append(InlineKeyboardButton(btn["text"],
url=btn["url"]))
if row_buttons:
[Link](row_buttons)
if welcome_photo:
[Link](
chat_id=group_id,
photo=welcome_photo,
caption=welcome_text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons) if buttons else
None
)
elif welcome_video:
[Link](
chat_id=group_id,
video=welcome_video,
caption=welcome_text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons) if buttons else
None
)
else:
[Link](
chat_id=group_id,
text=welcome_text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons) if buttons else
None
)
raise ReturnCommand()
goodbye_settings = [Link](f"goodbye_settings_{group_id}") or {
"enabled": False,
"message": "Goodbye {name}, we will miss you!"
}
if goodbye_settings.get("enabled"):
saved = [Link](f"goodbye_message_{group_id}") or {}
goodbye_text = [Link]("text", goodbye_settings["message"])
goodbye_text = goodbye_text.replace("{name}", first_name)
goodbye_text = goodbye_text.replace("{username}", username)
goodbye_text = goodbye_text.replace("{group}", group_title)
raise ReturnCommand()
except Exception as e:
raise ReturnCommand()
/invite_settings
================
if [Link] != "private":
raise ReturnCommand()
u = message.from_user.id
group_id = [Link]()
ctx = [Link]("settings_context")
buttons = InlineKeyboardMarkup([
[InlineKeyboardButton("⚙️ Invite System Controls",
callback_data=f"/invite_config_menu {group_id}")],
[InlineKeyboardButton("🔢 Max Invite Limit", callback_data=f"/invite_max_config
{group_id}")],
[InlineKeyboardButton("🧩 Captcha Settings",
callback_data=f"/captcha_config_menu {group_id}")],
[InlineKeyboardButton("🔙 Back", callback_data="/settings_dm")]
])
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="html",
reply_markup=buttons
)
except:
[Link](u, text, parse_mode="html", reply_markup=buttons)
/lbformat
=========
if [Link] != "private":
raise ReturnCommand()
u = [Link]
group_id = [Link]()
ctx = [Link]("settings_context")
options = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]
rows, temp = [], []
if temp:
[Link](temp)
try:
[Link](chat_id=u, message_id=message.message_id, text=text,
parse_mode="html", reply_markup=InlineKeyboardMarkup(rows))
except:
[Link](u, text, parse_mode="html",
reply_markup=InlineKeyboardMarkup(rows))
/lbformat_set
=============
if [Link] != "private":
raise ReturnCommand()
u = [Link]
split = [Link]().split(" ")
if len(split) != 2:
[Link](u, "⚠️ Invalid usage.")
raise ReturnCommand()
options = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]
rows, temp = [], []
if temp:
[Link](temp)
try:
[Link](chat_id=u, message_id=message.message_id,
reply_markup=InlineKeyboardMarkup(rows))
except:
pass
/lbreset
========
# Command: /lbreset <group_id> <yes/no>
if [Link] not in ["group", "supergroup", "private"]:
raise ReturnCommand()
u = message.from_user.id
params = [Link]().split() if params else []
if len(params) < 1:
[Link](u, "❌ Group ID missing.")
raise ReturnCommand()
group_id = int(params[0])
choice = params[1].lower() if len(params) > 1 else ""
# ✅ Admin check
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 Only admins can reset the leaderboard.")
raise ReturnCommand()
except:
[Link](u, "⚠️ Failed to verify permissions.")
raise ReturnCommand()
try:
[Link](chat_id=group_id, message_id=message.message_id)
except:
pass # silently ignore if message doesn't exist
else:
# Ask for confirmation
btns = InlineKeyboardMarkup([
[
InlineKeyboardButton("✅ Yes", callback_data=f"/lbreset {group_id}
yes"),
InlineKeyboardButton("❌ No", callback_data=f"/lbreset {group_id} no")
]
])
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=f"⚠️ This will clear the *invite & activity leaderboard* for the
group ({group_id}).\n\n"
"Are you sure you want to proceed?",
parse_mode="Markdown",
reply_markup=btns
)
except:
[Link](
u,
f"⚠️ This will clear the *invite & activity leaderboard* for the group
({group_id}).\n\n"
"Are you sure you want to proceed?",
parse_mode="Markdown",
reply_markup=btns
)
raise ReturnCommand()
/lbtrigger
==========
if [Link] != "private":
raise ReturnCommand()
group_id = [Link]()
u = [Link]
ctx = [Link]("settings_context")
try:
[Link](chat_id=u, message_id=message.message_id, text=text,
parse_mode="html", reply_markup=InlineKeyboardMarkup(buttons))
except:
[Link](u, text, parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons))
/leaderboard_settings
=====================
# /leaderboard_settings_dm <group_id>
if [Link] != "private":
raise ReturnCommand()
group_id = [Link]()
ctx = [Link]("settings_context")
buttons = {
"inline_keyboard": [
[{"text": " Leaderboard Trigger", "callback_data": f"/lbtrigger
{group_id}"}],
[{"text": "🎨 Edit Format", "callback_data": f"/lbformat {group_id}"}],
[{"text": "♻️ Reset Leaderboard", "callback_data": f"/lbreset
{group_id}"}],
[{"text": "🔙 Back", "callback_data": "/settings_dm"}]
]
}
try:
[Link](
chat_id=[Link],
message_id=message.message_id,
text=text,
parse_mode="markdown",
reply_markup=buttons
)
except:
[Link](u, text, parse_mode="markdown", reply_markup=buttons)
/list_blocked_words
===================
# Command: /list_blocked_words
if [Link] != "private":
raise ReturnCommand()
u = message.from_user.id
ctx = [Link]("settings_context")
group_id = ctx["group_id"]
group_title = ctx["group_title"]
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to view these settings.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
if not blocked_words:
text = f"📜 *Blocked Words for {group_title}:*\n\n_No blocked words set yet._"
else:
formatted = []
for w in blocked_words:
mode_icon = ""✂️
if w["mode"] == "precise" else " "
mode_name = "Precise" if w["mode"] == "precise" else "Included"
[Link](f"• `{w['word']}` — {mode_icon} *{mode_name}*")
word_list = "\n".join(formatted)
text = f"📜 *Blocked Words for {group_title}:*\n\n{word_list}"
btns = {
"inline_keyboard": [
[{"text": "➕ Add Blocked Word", "callback_data": f"/add_blocked_word
{group_id}"}],
[{"text": "➖ Remove Blocked Word", "callback_data": f"/remove_blocked_word
{group_id}"}],
[{"text": "🔙 Back", "callback_data": f"/word_blocks {group_id}"}]
]
}
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="markdown",
reply_markup=btns
)
except:
[Link](
u,
text,
parse_mode="markdown",
reply_markup=btns
)
/mute
=====
if [Link] not in ["group", "supergroup"]:
[Link]([Link], "⚠️ This command can only be used in groups.")
raise ReturnCommand()
if not params:
[Link]([Link], "❗ Usage: /mute <user_id or @username>")
raise ReturnCommand()
target = params[0]
try:
# Try treating it as an integer user_id
target_user_id = int(target)
except Exception:
# Otherwise, assume it's a username string like @username
target_user_id = target
try:
[Link](
chat_id=[Link],
user_id=target_user_id,
permissions={
"can_send_messages": False,
"can_send_media_messages": False,
"can_send_polls": False,
"can_add_web_page_previews": False,
"can_change_info": False,
"can_invite_users": True,
"can_pin_messages": False
}
)
[Link]([Link], f"✅ User <code>{target_user_id}</code> has been
muted.", {"parse_mode": "HTML"})
except Exception:
[Link]([Link], "❌ Failed to mute user.")
/remove_blocked_word
====================
# Command: /remove_blocked_word
if [Link] != "private":
raise ReturnCommand()
u = message.from_user.id
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to manage blocked words.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
# ✅ Save context
[Link]("remove_blocked_word_context", {"group_id": group_id})
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="markdown",
reply_markup=btns
)
except:
[Link](u, text, parse_mode="markdown", reply_markup=btns)
/reset_activity
===============
# /reset_activity <group_id> [yes|no]
if [Link] != "private":
raise ReturnCommand()
u = [Link]
split = [Link]().split(" ")
group_id = split[0]
confirm = split[1] if len(split) > 1 else None
ctx = [Link]("settings_context")
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin in the group to reset activity.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
text = (
f"<b>⚠️ Reset Activity Points</b>\n\n"
f"Are you sure you want to reset all user activity points for this group? "
f"This action cannot be undone."
)
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
except:
[Link](u, text, parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons))
raise ReturnCommand()
# Button labels
trigger_label = f"Leaderboard Trigger ({'Admins Only' if
settings['trigger']=='admins' else 'Everyone'})"
count_label = f"Count Media ({'ON ✅' if settings['count_media'] else 'OFF'})"
count_admin_label = f"Count Admins ({'ON ✅' if settings['count_admins'] else
'OFF'})"
cooldown_label = f"Message Cooldown ({settings['msg_cldwn']} s)"
buttons = [
[InlineKeyboardButton(trigger_label, callback_data=f"/toggle_activity
{group_id} trigger")],
[InlineKeyboardButton(count_label, callback_data=f"/toggle_activity
{group_id} count_media")],
[InlineKeyboardButton(cooldown_label, callback_data=f"/activity_cooldown
{group_id}")],
[InlineKeyboardButton(count_admin_label, callback_data=f"/toggle_activity
{group_id} count_admins")],
[InlineKeyboardButton("♻️ Reset Activity", callback_data=f"/reset_activity
{group_id}")],
[InlineKeyboardButton("🔙 Back", callback_data="/settings_dm")]
]
text = (
f"<b>📊 Activity Settings for:</b> {[Link]('group_title', 'Group')}\n\n"
f"• <b>Leaderboard Trigger</b>: Choose if only admins or everyone can use
the leaderboard.\n"
f"• <b>Count Media</b>: Decide if sending photos, GIFs, or stickers also
give activity points.\n"
f"• <b>Count Admins</b>: Decide if admin messages also count.\n"
f"• <b>Message Cooldown</b>: Limit how often activity points are given.\n"
f"• <b>Reset Activity</b>: Clears all saved activity points for this
group."
)
try:
[Link](chat_id=u, message_id=message.message_id,
text=text, parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons))
except:
pass
raise ReturnCommand()
deleted_count = 0
for uid_str in user_ids:
points_key = f"user_points_{group_id}_{uid_str}"
[Link](points_key)
deleted_count += 1
/save_blocked_word
==================
# Command: /save_blocked_word
if [Link] != "private":
raise ReturnCommand()
u = message.from_user.id
ctx = [Link]("blocked_word_context")
if not ctx:
[Link](u, "❌ No blocked word session found. Please start again with
/add_blocked_word.")
raise ReturnCommand()
group_id = ctx["group_id"]
mode = ctx["mode"]
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to manage blocked words.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
# ✅ Cancel check
word = [Link]()
if [Link]() == "x":
[Link](u, "❌ Blocked word creation cancelled.")
[Link]("blocked_word_context")
[Link]("/list_blocked_words")
raise ReturnCommand()
[Link](
u,
f"✅ Blocked word added:\n• Word: `{word}`\n• Mode: *{[Link]()}*",
parse_mode="markdown"
)
# ✅ Refresh list
[Link]("/list_blocked_words")
/save_buttons
=============
if [Link] != "private":
raise ReturnCommand()
u = [Link]
group_id = [Link]("welcome_edit_group")
ctx = [Link]("settings_context")
if not group_id:
[Link](u, "❌ No active session. Please start again.")
raise ReturnCommand()
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to manage these settings.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
# ✅ Handle skip
if [Link] and [Link]().upper() == "X":
[Link](f"welcome_buttons_{group_id}") # remove old buttons if any
[Link](u, "✅ Skipped adding buttons.")
[Link]("/welcome_goodbye")
raise ReturnCommand()
row_buttons = []
# split row by "-" → multiple buttons in same row
parts = row_text.split(" - ")
for part in parts:
try:
text, link = [Link]().split(" ", 1)
if not [Link]("http"):
raise ValueError
row_buttons.append({"text": text, "url": link})
except:
[Link](
u,
f"❌ Invalid button format in row: `{row_text}`\n\n"
"📌 Format:\n"
"[Text] [Link] - [Text] [Link]\n"
"➡️ `-` = same row\n"
"➡️ New line = new row\n\n"
"Send `X` to skip.",
parse_mode="Markdown"
)
[Link]("/save_buttons")
raise ReturnCommand()
if row_buttons:
[Link](row_buttons)
# ✅ Save buttons
[Link](f"welcome_buttons_{group_id}", buttons)
/save_goodbye
=============
if [Link] == "private":
u = [Link]
# Retrieve group ID from temporary storage
group_id = [Link]("goodbye_edit_group")
if not group_id:
[Link]("❌ No active session.")
raise ReturnCommand()
# Extract message parts, handling for both image and text messages
goodbye_text = [Link] if [Link] else [Link] if
[Link] else ""
goodbye_photo = [Link][-1].file_id if [Link] else None
goodbye_video = [Link].file_id if [Link] else None
saved = [Link](f"goodbye_message_{group_id}")
if [Link]("photo"):
[Link](
photo=saved["photo"],
caption=[Link]("text", "✅ Goodbye message saved successfully!"),
parse_mode="HTML"
)
elif [Link]("video"):
[Link](
video=saved["video"],
caption=[Link]("text", "✅ Goodbye message saved successfully!"),
parse_mode="HTML"
)
else:
[Link](
chat_id=u,
text=f"✅ Goodbye message saved successfully!\n\n{[Link]('text',
'')}",
parse_mode="HTML"
)
except:
[Link](u, "❌ Could not save goodbye settings. Please try again.")
/save_removed_word
==================
# Command: /save_removed_word
if [Link] != "private":
raise ReturnCommand()
u = message.from_user.id
ctx = [Link]("remove_blocked_word_context")
if not ctx:
[Link](u, "❌ No removal session found. Please start again with
/remove_blocked_word.")
raise ReturnCommand()
group_id = ctx["group_id"]
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to manage blocked words.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
# ✅ Cancel check
word = [Link]()
if [Link]() == "x":
[Link](u, "❌ Blocked word removal cancelled.")
[Link]("remove_blocked_word_context")
[Link]("/list_blocked_words")
raise ReturnCommand()
if len(new_list) == len(blocked_words):
[Link](u, f"⚠️ No blocked word found matching `{word}`.",
parse_mode="markdown")
else:
[Link](f"blocked_words_{group_id}", new_list)
[Link](u, f"✅ Blocked word `{word}` has been removed.",
parse_mode="markdown")
# ✅ Clear context
[Link]("remove_blocked_word_context")
# ✅ Refresh list
[Link]("/list_blocked_words")
/save_welcome
=============
# /save_welcome
if [Link] == "private":
u = [Link]
# Retrieve group ID from temporary storage
group_id = [Link]("welcome_edit_group")
if not group_id:
[Link](u, "❌ No active session.")
raise ReturnCommand()
# Extract text/media
welcome_text = [Link] if [Link] else [Link] if
[Link] else ""
welcome_photo = [Link][-1].file_id if [Link] else None
welcome_video = [Link].file_id if [Link] else None
saved = [Link](f"welcome_message_{group_id}")
if [Link]("photo"):
[Link](
photo=saved["photo"],
caption=[Link]("text", "✅ Welcome message saved successfully!"),
parse_mode="HTML"
)
elif [Link]("video"):
[Link](
video=saved["video"],
caption=[Link]("text", "✅ Welcome message saved successfully!"),
parse_mode="HTML"
)
else:
[Link](
chat_id=u,
text=f"✅ Welcome message saved successfully!\n\n{[Link]('text',
'')}",
parse_mode="HTML"
)
except:
[Link]("❌ Could not save welcome settings. Please try again.")
/scan_mode
==========
if [Link] != "private":
raise ReturnCommand()
group_id = [Link]()
u = [Link]
ctx = [Link]("settings_context")
# ✅ Verify session
if not ctx or str(ctx["group_id"]) != group_id:
[Link](u, "❌ Invalid or expired session.")
raise ReturnCommand()
stored_modes = [Link](f"group_modes_{group_id}")
modes = stored_modes if stored_modes is not None else []
buttons = [[InlineKeyboardButton(
f"{'✅' if key in modes else '❌'} {label}",
callback_data=f"/toggle_mode {group_id} {key}"
)] for key, label in all_modes.items()]
try:
[Link](chat_id=u, message_id=message.message_id, text=text,
parse_mode="html", reply_markup=InlineKeyboardMarkup(buttons))
except:
[Link](u, text, parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons))
/set_captcha
============
if [Link] != "private":
raise ReturnCommand()
u = message.from_user.id
parts = [Link]().split(" ")
if len(parts) != 2:
raise ReturnCommand()
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin in the group to manage these
settings.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
if captcha_type not in ["emoji", "math"]:
[Link](u, "❌ Invalid captcha type.")
raise ReturnCommand()
text = (
f"<b>🤖 Captcha Settings</b>\n\n"
f"Choose the verification method new users must complete to join:\n\n"
f"Group: <b>{group_title}</b>"
)
options = {
"emoji": "Emoji Captcha",
"math": "Math Captcha"
}
buttons = []
for key, label in [Link]():
emoji_mark = "✅" if selected == key else "❌"
[Link]([InlineKeyboardButton(f"{emoji_mark} {label}",
callback_data=f"/set_captcha {group_id} {key}")])
[Link]([InlineKeyboardButton("🔙 Back to Invite Settings",
callback_data=f"/invite_settings {group_id}")])
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
except:
pass
/set_invite
===========
# /set_invite <group_id> <setting_key>
if [Link] != "private":
raise ReturnCommand()
u = [Link]
parts = [Link]().split(" ")
if len(parts) != 2:
raise ReturnCommand()
# ✅ Buttons
buttons = []
for key, label in [Link]():
emoji = "✅" if [Link](key, False) else "❌"
[Link]([InlineKeyboardButton(f"{emoji} {label}",
callback_data=f"/set_invite {group_id} {key}")])
[Link]([InlineKeyboardButton("🔙 Back", callback_data=f"/invite_settings
{group_id}")])
# ✅ Info text
text = f"<b>🔗 Invite Settings for:</b> {group_title}\n\n"
for key, label in [Link]():
state = "[ON]" if [Link](key, False) else "[OFF]"
text += f"• <b>{label}</b> {state}\n — {descriptions[key]}\n\n"
/set_invite_limit
=================
# /set_invite_limit <group_id> <value>
if [Link] != "private":
raise ReturnCommand()
u = [Link]
parts = [Link]().split(" ", 1)
if len(parts) != 2:
raise ReturnCommand()
[Link](f"group_invite_config_{group_id}", config)
text = (
f"<b>🎯 Invite Limit Settings</b>\n\n"
f"Define how many invite links each user can generate.\n\n"
f"Group: <b>{group_title}</b>\n"
f"Current limit: <b>{current}</b>"
)
btns = []
presets = [("No limit (OFF)", None), ("10 invites", 10), ("50 invites", 50), ("100
invites", 100)]
for label, val in presets:
emoji = "✅" if val == limit else "❌"
callback = f"/set_invite_limit {group_id} {val}" if val is not None else
f"/set_invite_limit {group_id} off"
[Link]([InlineKeyboardButton(f"{emoji} {label}", callback_data=callback)])
custom_label = f"Custom ✅ ({limit})" if limit and limit not in [10, 50, 100] else
"Custom…"
[Link]([InlineKeyboardButton(custom_label, callback_data=f"/set_invite_limit
{group_id} custom")])
[Link]([InlineKeyboardButton("🔙 Back to Invite Settings",
callback_data=f"/invite_settings {group_id}")])
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(btns)
)
except:
[Link](u, text, parse_mode="html",
reply_markup=InlineKeyboardMarkup(btns))
/settings_dm
============
# Command: /settings_dm
if [Link] != "private":
raise ReturnCommand()
u = message.from_user.id
ctx = [Link]("settings_context")
group_title = ctx["group_title"]
group_id = ctx["group_id"]
btns = {
"inline_keyboard": [
[{"text": "👋 Welcome & Goodbye Settings", "callback_data":
f"/welcome_goodbye {group_id}"}],
[{"text": "🚫 Block Settings", "callback_data": f"/block_settings
{group_id}"}],
[{"text": "🧹 Filter Settings", "callback_data": f"/filter_settings
{group_id}"}],
[{"text": "🧠 Scan Settings", "callback_data": f"/scan_mode {group_id}"}],
[{"text": "🏆 Leaderboard Settings", "callback_data":
f"/leaderboard_settings {group_id}"}],
[{"text": "🔗 Invite Settings", "callback_data": f"/invite_settings
{group_id}"}],
[{"text": "📊 Activity Settings", "callback_data": f"/activity_settings
{group_id}"}],
[{"text": "📝 Word Blocks", "callback_data": f"/word_blocks {group_id}"}],
[{"text": "❌ Close", "callback_data": "/close_dm"}]
]
}
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="markdown",
reply_markup=btns
)
except:
[Link](
u,
text,
parse_mode="markdown",
reply_markup=btns
)
/start_swr
==========
if [Link] not in ["group", "supergroup"]:
raise ReturnCommand()
group_id = [Link]
# Load session
session = [Link](f"swr_session_{group_id}")
if not session:
[Link](group_id, "❌ No SWR session found. Start a new game with `/swr
<rounds>`")
raise ReturnCommand()
# Increment round
session["rounds_done"] += 1
[Link](f"swr_session_{group_id}", session)
[Link](f"swr_session_{group_id}")
raise ReturnCommand()
try:
response = [Link]("[Link]
10000-english/master/[Link]")
word_list = str([Link]).splitlines()
filtered_words = [w for w in word_list if 3 <= len(w) <= 8]
word = [Link](filtered_words)
session["current_word"] = word
[Link](f"swr_session_{group_id}", session)
image_url = f"[Link]
[Link](
chat_id=group_id,
photo=image_url,
caption="📝 First person to type the secret word in the chat wins this
round!",
parse_mode="Markdown"
)
[Link]("/check_swr")
except Exception as e:
[Link](group_id, f"❌ Error fetching word list: {str(e)}")
/stop_filter
============
# Command: /stop_filter
if [Link] not in ["group", "supergroup"]:
raise ReturnCommand()
group_id = [Link]
u = message.from_user.id
# ✅ Admin check
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](group_id, f"❌ {[Link](u)}, only group admins can
remove filters.")
raise ReturnCommand()
except:
[Link](u, "⚠️ Failed to verify admin permissions.")
raise ReturnCommand()
parts = [Link](maxsplit=1)
if len(parts) < 2:
[Link](group_id, "❌ Usage: `/stop_filter trigger`",
parse_mode="markdown")
raise ReturnCommand()
trigger = parts[1].lower()
filters = [Link](f"filters_{group_id}") or {}
if trigger in filters:
del filters[trigger]
[Link](f"filters_{group_id}", filters)
[Link](group_id, f" Filter for *{trigger}* removed.",
parse_mode="markdown")
else:
[Link](group_id, f"⚠️ No filter found for *{trigger}*.",
parse_mode="markdown")
/stop_swr
=========
# Command: /stop_swr
if [Link] not in ["group", "supergroup"]:
raise ReturnCommand()
u = message.from_user.id
group_id = [Link]
# ✅ Admin check
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](group_id, "🚫 Only admins can stop a SWR session.")
raise ReturnCommand()
except:
[Link](group_id, "⚠️ Failed to verify admin status.")
raise ReturnCommand()
# ✅ Load session
session = [Link](f"swr_session_{group_id}")
if not session:
[Link](group_id, "⚠️ No active SWR session found.")
raise ReturnCommand()
# ✅ Delete session
[Link](f"swr_session_{group_id}")
[Link](group_id, "🛑 The current Secret Word Race session has been stopped.")
/swr
====
# Command: /swr <rounds>
if [Link] not in ["group", "supergroup"]:
raise ReturnCommand()
u = message.from_user.id
group_id = [Link]
# ✅ Admin check
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](group_id, "🚫 Only admins can start the SWR game.")
raise ReturnCommand()
except:
[Link](group_id, "⚠️ Failed to verify admin permissions.")
raise ReturnCommand()
rounds_total = int(params[0])
session = {
"group_id": group_id,
"rounds_total": rounds_total,
"rounds_done": 0,
"players": {},
"current_word": None
}
[Link](f"swr_session_{group_id}", session)
/toggle_activity
================
if [Link] != "private":
raise ReturnCommand()
split = [Link]()
if len(split) != 2:
[Link]([Link], "❌ Invalid parameters.")
raise ReturnCommand()
# ✅ Verify session
if not ctx or int(ctx["group_id"]) != group_id:
[Link](u, "❌ Invalid or expired session.")
raise ReturnCommand()
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin in the group to manage these
settings.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
# ✅ Toggle logic
if setting == "trigger":
settings["trigger"] = "everyone" if settings["trigger"] == "admins" else
"admins"
elif setting == "count_media":
settings["count_media"] = not settings["count_media"]
elif setting == "count_admins":
settings["count_admins"] = not settings["count_admins"]
else:
[Link](u, "❌ Unknown setting.")
raise ReturnCommand()
# ✅ Save changes
[Link](f"activity_settings_{group_id}", settings)
# ✅ Rebuild buttons
trigger_label = f"Leaderboard Trigger ({'Admins Only' if
settings['trigger']=='admins' else 'Everyone'})"
count_label = f"Count Media ({'ON ✅' if settings['count_media'] else 'OFF'})"
count_admin_label = f"Count Admins ({'ON ✅' if settings['count_admins'] else
'OFF'})"
cooldown_label = f"Message Cooldown ({settings['msg_cldwn']} s)"
buttons = [
[InlineKeyboardButton(trigger_label, callback_data=f"/toggle_activity
{group_id} trigger")],
[InlineKeyboardButton(count_label, callback_data=f"/toggle_activity {group_id}
count_media")],
[InlineKeyboardButton(cooldown_label, callback_data=f"/activity_cooldown
{group_id}")],
[InlineKeyboardButton(count_admin_label, callback_data=f"/toggle_activity
{group_id} count_admins")],
[InlineKeyboardButton("♻️ Reset Activity", callback_data=f"/reset_activity
{group_id}")],
[InlineKeyboardButton("🔙 Back", callback_data="/settings_dm")]
]
text = (
f"<b>📊 Activity Settings for:</b> {group_title}\n\n"
f"• <b>Leaderboard Trigger</b>: Choose if only admins or everyone can use the
leaderboard.\n"
f"• <b>Count Media</b>: Decide if sending photos, GIFs, or stickers also give
activity points.\n"
f"• <b>Message Cooldown</b>: Limit how often activity points are given.\n"
f"• <b>Count Admins</b>: Decide if admin messages also count.\n"
f"• <b>Reset Activity</b>: Clears all saved activity points for this group."
)
/toggle_block
=============
if [Link] != "private":
raise ReturnCommand()
u = [Link]
split = [Link](" ")
if len(split) != 2:
[Link](u, "❌ Invalid usage.")
raise ReturnCommand()
# ✅ Toggle block
if block_key in blocks:
[Link](block_key)
else:
[Link](block_key)
# ✅ Save back
[Link](f"group_blocks_{group_id}", blocks)
# ✅ Rebuild buttons
buttons = [[InlineKeyboardButton(
f"{'✅' if key in blocks else '❌'} {label}",
callback_data=f"/toggle_block {group_id} {key}"
)] for key, label in all_blocks.items()]
# ✅ Updated menu
text = f"<b>🚫 Block Settings for:</b> {[Link]('group_title', 'Group')}\n\nTap to
toggle block types."
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
except:
pass
/toggle_goodbye
===============
# /toggle_goodbye
if [Link] != "private":
raise ReturnCommand()
u = [Link]
ctx = [Link]("settings_context")
# ✅ Verify session
if not ctx or str([Link]("group_id")) != group_id:
[Link](u, "❌ Invalid or expired session.")
raise ReturnCommand()
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to manage these settings.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
# ✅ Save changes
[Link](f"goodbye_settings_{group_id}", goodbye_settings)
# ✅ Rebuild buttons
toggle_label = "✅ On" if goodbye_settings["enabled"] else "❌ Off"
buttons = [
[InlineKeyboardButton(f"Goodbye Messages: {toggle_label}",
callback_data=f"/toggle_goodbye {group_id}")],
[InlineKeyboardButton("✏️ Customize Goodbye Message",
callback_data=f"/edit_goodbye {group_id}")],
[InlineKeyboardButton("📄 View Current Goodbye Message",
callback_data=f"/view_goodbye {group_id}")],
[InlineKeyboardButton("🔙 Back", callback_data=f"/welcome_goodbye {group_id}")]
]
text = (
f"<b>💔 Goodbye Message Settings for:</b> {group_title}\n\n"
f"• Toggle goodbye messages on or off.\n"
f"• Customize the goodbye message text.\n"
f"• View the current goodbye message."
)
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
except:
[Link](
u,
text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
/toggle_mode
============
if [Link] != "private":
raise ReturnCommand()
u = [Link]
split = [Link](" ")
if len(split) != 2:
[Link](u, "❌ Invalid usage.")
raise ReturnCommand()
stored_modes = [Link](f"group_modes_{group_id}")
modes = stored_modes if stored_modes is not None else []
if mode_key in modes:
[Link](mode_key)
else:
[Link](mode_key)
[Link](f"group_modes_{group_id}", modes)
buttons = [[InlineKeyboardButton(
f"{'✅' if key in modes else '❌'} {label}",
callback_data=f"/toggle_mode {group_id} {key}"
)] for key, label in all_modes.items()]
try:
[Link](chat_id=u, message_id=message.message_id, text=text,
parse_mode="html", reply_markup=InlineKeyboardMarkup(buttons))
except:
pass
/toggle_welcome
===============
if [Link] != "private":
raise ReturnCommand()
group_id = [Link]()
u = [Link]
ctx = [Link]("settings_context")
# ✅ Verify session
if not ctx or str([Link]("group_id")) != group_id:
[Link](u, "❌ Invalid or expired session.")
raise ReturnCommand()
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to manage these settings.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
# ✅ Save changes
[Link](f"welcome_settings_{group_id}", welcome_settings)
buttons = [
[InlineKeyboardButton(f"Welcome Messages: {toggle_label}",
callback_data=f"/toggle_welcome {group_id}")],
[InlineKeyboardButton("✏️ Customize Welcome Message",
callback_data=f"/edit_welcome {group_id}")],
[InlineKeyboardButton("📄 View Current Welcome Message",
callback_data=f"/view_welcome {group_id}")],
[InlineKeyboardButton("🔙 Back", callback_data=f"/welcome_goodbye {group_id}")]
]
text = (
f"<b>👋 Welcome Message Settings for:</b> {group_title}\n\n"
f"• Toggle welcome messages on or off.\n"
f"• Customize the welcome message text.\n"
f"• View the current welcome message."
)
/view_goodbye
=============
# /view_goodbye
if [Link] != "private":
raise ReturnCommand()
u = [Link]
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to view these settings.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
# ✅ Back button
reply_markup = {
"inline_keyboard": [
[{"text": "🔙 Back", "callback_data": f"/goodbye_message {group_id}"}]
]
}
/view_welcome
=============
# Command: /view_welcome
if [Link] != "private":
raise ReturnCommand()
u = [Link]
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to view these settings.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
u = [Link]
ctx = [Link]("settings_context")
# ✅ Verify session
if not ctx or str([Link]("group_id")) != group_id:
[Link](u, "❌ Invalid or expired session.")
raise ReturnCommand()
text = (
f"<b>👋 Welcome & Goodbye Settings for:</b> {group_title}\n\n"
f"Choose which message you want to configure."
)
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
except:
[Link](
u,
text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
/welcome_message
================
if [Link] != "private":
raise ReturnCommand()
u = [Link]
ctx = [Link]("settings_context")
# ✅ Verify session
if not ctx or str([Link]("group_id")) != group_id:
[Link](u, "❌ Invalid or expired session.")
raise ReturnCommand()
# ✅ Verify admin
try:
member = [Link](group_id, u)
if [Link] not in ["administrator", "creator"]:
[Link](u, "🚫 You must be an admin to manage these settings.")
raise ReturnCommand()
except:
[Link](u, "❌ Could not verify your admin status.")
raise ReturnCommand()
buttons = [
[InlineKeyboardButton(f"Welcome Messages: {toggle_label}",
callback_data=f"/toggle_welcome {group_id}")],
[InlineKeyboardButton("✏️ Customize Welcome Message",
callback_data=f"/edit_welcome {group_id}")],
[InlineKeyboardButton("📄 View Current Welcome Message",
callback_data=f"/view_welcome {group_id}")],
[InlineKeyboardButton("🔙 Back", callback_data=f"/welcome_goodbye {group_id}")]
]
text = (
f"<b>👋 Welcome Message Settings for:</b> {group_title}\n\n"
f"• Toggle welcome messages on or off.\n"
f"• Customize the welcome message text.\n"
f"• View the current welcome message."
)
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
except:
[Link](
u,
text,
parse_mode="html",
reply_markup=InlineKeyboardMarkup(buttons)
)
/word_blocks
============
# /word_blocks
if [Link] != "private":
raise ReturnCommand()
u = message.from_user.id
ctx = [Link]("settings_context")
group_title = ctx["group_title"]
group_id = ctx["group_id"]
btns = {
"inline_keyboard": [
[{"text": "📃 List of Blocked Words", "callback_data": f"/list_blocked_words
{group_id}"}],
[{"text": "➕ Add Blocked Word", "callback_data": f"/add_blocked_word
{group_id}"}],
[{"text": "➖ Remove Blocked Word", "callback_data": f"/remove_blocked_word
{group_id}"}],
[{"text": "🔙 Back", "callback_data": f"/settings_dm"}]
]
}
try:
[Link](
chat_id=u,
message_id=message.message_id,
text=text,
parse_mode="markdown",
reply_markup=btns
)
except:
[Link](
u,
text,
parse_mode="markdown",
reply_markup=btns
)
@
=
# /handler_bot_added
try:
my_bot_id = 7995887863 # <-- your bot ID here
try:
try:
count = [Link](chat_id=group_id)
except:
count = 0
join_text = (
"🤖 <b>Elite Group Bot has arrived!</b>\n\n"
"✨ I help keep your community clean & engaging:\n"
"🛡 Auto-delete spam, toxicity & profanity\n"
"📩 Track invites & run contests with ease\n"
"📊 Analytics & referral rewards system\n\n"
f"⚙️ Type <b>/settings</b> to set me up in <b>{group_title}</b>!\n\
n"
"🚀 Let's make this group safer, smarter, and more fun together!"
)
[Link](chat_id=group_id, text=join_text, parse_mode="html")
raise ReturnCommand()
serve
=====
# Command: /check_swr
if [Link] not in ["group", "supergroup"]:
raise ReturnCommand()
group_id = [Link]
user_id = message.from_user.id
text = ([Link] or "").strip().lower() # this is correct; no extra definition
needed
# ✅ Load session
session = [Link](f"swr_session_{group_id}")
if not session or not [Link]("current_word"):
[Link](group_id, "⚠️ No active round found.")
raise ReturnCommand()
# ✅ Check answer
correct_word = session["current_word"].lower()
if text == correct_word:
# ✅ Update player score
players = [Link]("players", {})
players[str(user_id)] = [Link](str(user_id), 0) + 1
session["players"] = players
[Link](f"swr_session_{group_id}", session)
else:
[Link](group_id, f"❌ {[Link]('name', user=user_id)} guessed
incorrectly. Try again!")
[Link](group_id, "⚠️ [DEBUG] Incorrect guess received, waiting for next
guess.")