From 3b44100fcfbbd44f95dff7fed8e4d885f8e46611 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 9 Apr 2018 19:56:43 +0200 Subject: [PATCH] Telegrambot improvements --- telegrambot.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/telegrambot.py b/telegrambot.py index 18a8fedf..adb41d26 100644 --- a/telegrambot.py +++ b/telegrambot.py @@ -7,6 +7,8 @@ import stagismo from telegram import Bot, Update, InlineKeyboardMarkup, InlineKeyboardButton from telegram.ext import Updater, CommandHandler, CallbackQueryHandler from discord import Status as DiscordStatus +import subprocess +import os # Init the config reader import configparser @@ -16,16 +18,18 @@ config.read("config.ini") discord_connection = None # Find the latest git tag -import subprocess -import os -old_wd = os.getcwd() -try: - os.chdir(os.path.dirname(__file__)) - version = str(subprocess.check_output(["git", "describe", "--tags"]), encoding="utf8").strip() -except: - version = "v???" -finally: - os.chdir(old_wd) +if __debug__: + version = "Dev" +else: + # Find the latest git tag + old_wd = os.getcwd() + try: + os.chdir(os.path.dirname(__file__)) + version = str(subprocess.check_output(["git", "describe", "--tags"]), encoding="utf8").strip() + except Exception: + version = "❓" + finally: + os.chdir(old_wd) def cmd_register(bot: Bot, update: Update): @@ -366,6 +370,7 @@ def process(arg_discord_connection): u.dispatcher.add_handler(CommandHandler("vote", cmd_vote)) u.dispatcher.add_handler(CommandHandler("ban", cmd_ban)) u.dispatcher.add_handler(CallbackQueryHandler(on_callback_query)) + u.bot.send_message(config["Telegram"]["main_group"], f"ℹ Royal Bot {version} avviato e pronto a ricevere comandi!") u.start_polling() u.idle()