Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import logging
- from datetime import datetime
- import re
- from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, RegexHandler, ConversationHandler, CallbackQueryHandler
- from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove, InlineKeyboardButton, InlineKeyboardMarkup
- import airbnb
- search_id = 0
- inline = 'inline'
- def greet_user(bot, update, user_data):
- text = ("Hi! I'm bot low cost offers finder at Airbnb.\n\n"
- "I will follow your filters and tell you when i find new offer for you.\n\n"
- "It's simple to use me:\n"
- " · Press Menu, to add your first notification or to edit existing\n"
- " · To read full description of bot functions press Help button")
- keyboard = [[InlineKeyboardButton("Menu", callback_data='Menu'),
- InlineKeyboardButton("My subscriptions", callback_data='My subscriptions')],
- [InlineKeyboardButton("Help", callback_data='Help')]]
- reply_markup = InlineKeyboardMarkup(keyboard)
- update.message.reply_text(text, reply_markup=reply_markup)
- return inline
- def main_menu(bot, update, user_data):
- query = update.callback_query
- print(query.data)
- functions = {'Menu': menu(bot, update, user_data),
- 'Help': help_comm(bot, update, user_data),
- 'My subscriptions': my_subs(bot, update, user_data)}
- return functions[query.data]
- def menu(bot, update, user_data):
- text = "Do you want to add new search or edit existing?"
- keyboard = [[InlineKeyboardButton('New search', callback_data='New search'),
- InlineKeyboardButton('Edit existing search', callback_data='Edit existing search')]]
- reply_markup = InlineKeyboardMarkup(keyboard)
- query = update.callback_query
- query.edit_message_text(text, reply_markup=reply_markup)
- return inline
- def help_comm(bot, update, user_data):
- text = '''What does this bot do?\n
- Tracks prices for apartments that suits your criteria, when it founds new offer bot sends you picture, price and link to this offer.\n
- You should set your currency, check in and check out dates, number of guests, city name, room types, minimum and maximum price per night.\n
- How to use?
- 1.To make first search subscription go to menu and then press "New search".\n
- 2.Set all required parameters.\n
- 3. Press save, now you made your first subscription.\n
- To change or delete parameters go to menu and press "edit".
- To show all of your subscriptions go to menu and press "my subscriptions".
- '''
- keyboard = [[InlineKeyboardButton("Menu", callback_data='Menu'),
- InlineKeyboardButton("My subscriptions", callback_data='My subscriptions')],
- [InlineKeyboardButton("Help", callback_data='Help')]]
- reply_markup = InlineKeyboardMarkup(keyboard)
- query = update.callback_query
- query.edit_message_text(text, reply_markup=reply_markup)
- return inline
- def my_subs(bot, update, user_data):
- text = 'Здесь должны быть существующие подписки'
- keyboard = [[InlineKeyboardButton("Menu", callback_data='Menu'),
- InlineKeyboardButton("My subscriptions", callback_data='My subscriptions')],
- [InlineKeyboardButton("Help", callback_data='Help')]]
- reply_markup = InlineKeyboardMarkup(keyboard)
- query = update.callback_query
- query.edit_message_text(text, reply_markup=reply_markup)
- return inline
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement