soyelmismo / chatgpTG

GPT + Telegram = :D
MIT License
17 stars 4 forks source link

Feature request: possibility to block user #8

Open unameisfine opened 11 months ago

unameisfine commented 11 months ago

It can be usefull to add possibility to ban any user in bot. I realized my own solution with additional field "banned" in mongo database. And simple part of my code. But it can be not the best solution.

async def message_handle(update: Update, context: CallbackContext, message=None, use_new_dialog_timeout=True):
#check is banned
user_id = update.message.from_user.id
isbanned = db.get_user_attribute(user_id, "banned")
if isbanned == 1:
     await update.message.reply_text("You are banned!")
     return