diff --git a/betaseries.py b/betaseries.py index c14907e..f0b0b0f 100644 --- a/betaseries.py +++ b/betaseries.py @@ -8,6 +8,7 @@ import requests import json from config import config import os +# import time from os import path from telegram_api import send_message @@ -116,7 +117,7 @@ def check_latest(thetvdb_id): message = 'Nouvel episode de ' + title + ' ! ' + 'S' + str(latest_season) + 'E' + str(latest_episode) send_message(message) os.remove(file_path) - #create_file(file_path, episode_info) + create_file(file_path, episode_info) return print("Aucun changement") @@ -159,7 +160,7 @@ def to_see(thetvdb_id): return def main(): -#Only here for debug +#Only here for debug login_beta() print(get_title_only('354198')) diff --git a/bot.py b/bot.py index 430c714..af59fde 100644 --- a/bot.py +++ b/bot.py @@ -5,7 +5,8 @@ import logging import requests import json -from telegram.ext import Updater, CommandHandler +from telegram import InlineKeyboardButton, InlineKeyboardMarkup +from telegram.ext import Updater, CommandHandler, CallbackQueryHandler from config import config, series from betaseries import login_beta, get_title_only, to_see from telegram_api import send_message @@ -107,6 +108,42 @@ def liste(update, context): message += '\n' + "Bon Visionnage !" send_message(message) + + + +def coding(update, context): + if type(series) == str : + file_path = 'latest/' + series + '.json' + print(file_path) + with open(file_path) as json_file: + data = json.load(json_file) + message = u'Episode que vous allez marquer comme vu : ' + data['serie_title'] + ' - S' + str(data['season ']) + 'E' + str(data['episode']) + send_message(message) + return + + + keyboard = [[InlineKeyboardButton("Option 1", callback_data='1'), + InlineKeyboardButton("Option 2", callback_data='2'), + InlineKeyboardButton("Option 3", callback_data='3')], + + [InlineKeyboardButton("Option 4", callback_data='5')] ] + + reply_markup = InlineKeyboardMarkup(keyboard) + + update.message.reply_text(message, reply_markup=reply_markup) + + + + + +def button(update, context): + query = update.callback_query + + query.answer() + + query.edit_message_text(text="Selected option: {}".format(query.data)) + + def main(): updater = Updater(token_bot, use_context=True) @@ -133,6 +170,9 @@ def main(): dp.add_handler(CommandHandler("check", check_seen)) + dp.add_handler(CommandHandler("code", coding)) + updater.dispatcher.add_handler(CallbackQueryHandler(button)) + updater.start_polling() updater.idle()