mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Applied find_user function
This commit is contained in:
parent
b29165017c
commit
08e9dbcb07
1 changed files with 10 additions and 12 deletions
22
grandbot.py
22
grandbot.py
|
@ -469,13 +469,13 @@ Sintassi: `/cv`"""
|
||||||
await update.message.reply(bot, to_send, parse_mode="Markdown", disable_web_page_preview=1)
|
await update.message.reply(bot, to_send, parse_mode="Markdown", disable_web_page_preview=1)
|
||||||
|
|
||||||
|
|
||||||
async def buycoins_telegram(bot, update, arguments):
|
async def buycoins_telegram(bot, update, _):
|
||||||
"""Compra nuovi ℝ!
|
"""Compra nuovi ℝ!
|
||||||
|
|
||||||
Sintassi: /buycoins"""
|
Sintassi: /buycoins"""
|
||||||
# Check the day
|
# Check the day
|
||||||
if datetime.datetime.now().day != 1 or datetime.datetime.now().month != 4:
|
if datetime.datetime.now().day != 1 or datetime.datetime.now().month != 4:
|
||||||
print("Qualcuno sa!")
|
await update.message.reply(bot, "⚠ Non è ancora giunto il momento.")
|
||||||
return
|
return
|
||||||
# Try to login
|
# Try to login
|
||||||
logged_user = currently_logged_in(update)
|
logged_user = currently_logged_in(update)
|
||||||
|
@ -525,10 +525,8 @@ Sintassi: `/addcoins <username> <coins>`"""
|
||||||
if len(arguments) != 2:
|
if len(arguments) != 2:
|
||||||
await update.message.reply(bot, "⚠ Sintassi del comando non valida.\n`/addcoins <username> <coins>`", parse_mode="Markdown")
|
await update.message.reply(bot, "⚠ Sintassi del comando non valida.\n`/addcoins <username> <coins>`", parse_mode="Markdown")
|
||||||
return
|
return
|
||||||
# Create a new database session
|
|
||||||
session = database.Session()
|
|
||||||
# Find the user
|
# Find the user
|
||||||
user = session.query(database.User).filter_by(username=arguments[0]).first()
|
session, user = database.find_user(arguments[0])
|
||||||
# Check if the user exists
|
# Check if the user exists
|
||||||
if user is None:
|
if user is None:
|
||||||
await update.message.reply(bot, "⚠ L'utente specificato non esiste.")
|
await update.message.reply(bot, "⚠ L'utente specificato non esiste.")
|
||||||
|
@ -653,13 +651,13 @@ if __name__ == "__main__":
|
||||||
d.commands["leggi"] = leggi_discord
|
d.commands["leggi"] = leggi_discord
|
||||||
d.commands["diario"] = diario_discord
|
d.commands["diario"] = diario_discord
|
||||||
# Set coins to 0 if None in inventory
|
# Set coins to 0 if None in inventory
|
||||||
session = database.Session()
|
gen_session = database.Session()
|
||||||
users = session.query(database.User).all()
|
gen_users = gen_session.query(database.User).all()
|
||||||
for user in users:
|
for gen_user in gen_users:
|
||||||
if user.coins is None:
|
if gen_user.coins is None:
|
||||||
user.coins = 0
|
gen_user.coins = 0
|
||||||
session.commit()
|
gen_session.commit()
|
||||||
del session
|
del gen_session
|
||||||
# Init Telegram bot
|
# Init Telegram bot
|
||||||
loop.create_task(b.run())
|
loop.create_task(b.run())
|
||||||
print("Telegram bot start scheduled!")
|
print("Telegram bot start scheduled!")
|
||||||
|
|
Loading…
Reference in a new issue