refactor major
This commit is contained in:
74
_archiv/test.py
Normal file
74
_archiv/test.py
Normal file
@@ -0,0 +1,74 @@
|
||||
import logging
|
||||
|
||||
from telegram.ext import CommandHandler, CallbackQueryHandler
|
||||
from telegram.ext import Updater
|
||||
from telegram import InlineKeyboardButton,InlineKeyboardMarkup
|
||||
|
||||
from telegram.ext import MessageHandler, Filters
|
||||
|
||||
updater = Updater(token='317750953:AAFzRryrTGUhnaaHgXfvVUkvk5WKgyTQ7CU', use_context=True)
|
||||
dispatcher = updater.dispatcher
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
workflows = {}
|
||||
|
||||
|
||||
def start(update, context):
|
||||
logger.info("start")
|
||||
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)
|
||||
|
||||
|
||||
#context.bot.send_message(chat_id=update.effective_chat.id, text="I'm a bot, please talk to me!")
|
||||
|
||||
start_handler = CommandHandler('start', start)
|
||||
dispatcher.add_handler(start_handler)
|
||||
print("StartCommand")
|
||||
|
||||
def echo(update, context):
|
||||
logger.info("echo")
|
||||
context.bot.send_message(chat_id=update.effective_chat.id, text=update.message.text)
|
||||
|
||||
echo_handler = MessageHandler(Filters.text & (~Filters.command), echo)
|
||||
dispatcher.add_handler(echo_handler)
|
||||
print("Added Echo")
|
||||
|
||||
def caps(update, context):
|
||||
text_caps = ' '.join(context.args).upper()
|
||||
context.bot.send_message(chat_id=update.effective_chat.id, text=text_caps)
|
||||
|
||||
caps_handler = CommandHandler('caps', caps)
|
||||
dispatcher.add_handler(caps_handler)
|
||||
|
||||
from telegram import InlineQueryResultArticle, InputTextMessageContent
|
||||
def inline_caps(update, context):
|
||||
query = update.inline_query.query
|
||||
if not query:
|
||||
return
|
||||
results = list()
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
id=query.upper(),
|
||||
title='Caps',
|
||||
input_message_content=InputTextMessageContent(query.upper())
|
||||
)
|
||||
)
|
||||
context.bot.answer_inline_query(update.inline_query.id, results)
|
||||
|
||||
from telegram.ext import InlineQueryHandler
|
||||
inline_caps_handler = InlineQueryHandler(inline_caps)
|
||||
dispatcher.add_handler(inline_caps_handler)
|
||||
|
||||
|
||||
def button(update, context):
|
||||
query = update.callback_query
|
||||
query.edit_message_text(text="Selected option: {}".format(query.data))
|
||||
updater.dispatcher.add_handler(CallbackQueryHandler(button))
|
||||
|
||||
|
||||
updater.start_polling()
|
||||
Reference in New Issue
Block a user