mirror of
https://github.com/Noettore/lagomareGateKeeperBot.git
synced 2025-10-15 03:26:40 +02:00
Created modules and organized code
This commit is contained in:
16
handlers/credentials.py
Normal file
16
handlers/credentials.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from telegram import Update
|
||||
from telegram.ext import ContextTypes
|
||||
from models import Users, Credential, Role
|
||||
|
||||
async def setcredentials(update: Update, context: ContextTypes.DEFAULT_TYPE, users: Users):
|
||||
user_id = str(update.effective_user.id)
|
||||
args = context.args
|
||||
if len(args) != 2:
|
||||
return await update.message.reply_text("Usage: `/setcredentials <username> <password>`")
|
||||
role = users.get_role(user_id)
|
||||
if role not in (Role.ADMIN, Role.MEMBER):
|
||||
return await update.message.reply_text("Only members or admins can set credentials")
|
||||
if users.set_credentials(user_id, Credential(args[0], args[1])):
|
||||
await update.message.reply_text("Credentials saved")
|
||||
else:
|
||||
await update.message.reply_text("Error saving credentials")
|
Reference in New Issue
Block a user