from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, CallbackQueryHandler
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from app.config import config
import logging

# Enable logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                    level=logging.INFO)
logger = logging.getLogger(__name__)



def start(bot, update):
    keyboard = [[InlineKeyboardButton("Option 1", callback_data='1'),
                 InlineKeyboardButton("Option 2", callback_data='2')],

                [InlineKeyboardButton("Option 3", callback_data='3')]]

    reply_markup = InlineKeyboardMarkup(keyboard)

    update.message.reply_text('Please choose:', reply_markup=reply_markup)


def echo(bot, update):
    update.message.reply_text(update.message.text)

def ping(bot, update):
    update.message.reply_text("pong")

def button(bot, update):
    query = update.callback_query

    bot.editMessageText(text="Selected option: %s" % query.data,
                        chat_id=query.message.chat_id,
                        message_id=query.message.message_id)


def help(bot, update):
    update.message.reply_text("Use /start to test this bot. Other commands: /echo, /ping")


def error(bot, update, error):
    logging.warning('Update "%s" caused error "%s"' % (update, error))


# Create the Updater and pass it your bot's token.
updater = Updater(config.config["Debug"]["TelegramBotToken"])

updater.dispatcher.add_handler(CommandHandler('start', start))
updater.dispatcher.add_handler(CallbackQueryHandler(button))
updater.dispatcher.add_handler(CommandHandler('help', help))
updater.dispatcher.add_handler(CommandHandler('echo', echo))
updater.dispatcher.add_handler(CommandHandler('ping', ping))
updater.dispatcher.add_error_handler(error)

# Start the Bot
updater.start_polling()

# Run the bot until the user presses Ctrl-C or the process receives SIGINT,
# SIGTERM or SIGABRT
updater.idle()

@@ -66,17 +66,41 @@
  Filters
-,
+%0Afrom telegram.ext import
  Callbac
@@ -207,16 +207,72 @@
  config%0A
+from app.views import WarningView, ErrorView, InfoView%0A%0A
 import l
@@ -340,18 +340,17 @@
 e)s 
-- 
+%5B
 %25(name)s
  - %25
@@ -345,18 +345,16 @@
 %25(name)s
- -
  %25(level
@@ -363,10 +363,10 @@
 me)s
- -
+%5D:
  %25(m
@@ -455,17 +455,16 @@
 me__)%0A%0A%0A
-%0A
 def star
@@ -896,16 +896,17 @@
 .text)%0A%0A
+%0A
 def ping
@@ -959,16 +959,17 @@
 pong%22)%0A%0A
+%0A
 def butt
@@ -1199,24 +1199,419 @@
 ssage_id)%0A%0A%0A
+def info(bot, update):%0A    msg = InfoView(%22this is a test%22)%0A    # print(str(update).encode('utf8'))%0A    # update.message.reply_text(%22info%22)%0A    update.message.reply_text(str(msg))%0A%0A%0Adef errorm(bot, update):%0A    msg = ErrorView(%22this is a test%22)%0A    update.message.reply_text(str(msg))%0A%0A%0Adef warning(bot, update):%0A    msg = WarningView(%22this is a test%22)%0A    update.message.reply_text(str(msg))%0A%0A%0A
 def help(bot
@@ -1651,16 +1651,25 @@
 ly_text(
+%0A        
 %22Use /st
@@ -1826,17 +1826,16 @@
 rror))%0A%0A
-%0A
 # Create
@@ -2247,16 +2247,208 @@
  ping))%0A
+updater.dispatcher.add_handler(CommandHandler('info', info))%0Aupdater.dispatcher.add_handler(CommandHandler('warning', warning))%0Aupdater.dispatcher.add_handler(CommandHandler('error', errorm))%0A
 updater.

Implemented message views with the following commands: /info /error /warning.