45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, ReplyKeyboardMarkup, ReplyKeyboardRemove
|
|
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler, ConversationHandler, MessageHandler, \
|
|
ChatMemberHandler, filters, ApplicationBuilder
|
|
from fmd_bot import config, FIRST, SECOND, states
|
|
from fmd_bot.handlers.MainHandler import MainHandler, SET_ADMIN_MSG
|
|
from tg_bot import recursive_dict_merge
|
|
|
|
class FmdBot:
|
|
|
|
def run(self):
|
|
TOKEN = config['TELEGRAM_TOKEN']
|
|
|
|
application = ApplicationBuilder().token(TOKEN).build()
|
|
|
|
app_states = { # словарь состояний разговора, возвращаемых callback функциями
|
|
FIRST: [
|
|
CallbackQueryHandler(MainHandler.menu, pattern='^main_menu'),
|
|
],
|
|
SET_ADMIN_MSG: [
|
|
|
|
],
|
|
}
|
|
|
|
# app_states.update(states)
|
|
|
|
final_states = recursive_dict_merge(states, app_states)
|
|
|
|
conv_handler = ConversationHandler(
|
|
entry_points=[
|
|
CommandHandler('start', MainHandler.start),
|
|
],
|
|
states=final_states,
|
|
fallbacks=[CommandHandler('start', MainHandler.start)],
|
|
)
|
|
|
|
application.add_handler(conv_handler)
|
|
|
|
# text_handler = MessageHandler(filters.TEXT & (~filters.COMMAND), self.text_msg)
|
|
# application.add_handler(text_handler)
|
|
|
|
application.run_polling()
|
|
|
|
|
|
|