mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
Add @database_access to /cast
This commit is contained in:
parent
33fa9825dd
commit
51b8deaa9c
1 changed files with 2 additions and 5 deletions
|
@ -173,19 +173,16 @@ def cmd_cv(bot: telegram.Bot, update: telegram.Update):
|
||||||
|
|
||||||
|
|
||||||
@command
|
@command
|
||||||
def cmd_cast(bot: telegram.Bot, update: telegram.Update):
|
@database_access
|
||||||
|
def cmd_cast(bot: telegram.Bot, update: telegram.Update, session: db.Session):
|
||||||
try:
|
try:
|
||||||
spell: str = update.message.text.split(" ", 1)[1]
|
spell: str = update.message.text.split(" ", 1)[1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
bot.send_message(update.message.chat.id, "⚠️ Non hai specificato nessun incantesimo!\n"
|
bot.send_message(update.message.chat.id, "⚠️ Non hai specificato nessun incantesimo!\n"
|
||||||
"Sintassi corretta: `/cast <nome_incantesimo>`", parse_mode="Markdown")
|
"Sintassi corretta: `/cast <nome_incantesimo>`", parse_mode="Markdown")
|
||||||
return
|
return
|
||||||
# Open a new db session
|
|
||||||
session = db.Session()
|
|
||||||
# Find a target for the spell
|
# Find a target for the spell
|
||||||
target = random.sample(session.query(db.Telegram).all(), 1)[0]
|
target = random.sample(session.query(db.Telegram).all(), 1)[0]
|
||||||
# Close the session
|
|
||||||
session.close()
|
|
||||||
# END
|
# END
|
||||||
bot.send_message(update.message.chat.id, cast.cast(spell_name=spell,
|
bot.send_message(update.message.chat.id, cast.cast(spell_name=spell,
|
||||||
target_name=target.username if target.username is not None
|
target_name=target.username if target.username is not None
|
||||||
|
|
Loading…
Reference in a new issue