mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
To use /diario you must be a Royal
This commit is contained in:
parent
998360d593
commit
e6120ea84a
1 changed files with 7 additions and 3 deletions
10
basicbot.py
10
basicbot.py
|
@ -17,14 +17,18 @@ def currently_logged_in(update):
|
||||||
"""Find the database user which sent the update."""
|
"""Find the database user which sent the update."""
|
||||||
session = database.Session()
|
session = database.Session()
|
||||||
user = session.query(database.User).filter_by(telegram_id=update.message.sent_from.user_id).first()
|
user = session.query(database.User).filter_by(telegram_id=update.message.sent_from.user_id).first()
|
||||||
return session, user
|
return user
|
||||||
|
|
||||||
|
|
||||||
async def diario(bot, update, arguments):
|
async def diario(bot, update, arguments):
|
||||||
"""Aggiungi una frase al diario Royal Games.
|
"""Aggiungi una frase al diario Royal Games.
|
||||||
|
|
||||||
|
Devi essere un Royal per poter eseguire questo comando.
|
||||||
|
|
||||||
Sintassi: `/diario <frase>`"""
|
Sintassi: `/diario <frase>`"""
|
||||||
# Sì, ho copiato la funzione dal bot vecchio
|
if not currently_logged_in(update).royal:
|
||||||
|
await update.message.chat.send_message(bot, "⚠ Non sei autorizzato a eseguire questo comando.")
|
||||||
|
return
|
||||||
if len(arguments) == 0:
|
if len(arguments) == 0:
|
||||||
await update.message.chat.send_message(bot, "⚠ Sintassi del comando non valida.\n`/diario <random | numerofrase>`")
|
await update.message.chat.send_message(bot, "⚠ Sintassi del comando non valida.\n`/diario <random | numerofrase>`")
|
||||||
return
|
return
|
||||||
|
@ -147,7 +151,7 @@ Sintassi: `/changepassword <newpassword>`"""
|
||||||
await update.message.chat.send_message(bot, "⚠ Sintassi del comando non valida.\n`/changepassword <oldpassword> <newpassword>`")
|
await update.message.chat.send_message(bot, "⚠ Sintassi del comando non valida.\n`/changepassword <oldpassword> <newpassword>`")
|
||||||
return
|
return
|
||||||
# TODO: this can be improved, maybe?
|
# TODO: this can be improved, maybe?
|
||||||
session, logged_user = currently_logged_in(update)
|
logged_user = currently_logged_in(update)
|
||||||
# Check if the login is successful
|
# Check if the login is successful
|
||||||
if logged_user is not None:
|
if logged_user is not None:
|
||||||
# Change the password
|
# Change the password
|
||||||
|
|
Loading…
Reference in a new issue