Light Armor Bot
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152from telegram import Updatefrom telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackContext
# Replace with your bot tokenTOKEN = '7339830560:AAE43s3Uv025zSX-vvu2k4GbWaHr-P9UDTc'
# Welcome handlerdef welcome(update: Update, context: CallbackContext): # Check for new members new_members = update.message.new_chat_members if new_members: for member in new_members: welcome_message = f"Welcome {member.full_name}! 👋\nEnjoy your time here!" update.message.reply_text(welcome_message)
# Ban handlerdef ban_user(update: Update, context: CallbackContext): chat_id = update.message.chat_id user_id = update.message.reply_to_message.from_user.id if update.message.reply_to_message else None # Only allow admins to use the ban command if update.message.from_user.id == update.message.chat.admins[0].user.id: # Check if the bot is an admin if user_id: context.bot.ban_chat_member(chat_id, user_id) update.message.reply_text(f"User {user_id} has been banned.") else: update.message.reply_text("Please reply to a user's message you want to ban.") else: update.message.reply_text("You don't have permission to ban users!")
# Main functiondef main(): # Set up the Updater with the bot token updater = Updater(TOKEN, use_context=True)
# Get the dispatcher to register handlers dp = updater.dispatcher
# Register the welcome handler (for new members) dp.add_handler(MessageHandler(Filters.status_update.new_chat_members, welcome))
# Register the ban handler (for banning users) dp.add_handler(CommandHandler('ban', ban_user, pass_args=True, filters=Filters.reply))
# Start polling updater.start_polling()
# Run the bot until you manually stop it (Ctrl + C) updater.idle()
if __name__ == '__main__': main()Light ArmorAdded+52