From 2699d5c5f1af3cea1fb4efe76b9aad9da604aca3 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 22 Mar 2017 17:23:17 +0100 Subject: [PATCH] Added start function --- grandbot.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/grandbot.py b/grandbot.py index 67dadcf2..fa3f2bb3 100644 --- a/grandbot.py +++ b/grandbot.py @@ -1,5 +1,4 @@ import asyncio -loop = asyncio.get_event_loop() import telegram import random import datetime @@ -11,9 +10,11 @@ import database import markovify import discord +loop = asyncio.get_event_loop() b = telegram.Bot(royalbotconfig.telegram_token) d = discord.Client() + def currently_logged_in(update): """Trova l'utente connesso all'account di Telegram che ha mandato l'update.""" session = database.Session() @@ -21,6 +22,14 @@ def currently_logged_in(update): return user +async def start(bot, update, arguments): + user = currently_logged_in(update) + if user is None: + await update.message.reply(f"Ciao!\n_Non hai eseguito l'accesso al RYGdb.") + else: + await update.message.reply(f"Ciao!\n_Hai eseguito l'accesso come_ `{user}`.") + + async def diario(bot, update, arguments): """Aggiungi una frase al diario Royal Games. @@ -277,6 +286,7 @@ Sintassi: `/cv`""" if __name__ == "__main__": # Init Telegram bot commands + b.commands["start"] = start b.commands["leggi"] = leggi b.commands["diario"] = diario b.commands["discord"] = discord