|
import time |
|
from pyrogram import filters, Client |
|
from pyrogram.types import * |
|
from akn.utils.database import db |
|
from akn.langs import transdev |
|
|
|
@Client.on_callback_query(filters.regex("^arzlang_")) |
|
async def arzset_language(_, callback): |
|
lang_code = callback.data.split("_")[1] |
|
await db.alldl_bot.update_one( |
|
{"user_id": callback.from_user.id}, |
|
{"$set": {"language": lang_code}}, |
|
upsert=True |
|
) |
|
await callback.answer(f"Language set to {lang_code.upper()}!") |
|
await callback.message.edit_text( |
|
f"Language changed to {lang_code.upper()}! Use /start to see the changes.", |
|
) |
|
|
|
unmute_permissions = ChatPermissions( |
|
can_send_messages=True, |
|
can_send_media_messages=True, |
|
can_send_polls=True, |
|
can_change_info=False, |
|
can_invite_users=True, |
|
can_pin_messages=False, |
|
) |
|
|
|
GROUP_TEXTS = """ |
|
Hi {name} i am a modular group management bot with some fun extras. |
|
|
|
Resfresh Ping: `{ping}` |
|
|
|
i can do Azrea Bot of things, and help u manage your group effortlessly! |
|
|
|
All Command can be accessed by using: `/` |
|
**Click on help to learn more!** |
|
""" |
|
|
|
help_texts = { |
|
"ban": "**Ban Commands:**\n" |
|
"/ban - Ban a user\n" |
|
"/unban - Unban a user\n" |
|
"/tban - Temporary ban\n" |
|
"/banme - Ban yourself", |
|
|
|
"mute": "**Mute Commands:**\n" |
|
"/mute - Mute a user\n" |
|
"/unmute - Unmute user\n" |
|
"/tmute - Temporary mute\n" |
|
"/muteall - Mute all users\n" |
|
"/muteme - Mute yourself", |
|
|
|
"promote": "**Promotion Commands:**\n" |
|
"/promote - Promote user\n" |
|
"/demote - Demote user\n" |
|
"/title - Set admin title\n" |
|
"/adminlist - List admins", |
|
|
|
"clean": "**Cleaning Commands:**\n" |
|
"/del - Delete message\n" |
|
"/purge - Purge messages\n" |
|
"/delall - Delete all messages\n" |
|
"/setgpic - Set group photo", |
|
|
|
"lock": "**Locking Commands:**\n" |
|
"/lock - Lock permissions\n" |
|
"/unlock - Unlock permissions\n" |
|
"/locks - Current locks\n" |
|
"/locktypes - Available locks", |
|
|
|
"demote": "**Demotion Commands:**\n" |
|
"/demote - Demote user\n" |
|
"/undemote - Undemote user\n" |
|
"/demoteme - Demote yourself\n" |
|
"/demoteall - Demote all admins", |
|
|
|
"downloader": "**Downloader Commands:**\n" |
|
"/igdl - Instgram Downloader\n" |
|
"/ytv - Youtube Downloader\n" |
|
"/yta - Youtube Audio Downloader\n" |
|
"/ytva - Youtube Video Audio Downloader\n" |
|
"/fbdl - Facebook Downloader\n" |
|
"/ttdl - Tiktok Downloader\n" |
|
"/twtdl - Twitter Downloader\n" |
|
"/alldl - All Downloader\n", |
|
|
|
"stats": "**Statistics Commands:**\n" |
|
"/stats - View user statistics.\n" |
|
"/rmdup - Remove duplicate messages\n" |
|
"/broadcast - Send a message to all users.\n", |
|
|
|
"forcesub": "**Force Subscribe Commands (Owner-Only):**\n" |
|
"/addjoin - Force subscribe to a channel.\n", |
|
|
|
"blacklist": "**Blacklist Commands (Owner-Only):**\n" |
|
"/addblacklist - Ban a user from using bot commands.\n" |
|
"/rmblacklist - Unban a blacklisted user.\n" |
|
"/blacklistchat - Block a chat from using the bot.\n" |
|
"/viewblacklistusers - View blacklisted users.\n" |
|
"/whitelistchat - Unblock a chat from using the bot.\n" |
|
"/blacklistedchat - View blacklisted chats.\n", |
|
|
|
"botsettings": "**Bot Settings Commands (Owner-Only):**\n" |
|
"/nobutton - Toggle **ON/OFF** the `/start` button.\n" |
|
"/setpic - Change the bot's display picture (resend if needed)\n" |
|
"/delpic - Remove bot display picture (resend if needed).\n" |
|
} |
|
|
|
def get_help_texts(lang="en"): |
|
return { |
|
"ban": transdev.get("messages.help_ban", lang=lang), |
|
|
|
"mute": transdev.get("messages.help_mute", lang=lang), |
|
|
|
"promote": transdev.get("messages.help_promote", lang=lang), |
|
|
|
"clean": transdev.get("messages.help_clean", lang=lang), |
|
|
|
"lock": transdev.get("messages.help_lock", lang=lang), |
|
|
|
"demote": transdev.get("messages.help_demote", lang=lang), |
|
|
|
"downloader": transdev.get("messages.help_downloader", lang=lang), |
|
|
|
"stats": transdev.get("messages.help_stats", lang=lang), |
|
|
|
"forcesub": transdev.get("messages.help_forcesub", lang=lang), |
|
|
|
"blacklist": transdev.get("messages.help_blacklist", lang=lang), |
|
|
|
"botsettings": transdev.get("messages.help_botsettings", lang=lang), |
|
} |
|
|
|
|
|
@Client.on_message(filters.regex("^arzunban_(\d+)")) |
|
async def arzunban_callback(client, callback): |
|
user_id = int(callback.data.split("_")[1]) |
|
chat_id = callback.chat.id |
|
try: |
|
await client.unban_chat_member(chat_id, user_id) |
|
await callback.answer("User unbanned successfully!") |
|
except Exception as e: |
|
await callback.answer(f"Failed to unban user: {e}") |
|
|
|
@Client.on_message(filters.regex("^arzunmute_(\d+)")) |
|
async def arzunmute_callback(client, callback): |
|
user_id = int(callback.data.split("_")[1]) |
|
chat_id = callback.chat.id |
|
try: |
|
await client.restrict_chat_member(chat_id, user_id, permissions=unmute_permissions) |
|
await callback.answer("User unmuted successfully!") |
|
except Exception as e: |
|
await callback.answer(f"Failed to unmute user: {e}") |
|
|
|
@Client.on_callback_query( |
|
filters.regex("^rhelp_(ban|mute|promote|demote|clean|lock|downloader|stats|forcesub|blacklist|botsettings)$") |
|
) |
|
async def rxhelp_callback(client, callback): |
|
category = callback.data.split("_")[1] |
|
user_data = await db.alldl_bot.find_one({"user_id": callback.from_user.id}) |
|
lang = user_data.get("language", "en") if user_data else "en" |
|
help_text = get_help_texts(lang=lang) |
|
|
|
keyboard = InlineKeyboardMarkup([ |
|
[InlineKeyboardButton("π Back", callback_data="rhelps_back")] |
|
]) |
|
|
|
await callback.edit_message_text( |
|
help_text.get(category, "β Help text not found."), |
|
reply_markup=keyboard |
|
) |
|
|
|
|
|
@Client.on_callback_query(filters.regex("^rhelps_back")) |
|
async def rhelp_back(client, callback): |
|
start = time.time() |
|
await client.get_me() |
|
end = time.time() |
|
latency = (end - start) * 1000 |
|
keyboard = InlineKeyboardMarkup([ |
|
[ |
|
InlineKeyboardButton("π« Ban", callback_data="rhelp_ban"), |
|
InlineKeyboardButton("π Mute", callback_data="rhelp_mute") |
|
], |
|
[ |
|
InlineKeyboardButton("π Promote", callback_data="rhelp_promote"), |
|
InlineKeyboardButton("π‘οΈ Demote", callback_data="rhelp_demote") |
|
], |
|
[ |
|
InlineKeyboardButton("π§Ή Clean", callback_data="rhelp_clean"), |
|
InlineKeyboardButton("π Lock", callback_data="rhelp_lock") |
|
], |
|
[ |
|
InlineKeyboardButton("π₯ Downloader", callback_data="rhelp_downloader"), |
|
], |
|
[ |
|
InlineKeyboardButton("π Stats", callback_data="rhelp_stats") |
|
], |
|
[ |
|
InlineKeyboardButton("π Force Subscribe", callback_data="rhelp_forcesub"), |
|
InlineKeyboardButton("π‘οΈ Blacklist", callback_data="rhelp_blacklist") |
|
], |
|
[ |
|
InlineKeyboardButton("βοΈ Bot Settings", callback_data="rhelp_botsettings"), |
|
], |
|
[ |
|
InlineKeyboardButton("β Close", callback_data="cclose"), |
|
] |
|
]) |
|
user_data = await db.alldl_bot.find_one({"user_id": callback.from_user.id}) |
|
lang = user_data.get("language", "en") if user_data else "en" |
|
text_str = transdev.get( |
|
"messages.welcome", |
|
lang=lang, |
|
name=callback.from_user.mention , |
|
ping=f"{latency:.2f}ms", |
|
) |
|
await callback.edit_message_text( |
|
text_str, |
|
reply_markup=keyboard |
|
) |