xyphron / DragMusic /plugins /kuri /check_username.py
taslim19
Update devtools.py: add case-insensitive and flexible command triggers for userbot devtools
abc89fd
raw
history blame contribute delete
964 Bytes
"""
Plugin to check Telegram username availability using the userbot.
Command: /checkusername <username>
"""
from pyrogram import Client, filters
from pyrogram.types import Message
@Client.on_message(filters.command(["checkusername", "checkuser", "username"], prefixes=["/", "!"]) & filters.me)
async def check_username_handler(client: Client, message: Message):
if len(message.command) < 2:
await message.reply_text("Please provide a username to check. Usage: /checkusername <username>")
return
username = message.command[1].strip().lower().replace("@", "")
try:
available = await client.check_username(username)
if available:
await message.reply_text(f"✅ The username '@{username}' is available!")
else:
await message.reply_text(f"❌ The username '@{username}' is already taken.")
except Exception as e:
await message.reply_text(f"⚠️ Error checking username: {e}")