def get_inline_no_query(): """Возвращает ответ на пустую строку запроса. :rtype: list """ markup = InlineKeyboardMarkup() markup.row(InlineKeyboardButton('Бота в другой чат', switch_inline_query='')) markup.row( InlineKeyboardButton('Дзен', switch_inline_query_current_chat='zen '), InlineKeyboardButton('Поиск PEP', switch_inline_query_current_chat='pep '), ) markup.row( InlineKeyboardButton('На pythonz.net', url='http://pythonz.net/'), ) results = [ telebot.types.InlineQueryResultArticle( 'index', 'Пульт управления роботом', telebot.types.InputTextMessageContent( 'Нажимайте на кнопки, расположенные ниже, — получайте результат.'), description='Нажмите сюда, чтобы вызвать пульт.', reply_markup=markup, ) ] return results
def dispatch(bot, chats, chat_id, command, message_id): command = command.strip() chat = chats.get(chat_id) if chats.get(chat_id) is not None else {} if command == 'Цитаты' or command == 'quotes': chat['processor'] = 'quotes' chats[chat_id] = chat key_board = InlineKeyboardMarkup(row_width=1) key_board.add(*main.buttons.get('end')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text='\n\n' + generate(chat) + '\n\n' + main.greetings['end'], reply_markup=key_board) del chats[chat_id] return True return False
def dispatch(bot, chats, chat_id, command, message_id): command = command.strip() chat = chats.get(chat_id) if chats.get(chat_id) is not None else {} if command == 'Комплименты': chat['processor'] = 'compliments' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('compliments_sex')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('compliments_sex'), reply_markup=key_board) chats[chat_id] = chat return True elif chat.get('processor') == 'compliments' and chat.get('sex') is None: chat['sex'] = command key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('compliments_type')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('compliments_type'), reply_markup=key_board) chats[chat_id] = chat return True elif chat.get('processor') == 'compliments' and chat.get('type_compl') is None: chat['type_compl'] = command chats[chat_id] = chat key_board = InlineKeyboardMarkup(row_width=1) key_board.add(*main.buttons.get('end')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text='\n\n' + generate(chat) + '\n\n' + main.greetings['end'], reply_markup=key_board) del chats[chat_id] return True return False
def gen_markup(): markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add(InlineKeyboardButton("register", callback_data="cb_yes"), InlineKeyboardButton("asdakskla", callback_data="cb_no")) return markup
def start(message): if checkUser(file_db, message.from_user.id): if checkUserInQueue(file_db, message.from_user.id): markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add( InlineKeyboardButton("Я уже не хочу кофе", callback_data="cancel_queue")) bot.send_message( message.from_user.id, checkUser(file_db, message.from_user.id) + ", я помню, что ты хочешь пойти попить кофейку. Как только я найду для тебя пару, сразу сообщу.", reply_markup=markup) elif message.text == '/stopchat': markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add( InlineKeyboardButton("Да", callback_data="stopchat_yes"), InlineKeyboardButton("Нет", callback_data="stopchat_no")) bot.send_message( message.from_user.id, "Вы желаете остановить диалог с собеседником?", reply_markup=markup) elif message.text == '/showcs': InfoByTelegramId = getInfoByTelegramId( file_db, message.from_user.id) location_id = InfoByTelegramId['location_id'] location_info = getLocationInfo(file_db, location_id) #Делаем 5 попыток получить ближайшие места, потому что бывает что сервис Google отвечает пустым ответом i = 5 while i > 0: nearest_coffee = getLocations( location_info[3], location_info[4], "AIzaSyBFE4VdqZXTAYEfRRiUIRLss12UBsTfh2U", 10) if nearest_coffee != "": i = 0 else: i = i - 1 if nearest_coffee != "": bot.send_message( message.from_user.id, "Ближайшие места, где можно попить кофе:\n" + nearest_coffee, parse_mode="Markdown", disable_web_page_preview=True) else: bot.send_message( message.from_user.id, "К сожалению, не удалось ничего найти. Иногда нас подводит сервис Google, попробуй повторить /showcs" ) elif checkActiveDialog(file_db, message.from_user.id): #bot.send_message(message.from_user.id, "У тебя есть активный диалог") text = str("Вам пишет {0}: ".format( checkUser(file_db, message.from_user.id))) bot.send_message( getCompanionId(file_db, message.from_user.id), text + message.text) else: markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add( InlineKeyboardButton("Да", callback_data="cb_yes"), InlineKeyboardButton("Пока не готов", callback_data="cb_no")) bot.send_message(message.from_user.id, "Привет, " + checkUser(file_db, message.from_user.id) + "! Пора попить кофейку ☕️ ?", reply_markup=markup) elif getCode(file_db, message.from_user.id): infoCode = getCode(file_db, message.from_user.id) bot.send_message( message.from_user.id, 'На твою почту ' + infoCode[3] + ' был отправлен код подтверждения. Пожалуйста, введи его. Если ты ошибся при вводе e-mail, нажми /setemail' ) bot.register_next_step_handler(message, get_check_pin) else: if message.text == '/reg': bot.send_message( message.from_user.id, "Регистрация займет пару минут! Чтобы мне удостовериться, что ты из банка Открытие, потребуется подтверждение по E-mail. Введи адрес своей корпоративной почты [email protected]" ) bot.register_next_step_handler(message, get_email) #следующий шаг – функция get_email else: bot.send_message( message.from_user.id, 'Добро пожаловать в CoffeeBot! Этот чатбот поможет найти собеседника на чашку кофе на площадках банка Открытие. Для регистрации нажми /reg' )
def markup_disponibilita(): markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add(InlineKeyboardButton("Si", callback_data="risp_si"), InlineKeyboardButton("No", callback_data="risp_no")) return markup
def make_back_button_keyboard(): keyboard = InlineKeyboardMarkup() keyboard.add(InlineKeyboardButton("Назад", callback_data="back"))
def main_markup(): markup = InlineKeyboardMarkup() markup.add(InlineKeyboardButton('Добавить заказ на печать', callback_data='add_print'), types.InlineKeyboardButton('Удалить заказ на печать', callback_data='delete_print'), types.InlineKeyboardButton('Уточнить статус', callback_data='check_print')) return markup
def admin_markup(): markup = InlineKeyboardMarkup() markup.row_width = 2 announce = InlineKeyboardButton('📢 Announcement', callback_data='announce') mail = InlineKeyboardButton('📤 Mailing', callback_data='mail') ban = InlineKeyboardButton('🚫 Ban Channel', callback_data='ban') unban = InlineKeyboardButton('📍 Unban Channel', callback_data='unban') update_subs = InlineKeyboardButton('🔄 Update Subscribers', callback_data='update_subs') show_channel = InlineKeyboardButton('ℹ️ Channel Info', callback_data='show_channel') bot_support = InlineKeyboardButton( '⚙ Bot Support', url='https://t.me/joinchat/GbIvzxMleRp7WCliVG7q2w') contact_dev = InlineKeyboardButton('👨🏻💻 Contact Dev', url='https://t.me/Bhosadiwale_Chacha') manage = InlineKeyboardButton('📊 Statistics', callback_data='stats') manage_list = InlineKeyboardButton('☑️ Manage List', callback_data='list') create_post = InlineKeyboardButton('📝 Create Post', callback_data='create_post') preview_list = InlineKeyboardButton('⏮ Preview List', callback_data='preview') send_promo = InlineKeyboardButton('✔️ Send Promo', callback_data='send_promo') dlt_promo = InlineKeyboardButton('✖️ Delete Promo', callback_data='dlt_promo') bot_doc = InlineKeyboardButton( '📄 Bot Documentation', url='https://telegra.ph/DOCUMENTATION-CROSS-PROMOTE-BOT-06-27') markup.add(mail, announce) markup.add(ban, unban) markup.add(update_subs) markup.add(show_channel, manage_list) markup.add(manage, create_post) markup.add(preview_list) markup.add(send_promo, dlt_promo) markup.add(bot_support, contact_dev) markup.add(bot_doc) return markup
ADMIN_ID = os.getenv("MY_ID") bot = telebot.TeleBot(TOKEN) app = Flask(__name__) db = Participants("predictions.db") predictions = {} money = {} coefficients = (1.29, 3.64) kb_bid_reply = InlineKeyboardMarkup() kb_bid_reply.add( InlineKeyboardButton('0.5 BYN', callback_data='kb_bid_btn1'), InlineKeyboardButton('1.5 BYN', callback_data='kb_bid_btn2'), InlineKeyboardButton('3.5 BYN', callback_data='kb_bid_btn3'), InlineKeyboardButton('Custom', callback_data='kb_bid_btn4'), ) @bot.callback_query_handler(func=lambda c: c.data.startswith('kb_pred')) def callback_handle_kb_pred(c: CallbackQuery): code = c.data[-1] user_id = str(c.from_user.id) if code == "1": predictions[user_id] = "pass" else:
def post_markup(message): post = post_dict[message.chat.id] word = post.words[-1] definition_number = len(word.definitions) + 1 markup = InlineKeyboardMarkup() add_definition_button = InlineKeyboardButton( "Add definition #{0}".format(definition_number), callback_data="add_definition") add_tags_button = InlineKeyboardButton("Add tags", callback_data="add_tags") add_links_button = InlineKeyboardButton("Add dictionary links", callback_data="add_links") add_synonyms_button = InlineKeyboardButton("Add synonyms", callback_data="add_synonyms") add_new_word_button = InlineKeyboardButton("Add new word", callback_data="add_new_word") cancel_button = InlineKeyboardButton("Cancel", callback_data="cancel") finish_button = InlineKeyboardButton("Finish", callback_data="finish") markup.add(add_definition_button) if not word.synonyms: markup.add(add_synonyms_button) if word.definitions: markup.add(add_new_word_button) if not post.hashTags: markup.add(add_tags_button) if not post.oxford and not post.cambridge and not post.context: markup.add(add_links_button) markup.row(cancel_button, finish_button) return markup
def main_menu_markup(): markup = InlineKeyboardMarkup() markup.row_width = 1 markup.add(InlineKeyboardButton("Create post", callback_data="create_post")) return markup
def gen_markup(): markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add(InlineKeyboardButton("Yes", callback_data=f"cb_yes"), InlineKeyboardButton("No", callback_data=f"cb_no")) return markup
def dispatch(bot, chats, chat_id, command, message_id): command = command.strip() chat = chats.get(chat_id) if chats.get(chat_id) is not None else {} if command == 'Текст' or command == 'text': chat['processor'] = 'text' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('text_type')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('text_type'), reply_markup=key_board) chats[chat_id] = chat return True elif chat.get('processor') == 'text' and (command == 'Классическая проза' or command == 'prose'): chat['type'] = 'prose' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('text_paragraph')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('text_paragraph'), reply_markup=key_board) chat['message_id'] = message_id chats[chat_id] = chat return True elif chat.get('processor') == 'text' and (command == 'Бизнес и финансы' or command == 'business'): chat['type'] = 'business' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('text_paragraph')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('text_paragraph'), reply_markup=key_board) chat['message_id'] = message_id chats[chat_id] = chat return True elif chat.get('processor') == 'text' and (command == 'Наука и техника' or command == 'science'): chat['type'] = 'science' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('text_paragraph')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('text_paragraph'), reply_markup=key_board) chat['message_id'] = message_id chats[chat_id] = chat return True elif chat.get('processor') == 'text' and (command == 'Юмор и развлечения' or command == 'humor'): chat['type'] = 'humor' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('text_paragraph')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('text_paragraph'), reply_markup=key_board) chat['message_id'] = message_id chats[chat_id] = chat return True elif chat.get('processor') == 'text' and (command == 'Дом и семья' or command == 'home'): chat['type'] = 'home' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('text_paragraph')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('text_paragraph'), reply_markup=key_board) chat['message_id'] = message_id chats[chat_id] = chat return True elif chat.get('processor') == 'text' and (command == 'Медицина и здоровье' or command == 'med'): chat['type'] = 'med' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('text_paragraph')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('text_paragraph'), reply_markup=key_board) chat['message_id'] = message_id chats[chat_id] = chat return True elif chat.get('processor') == 'text' and (command == 'Lorem Ipsum' or command == 'lorem'): chat['type'] = 'lorem' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('text_paragraph')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('text_paragraph'), reply_markup=key_board) chat['message_id'] = message_id chats[chat_id] = chat return True elif chat.get('processor') == 'text' and (command == 'О рыбе...' or command == 'fish'): chat['type'] = 'fish' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('text_paragraph')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('text_paragraph'), reply_markup=key_board) chat['message_id'] = message_id chats[chat_id] = chat return True elif chat.get('processor') == 'text' and chat.get("type") is not None and chat.get('paragraph') is None: chat['paragraph'] = command key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('text_words')) if message_id is None: message_id = chat['message_id'] chat['message_id'] = message_id bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('text_words'), reply_markup=key_board) chats[chat_id] = chat return True elif chat.get('processor') == 'text' and chat.get("type") is not None and chat.get('paragraph') is not None: chat['word'] = command key_board = InlineKeyboardMarkup(row_width=1) key_board.add(*main.buttons.get('end')) if message_id is None: message_id = chat['message_id'] if chat.get('message_id') is not None: del chat['message_id'] bot.edit_message_text(chat_id=chat_id, message_id=message_id, text='\n\n' + generate(chat) + '\n\n' + main.greetings['end'], reply_markup=key_board) del chats[chat_id] return True return False
def dispatch(bot, chats, chat_id, command, message_id): command = command.strip() chat = chats.get(chat_id) if chats.get(chat_id) is not None else {} if command == 'Имена': chat['processor'] = 'names' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('names_sex')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('names_sex'), reply_markup=key_board) chats[chat_id] = chat return True elif chat.get('processor') == 'names' and chat.get('sex') is None: chat['sex'] = command if command == 'nick': key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('names_count')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('names_count'), reply_markup=key_board) else: key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('names_field')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('names_field'), reply_markup=key_board) chat['message_id'] = message_id chats[chat_id] = chat return True elif chat.get('processor') == 'names' and chat.get('sex') is not None and chat.get('sex') != 'nick' and \ chat.get('surname') is None and chat.get('name') is None and chat.get('patronymic') is None: chat['surname'] = '0' chat['name'] = '0' chat['patronymic'] = '0' if command == 'ФИО': chat['surname'] = '1' chat['name'] = '1' chat['patronymic'] = '1' elif command == 'Ф': chat['surname'] = '1' elif command == 'И': chat['name'] = '1' elif command == 'О': chat['patronymic'] = '1' elif command == 'ФИ': chat['surname'] = '1' chat['name'] = '1' elif command == 'ИО': chat['name'] = '1' chat['patronymic'] = '1' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('names_count')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('names_count'), reply_markup=key_board) return True elif chat.get('processor') == 'names' and chat.get('count') is None: chat['count'] = command chats[chat_id] = chat key_board = InlineKeyboardMarkup(row_width=1) key_board.add(*main.buttons.get('end')) if message_id is None: message_id = chat['message_id'] if chat.get('message_id') is not None: del chat['message_id'] bot.edit_message_text(chat_id=chat_id, message_id=message_id, text='\n\n' + generate(chat) + '\n\n' + main.greetings['end'], reply_markup=key_board) del chats[chat_id] return True return False
def generate_inline_keyboard(self, buttons: List[InlineKeyboardButton], row_width=3): kb = InlineKeyboardMarkup(row_width=row_width) kb.add(*buttons) return kb
"path": "books/01.pdf" }, "book_2": { "name": "kniga 2", "path": "books/02.pdf" }, "book_3": { "name": "kniga 3", "path": "books/03.pdf" } } book_paths = [books[book_name]["path"] for book_name in books] # books markup books_markup = InlineKeyboardMarkup() for book_name in books: name = books[book_name]["name"] path = books[book_name]["path"] book_button = InlineKeyboardButton(text=name, callback_data=path) books_markup.add(book_button) # messages messages = { 'start': 'Добро пожаловать!', "books": "Выберите книгу", "take_it": "Приятного прочтения" }
def bid(m: Message): btn_pred_p = InlineKeyboardButton(f'Pass: {coefficients[1]}', callback_data='kb_pred_btn1') btn_pred_f = InlineKeyboardButton(f'Fail: {coefficients[0]}', callback_data='kb_pred_btn2') user_prediction = db.get_prediction(str(m.from_user.id)) if not user_prediction: kb = InlineKeyboardMarkup(row_width=1) kb.add(btn_pred_p, btn_pred_f) elif user_prediction[0] == "pass": kb = InlineKeyboardMarkup() kb.add(btn_pred_p) else: kb = InlineKeyboardMarkup() kb.add(btn_pred_f) bot.send_sticker(m.chat.id, "CAACAgIAAxkBAALb3mAxW_HxbZptc1xq7Oi1f1FSDj88AAJiAwACbbBCA5mTqKDVhSM1HgQ") bot.send_message(m.chat.id, "Now i'll send you predictions...", reply_markup=kb)
def dispatch(bot, chats, chat_id, command, message_id): command = command.strip() chat = chats.get(chat_id) if chats.get(chat_id) is not None else {} if command == 'Пароли': chat['processor'] = 'passwords' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('passwords_count')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('passwords_count'), reply_markup=key_board) chat['message_id'] = message_id chats[chat_id] = chat return True elif chat.get('processor') == 'passwords' and chat.get('count') is None: chat['count'] = str(command) key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('passwords_type')) if message_id is None: message_id = chat['message_id'] bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('passwords_type'), reply_markup=key_board) chats[chat_id] = chat return True elif chat.get('processor') == 'passwords' and chat.get('count') is not None: chat['upper'] = '0' chat['lower'] = '0' chat['num'] = '0' chat['symbol'] = '0' if command == 'Буквы и Цифры': chat['upper'] = '1' chat['lower'] = '1' chat['num'] = '1' elif command == 'Буквы': chat['upper'] = '1' chat['lower'] = '1' elif command == 'Буквы, Цифры и Символы': chat['upper'] = '1' chat['lower'] = '1' chat['num'] = '1' chat['symbol'] = '1' chats[chat_id] = chat key_board = InlineKeyboardMarkup(row_width=1) key_board.add(*main.buttons.get('end')) if chat.get('message_id') is not None: del chat['message_id'] bot.edit_message_text(chat_id=chat_id, message_id=message_id, text='\n\n' + generate(chat) + '\n\n' + main.greetings['end'], reply_markup=key_board) del chats[chat_id] return True return False
def shit(m: Message): chat_id = m.chat.id kb = InlineKeyboardMarkup() url_btn = InlineKeyboardButton(text="To Tischa's profile:", url="https://www.instagram.com/kristina_evil/") kb.add(url_btn) bot.send_message(chat_id, text="Think twice before this step...", reply_markup=kb)
def back_to_info_menu(): markup = InlineKeyboardMarkup() markup.add(InlineKeyboardButton("Назад", callback_data="back_to_info_menu")) return markup
def tags_reply_markup(tags, txt_f=lambda t: t, clb_f=lambda t: t): kb = InlineKeyboardMarkup(row_width=3) kb.add(*(InlineKeyboardButton(text=txt_f(tag), callback_data=clb_f(tag)) for tag in tags)) return kb
def enter_offer_info(message): user_id = chat_id = message.chat.id user = storage_worker.get_user_state(user_id) if message.text == 'Отмена': user.state = State.START storage_worker.save_user_state(user) bot.send_message(chat_id, 'Ввод отменён', reply_markup=make_main_keyboard()) return elif user.state == State.ENTER_NAME and message.text: offer_name = message.text with DBWorker(db_name) as db: db.update_offer_name(user.cur_offer_id, offer_name) elif user.state == State.ENTER_DESCRIPTION and message.text: offer_description = message.text with DBWorker(db_name) as db: db.update_offer_description(user.cur_offer_id, offer_description) elif user.state == State.ENTER_COORDINATES and message.location: offer_coordinates = message.location with DBWorker(db_name) as db: db.update_offer_coordinates( user.cur_offer_id, (offer_coordinates.latitude, offer_coordinates.longitude)) elif user.state == State.ENTER_CONTACT and message.contact: user_phone = message.contact.phone_number with DBWorker(db_name) as db: db.update_user_phone(user_id, user_phone) user.state = State.ENTER_COORDINATES storage_worker.save_user_state(user) bot.send_message( chat_id, "Отправьте координаты места, где будет размещено ваше предложение\n(Координаты можно отправить, нажав на скрепочку и выбрав местоположение)", reply_markup=make_cancel_button_keyboard()) return else: bot.send_message(chat_id, 'Введите корректные данные') return user.state = State.START storage_worker.save_user_state(user) # Обновление информации в последнем информационном сообщении refresh_offer_info_message(message.chat.id, user.cur_offer_id, user.last_info_msg_id) keyboard = InlineKeyboardMarkup() keyboard.add( InlineKeyboardButton("Вернуться к предложению", callback_data="back_to_offer")) bot.send_message(message.chat.id, "Принято!", reply_markup=keyboard)
start_teaching = types.InlineKeyboardButton(text='Обучение 📚', callback_data='teaching') start_howmuch = types.InlineKeyboardButton(text='Стоимость заказа 🧮', callback_data='howmuch') start_order = types.InlineKeyboardButton(text='Сделать заказ 📦', callback_data='order') keyboard.add(start_qweth, start_howbuy) keyboard.add(start_reviews, start_tariff) keyboard.add(start_teaching, start_howmuch) keyboard.add(start_order) bot.send_photo(chat_id = message.from_user.id, photo = 'https://imbt.ga/vz1OIqegdB', reply_markup=keyboard) #bot.send_message(message.chat.id, '"GORILLA VBIV║ASOS║AMAZON║FARFETCH"\n• РАБОТАЕМ БОЛЕЕ ГОДА\n• ИМЕЕМ ОГРОМНУЮ БАЗУ КЛИЕНТОВ\n• ПОДДЕРЖКА 24/7', reply_markup=keyboard) #ИЗНАЧАЛЬНОЕ МЕНЮ start_qweth = types.InlineKeyboardButton(text='Частые вопросы 💻',callback_data='qweth') qweth = InlineKeyboardMarkup().add(start_qweth) start_howbuy = types.InlineKeyboardButton(text=' Как заказать 🛠', callback_data='howbuy') howbuy = InlineKeyboardMarkup().add(start_howbuy) start_reviews = types.InlineKeyboardButton(text='Отзывы 📨', callback_data='reviews') reviews = InlineKeyboardMarkup().add(start_reviews) start_tariff = types.InlineKeyboardButton(text='Тариф 💸', callback_data='tariff') tariff = InlineKeyboardMarkup().add(start_tariff) start_teaching = types.InlineKeyboardButton(text='Обучение 📚', callback_data='teaching') teaching = InlineKeyboardMarkup().add(start_teaching) start_howmuch = types.InlineKeyboardButton(text='Стоимость заказа 🧮', callback_data='howmuch') howmuch = InlineKeyboardMarkup().add(start_howmuch) start_order = types.InlineKeyboardButton(text='Сделать заказ 📦', callback_data='order') order = InlineKeyboardMarkup().add(start_order) #ВОЗВРАТ
def main(self, initial_message=None, user_message=None, call=None, inline_message=None, **kwargs): if inline_message: user_id = inline_message.chat.id else: user_id = (initial_message or user_message or call).from_user.id if user_message: bot.delete_message(chat_id=user_message.chat.id, message_id=user_message.message_id) if call: inline_message = call.message if initial_message: bot.reply_to(initial_message, text=meta.new_event_guide) if kwargs.get('done', False): # send sure reply markup if kwargs.get('sure') is None: event = self.store[user_id]['event'] text = "Der Termin ist lautet:\n" + event.get_detail_str() + "\n\nSoll er gespeichert werden?" markup = InlineKeyboardMarkup(row_width=2) markup.add(InlineKeyboardButton(text="Ja", callback_data=self.command + json.dumps({'sure': True}))) markup.add(InlineKeyboardButton(text="Zurück", callback_data=self.command + json.dumps({'done': None, 'property': None}))) bot.edit_message_text(inline_message=inline_message, text=text, reply_markup=markup) return if kwargs.get('send_notice') is None: if not kwargs.get('sure'): self.store[user_id]['property'] = None self.__call__(call=call) return else: event = self.store[user_id]['event'] database.save_event(event) text = "Okay, der Termin wurde erstellt.\n" \ "Möchtest du alle wissen lassen, sodass sie zu oder absagen können?" markup = InlineKeyboardMarkup(row_width=2) markup.add( InlineKeyboardButton(text="Ja", callback_data=self.command + json.dumps({'send_notice': True})), InlineKeyboardButton(text="Nein", callback_data=self.command + json.dumps({'send_notice': False}))) bot.edit_message_text(inline_message=inline_message, text=text, reply_markup=markup) return if not kwargs.get('send_notice'): text = "Okay, es werden keine Nachrichten versandt." else: text = "Okay, es wurden Nachrichten an alle versandt." util.functions.send_new_event_alert(by=util.database.get_frichtle(user_id=user_id), event=self.store[user_id]['event']) bot.edit_message_text(inline_message=inline_message, text=text) self.store[user_id] = dict() self.store[user_id]['data'] = dict() self.store[user_id]['inline_message'] = None return if kwargs.get('property') is None: e = self.store[user_id].get('event', Event()) e.event_id = util.database.get_new_event_id() self.store[user_id]['event'] = e text = "Aktuell sieht der Termin folgendermaßen aus:\n" + e.get_detail_str() + "\n\nBitte wähle aus, um zu Daten einzugeben:" markup = InlineKeyboardMarkup(row_width=2) buttons = [] for i, v in enumerate(meta.event_col_names_display): buttons.append(InlineKeyboardButton(text=v, callback_data=self.command + json.dumps({'property': meta.event_col_names[i]}))) buttons.append(InlineKeyboardButton(text="Fertig", callback_data=self.command + json.dumps({'done': True, 'property': ''}))) buttons.append(InlineKeyboardButton(text="Abbrechen", callback_data="abort")) markup.add(*tuple(buttons)) if inline_message: msg = bot.edit_message_text(inline_message=inline_message, text=text, reply_markup=markup) elif call: msg = bot.edit_message_text(call=call, text=text, reply_markup=markup) else: msg = bot.send_message(initial_message.chat.id, text=text, reply_markup=markup) self.store[user_id]['inline_message'] = msg return if kwargs['property'] == "dress": if kwargs.get('value') is None: text = "Okay, bitte wähle ein Outfit:" markup = InlineKeyboardMarkup(row_width=2) markup.add(*tuple([InlineKeyboardButton(text=s, callback_data=self.command + json.dumps( {'value': s} )) for s in meta.dresses] + [InlineKeyboardButton(text="Zurück", callback_data=self.command + json.dumps({'property': None, 'value': None}))])) bot.edit_message_text(text=text, inline_message=inline_message, reply_markup=markup) else: event = self.store[user_id]['event'] event.dress = kwargs.pop('value') self.store[user_id]['data'].pop('value') self.store[user_id]['data'].pop('property') self.__call__(call=call) return else: prop_display = meta.event_col_names_display[meta.event_col_names.index(kwargs.get('property'))] text = "Okay, gib '{}' ein:".format(prop_display) hint = meta.event_col_names_hints.get(kwargs['property']) if hint is not None: text += "\n{}".format(hint) msg = bot.edit_message_text(inline_message=inline_message, text=text) bot.register_next_step_handler(msg, self.property_reply) return
def languages(): mp = InlineKeyboardMarkup(row_width=1) mp.add(*(InlineKeyboardButton(i[1][0] + ' ' + i[1][1], callback_data="swap_lang_" + i[0]) for i in const.languages.items())) return mp
def callback_query(call): call_a = call.data.split('_') if call_a[0] == "cancel": delete_user_from_queue(file_db, call.from_user.id) bot.send_message( call.from_user.id, 'Ок, как будешь готов попить кофе, дай мне знать 😉') elif call.data == "stopchat_yes": bot.answer_callback_query(call.id, "Остановка диалога") if checkActiveDialog(file_db, call.from_user.id): bot.send_message( getCompanionId(file_db, call.from_user.id), 'Диалог остановлен. Надеюсь все прошло хорошо, возвращайся снова! Если захочешь попить кофейку, напиши любое слово' ) bot.send_message( call.from_user.id, 'Диалог остановлен. Надеюсь все прошло хорошо, возвращайся снова! Если захочешь попить кофейку, напиши любое слово' ) disableDialog(file_db, call.from_user.id) bot.clear_step_handler_by_chat_id( chat_id=call.message.chat.id) else: bot.send_message(call.from_user.id, 'В данный момент нет активных диалогов') elif call.data == "stopchat_no": bot.answer_callback_query(call.id, "Остановка диалога") if checkActiveDialog(file_db, call.from_user.id): bot.send_message(call.from_user.id, 'Вы можете продолжить беседу') bot.clear_step_handler_by_chat_id( chat_id=call.message.chat.id) else: bot.send_message(call.from_user.id, 'В данный момент нет активных диалогов') if not checkUserInQueue( file_db, call.from_user.id ) and not checkActiveDialog( file_db, call.from_user.id ): #Не реагируем на кнопки, если есть активный диалог или ожидание в очереди if call_a[0] == "town": address = getLocationAddress(file_db, call_a[1]) markup = InlineKeyboardMarkup() for row in address: markup.add( InlineKeyboardButton(row[2], callback_data="gotoqueue_" + str(row[0]))) bot.send_message( call.from_user.id, "Выбери адрес или поделись геопозицией и я сам пойму где ты находишься 😏", reply_markup=markup) elif call_a[0] == "gotoqueue": if checkUserInQueue(file_db, call.from_user.id): utput = str("Я уже подыскиваю пару для тебя.") bot.send_message(call.from_user.id, output) else: bot.answer_callback_query(call.id, "Поиск собеседника") InfoByTelegramId = getInfoByTelegramId( file_db, call.from_user.id) location_id = InfoByTelegramId['location_id'] location_info = getLocationInfo(file_db, location_id) add_to_queue(file_db, call.from_user.id, location_id, 0, "") output = str( "Я добавил тебя в список желающих попить кофе по адресу {0}, {1}. Как только я найду пару, сразу сообщу." .format(location_info[1], location_info[2])) bot.send_message(call.from_user.id, output) bot.clear_step_handler_by_chat_id( chat_id=call.message.chat.id) elif call_a[0] == "givephoto": bot.answer_callback_query(call.id, "Приложи фото") updateLocation(file_db, call.from_user.id, call_a[1]) markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add( InlineKeyboardButton("Я не хочу загружать фото", callback_data="gotoqueue")) bot.send_message( call.from_user.id, "Приложи свое селфи и я порекомендую тебе кофе и найду наиболее подходящего собеседника!", reply_markup=markup) elif call.data == "cb_nolocation": bot.send_message( call.from_user.id, " Поделись геопозицией, чтобы я понял на какой площадке ты находишься 😏" ) elif call.data == "cb_yes": bot.answer_callback_query(call.id, "Поделись геопозицией") userInfo = getInfoByTelegramId(file_db, call.from_user.id) if userInfo['location_id']: location_info = getLocationInfo( file_db, userInfo['location_id']) location = str( "Последний раз ты был на локации по адресу: {0}, {1}. Сейчас ты здесь?" .format(location_info[1], location_info[2])) markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add( InlineKeyboardButton("Да", callback_data="givephoto_" + str(userInfo['location_id'])), InlineKeyboardButton( "Нет", callback_data="cb_nolocation")) bot.send_message(call.from_user.id, location, reply_markup=markup) else: bot.send_message( call.from_user.id, " Поделись геопозицией, чтобы я понял на какой площадке ты находишься 😏" ) elif call.data == "cb_no": bot.answer_callback_query(call.id, "Ок, как будешь готов, пиши 😉") bot.send_message(call.from_user.id, "Ок, как будешь готов, пиши 😉") else: if not checkActiveDialog( file_db, call.from_user.id) and call.data != "stopchat_no": bot.answer_callback_query(call.id, "Кнопки не доступны") bot.send_message(call.from_user.id, 'В данный момент эти кнопки не доступны')
def yes_no(id): markup = InlineKeyboardMarkup() markup.row(InlineKeyboardButton('Да', callback_data='yes/%d' % id), InlineKeyboardButton('Нет', callback_data='no/%d' % id)) return markup
again_k = ReplyKeyboardMarkup(resize_keyboard=True) again_k.add(KeyboardButton('🔁 Пройти ещё раз')) p_1_k = ReplyKeyboardMarkup(resize_keyboard=True, row_width=1) p_1_k.add( KeyboardButton( ' 👤 Я физическое лицо (клиент) мне нужна помощь с кредитом'), KeyboardButton(' 👥 Я юридическое лицо хочу получить финансирование'), KeyboardButton( ' 🤝 Я потенциальный партнер и хочу обсудить сотрудничество'), KeyboardButton(' 🏠 Мне нужна помощь риэлтора'), KeyboardButton(' ℹ️ Расскажи сначала о себе')) pill_blue = InlineKeyboardButton('🔵 Я отказываюсь', callback_data='pill_blue') pill_red = InlineKeyboardButton('Попробовать 🔴', callback_data='pill_red') pills_keyboard = InlineKeyboardMarkup(row_width=2) pills_keyboard.add(pill_blue, pill_red) fiz_lico_k = ReplyKeyboardMarkup(resize_keyboard=True, row_width=1) fiz_lico_k.add(KeyboardButton(' 🏡 Ипотечный кредит'), KeyboardButton(' 💳 Потребительский кредит'), KeyboardButton(' 🏠 Кредит под залог недвижимости '), KeyboardButton(' 💰 Рефинансирование'), KeyboardButton(' 🏎 Автокредитование'), KeyboardButton('⬅️ Вернуться назад')) ur_lico_k = ReplyKeyboardMarkup(resize_keyboard=True, row_width=1) ur_lico_k.add(KeyboardButton(' 🏦 Банковская гарантия'), KeyboardButton(' ⏱ Лизинг'), KeyboardButton(' 💳 Кредит'), KeyboardButton(' 💰 Проектное финансирование'), KeyboardButton('⬅️ Вернуться назад'))
def error_markup(): markup = InlineKeyboardMarkup() markup.row(InlineKeyboardButton('Да, ошибся', callback_data='error'), InlineKeyboardButton('Передумал мониторить', callback_data='stop')) return markup
def gen_markup(): markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add(InlineKeyboardButton("Yes", callback_data="cb_yes"), InlineKeyboardButton("No", callback_data="cb_no")) return markup
def delete_user_markup(user_inn): markup = InlineKeyboardMarkup() markup.row(InlineKeyboardButton('Удалить', callback_data='delete/%s' % user_inn)) return markup
def start_markup(id_): return InlineKeyboardMarkup().row( InlineKeyboardButton('Подробнее', callback_data='info/start/' + str(id_)))
def skip_markup(step): markup = InlineKeyboardMarkup() markup.row(InlineKeyboardButton('Пропустить', callback_data='skip/%s' % str(step))) return markup
from telebot.types import KeyboardButton, ReplyKeyboardMarkup, \ InlineKeyboardButton, InlineKeyboardMarkup products = KeyboardButton('Товары') cart = KeyboardButton('Корзина') registration = KeyboardButton('Регистрация') btns = ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True).row(products, cart, registration) phone = KeyboardButton(text='поделиться телефоном', request_contact=True) geo = KeyboardButton(text='поделиться местоположением', request_location=True) reg_btns = ReplyKeyboardMarkup(resize_keyboard=True).add(phone).add(geo) url_btn = InlineKeyboardButton(text="Ссылка на гугл", url='https://google.com') inline_btn = InlineKeyboardButton(text="Тестовая кнопка", callback_data="test") inline_btns = InlineKeyboardMarkup(row_width=2).add(url_btn, inline_btn)
def gen_markup(): markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add(InlineKeyboardButton("Да", callback_data="order_correct"), InlineKeyboardButton("Нет", callback_data="order_incorrect"), InlineKeyboardButton("Назад", callback_data="back_to_priority")) return markup
def back_to_priority(): markup = InlineKeyboardMarkup() markup.add(InlineKeyboardButton("Назад", callback_data="back_to_qty")) return markup
def dispatch(bot, chats, chat_id, command, message_id): command = command.strip() chat = chats.get(chat_id) if chats.get(chat_id) is not None else {} if command.upper() == 'ИНН/ОГРН/UUID' or command.upper() == 'INN': chat['processor'] = 'inn' key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('inn_type')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('inn_type'), reply_markup=key_board) chats[chat_id] = chat return True elif chat.get('processor') == 'inn' and chat.get('type') is None and (command == 'uuid' or command == 'UUID'): chat["type"] = command key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('uuid_start')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('uuid_start'), reply_markup=key_board) chat['message_id'] = message_id chats[chat_id] = chat return True elif chat.get('processor') == 'inn' and chat.get('type') is None: chat["type"] = command key_board = InlineKeyboardMarkup(row_width=3) key_board.add(*buttons.get('inn_start')) bot.edit_message_text(chat_id=chat_id, message_id=message_id, text=greetings.get('inn_start'), reply_markup=key_board) chat['message_id'] = message_id chats[chat_id] = chat return True elif chat.get('processor') == 'inn' and chat.get('type') is not None: chat['inn'] = command chats[chat_id] = chat key_board = InlineKeyboardMarkup(row_width=1) key_board.add(*main.buttons.get('end')) if message_id is None: message_id = chat['message_id'] if chat.get('message_id') is not None: del chat['message_id'] bot.edit_message_text(chat_id=chat_id, message_id=message_id, text='\n\n' + generate(chat) + '\n\n' + main.greetings['end'], reply_markup=key_board) del chats[chat_id] return True return False