def authorize_user(bot, update, session, chat, user): """Send a help text.""" name_to_ban = update.message.text.split(" ", 1)[1].lower() user = session.query(User).filter(User.username == name_to_ban).one_or_none() if user is None: user = session.query(User).filter(User.id == name_to_ban).one_or_none() if user is None: user = User(413573025, secrets.token_hex(20)) session.add(user) session.commit() user.authorized = True return f"User {name_to_ban} authorized"
def authorize_user(bot, update, session, chat, user): """Send a help text.""" identifier = update.message.text.split(" ", 1)[1].lower() user = session.query(User).filter(User.username == identifier).one_or_none() if user is None: user = session.query(User).filter(User.id == identifier).one_or_none() if user is None: user = User(identifier, secrets.token_hex(20)) session.add(user) user.authorized = True session.commit() return f"User {identifier} authorized"