def custom_keyboard(): reply_markup = ReplyKeyboardMarkup( keyboard=[[KeyboardButton( text="Eliminar Caps")], [KeyboardButton(text="Lembretes")], [KeyboardButton(text="Stats"), KeyboardButton(text="Ajuda")]]) return reply_markup
def create_bahn_destination_keyboard(self): try: fav1 = list(self.cookies['bahn']['fav1'].keys())[0] except (KeyError, IndexError): fav1 = "Favorit 1" try: fav2 = list(self.cookies['bahn']['fav2'].keys())[0] except (KeyError, IndexError): fav2 = "Favorit 2" try: fav3 = list(self.cookies['bahn']['fav3'].keys())[0] except (KeyError, IndexError): fav3 = "Favorit 3" keyboard = ReplyKeyboardMarkup(keyboard=[ [ KeyboardButton(text=fav1) ], [ KeyboardButton(text=fav2) ], [ KeyboardButton(text=fav3) ], [ KeyboardButton(text="Suche") ] ]) return keyboard
def handle(msg): content_type, chat_type, chat_id = telepot.glance(msg) #Other if statements is not able to handle 'location' input. Return is needed and placed at the top. if content_type == 'location': x = msg['location']['latitude'] y = msg['location']['longitude'] #All other variables have already been input. Location is the last. Can call for function. fullresp(a, b, tp, x, y, chat_id) return if (msg['text'] != "Details of a single shop." and msg['text'] != "Type of shops"): bot.sendMessage(chat_id, 'What are you searching for?', reply_markup=ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text="Details of a single shop."), KeyboardButton(text="Type of shops.") ]], resize_keyboard=True)) if msg['text'] == "Details of a single shop.": kb = kbgenerator('Name') keyboard = InlineKeyboardMarkup(inline_keyboard=kb) bot.sendMessage(chat_id, 'What is the name of the shop?', reply_markup=keyboard) if msg['text'] == "Type of shops.": kb = kbgenerator('Type') keyboard = InlineKeyboardMarkup(inline_keyboard=kb) bot.sendMessage(chat_id, 'What type of shops are you looking for?', reply_markup=keyboard)
async def on_callback_query(data): query_id, from_id, query_data = telepot.glance(data, flavor="callback_query") if not ManagerClients.existClient(from_id): if query_data in ["TermoServicoAceito", "TermoServicoNaoAceito"]: if query_data == "TermoServicoAceito": await bot.answerCallbackQuery(query_id, text="Aguarde um momento...") edited = telepot.message_identifier(data["message"]) await bot.editMessageText(edited, "Você aceitou o termo de serviço.") firstname_inline = KeyboardButton( text=data["from"] ["first_name"]) if "first_name" in data["from"] else None username_inline = KeyboardButton( text=data["from"] ["username"]) if "username" in data["from"] else None keyboard = [] if firstname_inline: keyboard.append([firstname_inline]) if username_inline: keyboard.append([username_inline]) keyboard = ReplyKeyboardMarkup(keyboard=keyboard, resize_keyboard=True) whats_name = await bot.sendMessage( from_id, "Como gostaria de si chamar?\nEscolha uma das opções abaixo ou digite outra.", reply_markup=keyboard) ManagerClients.createClient(from_id, whats_name["message_id"]) else: edited = telepot.message_identifier(data["message"]) await bot.editMessageText( edited, "Você não aceitou o termo de serviço.")
def menu(): askaim = ReplyKeyboardMarkup(keyboard=[ [KeyboardButton(text='News Feeds')], [KeyboardButton(text='Project Examples')], [KeyboardButton(text='Back to main menu.')], ], ) return askaim
def get_lang_board(self, lang, array, num=1): data = [[KeyboardButton(text=self.switch_coll.get(lang))], [KeyboardButton(text=self.switch_teach.get(lang))]] return ReplyKeyboardMarkup(keyboard=data, resize_keyboard=True, one_time_keyboard=True, selective=False)
def projectype(): project_type = ReplyKeyboardMarkup(keyboard=[ [KeyboardButton(text='Arduino')], [KeyboardButton(text='RaspberryPi')], [KeyboardButton(text='Back to type choosing')], ], ) return project_type
def on_chat_message(msg): content_type, chat_type, chat_id = telepot.glance(msg) createLog(msg) if content_type == 'text': if (msg['text'] == '/help' or msg['text'] == '/start'): bot.sendMessage(chat_id, 'Come posso aiutarti?', reply_markup=ReplyKeyboardMarkup( resize_keyboard=True, keyboard=[[ KeyboardButton(text="Orari"), KeyboardButton(text="Eventi"), KeyboardButton(text="Progetti attivi"), KeyboardButton(text="Chi siamo") ]])) elif msg['text'] == 'Orari': bot.sendMessage( chat_id, 'https://docs.google.com/spreadsheets/d/1Ce80qmF-nKEcuUJmqiLCYEUBZtCyQmVH-x_M-ZwnCKY/pubhtml/sheet?headers=false&gid=1104399453' ) elif msg['text'] == 'Eventi': bot.sendMessage(chat_id, 'Work in progress') elif msg['text'] == 'Progetti attivi': bot.sendMessage(chat_id, funcParserHTML(url)) elif msg['text'] == 'Chi siamo': bot.sendMessage( chat_id, 'L\'0p3n_L4b è un laboratorio interamente gestito da studenti il cui scopo è fornire ulteriori competenze ed, eventuale supporto agli studenti del Dipartimento DIBRIS sviluppando progetti.\n\nopenlab.dibris.unige.it' ) elif content_type == 'photo': bot.sendMessage(chat_id, 'Mi hai inviato una foto, ancora non posso leggerla')
def No14_Preference_Keyboard(): tmp = ReplyKeyboardMarkup(keyboard=[ [KeyboardButton(text='Canteen 14 (N) Chinese')], [KeyboardButton(text='Canteen 14 (N) Malay')], ], one_time_keyboard=True) return tmp
async def start(self, message: Dict[str, Any], _): ''' Start the game and send cards to players Args: message: a dict containing message data ''' chat_id = message['chat']['id'] message_id = message['message_id'] keyboard_markup = None try: game = self.games[chat_id] game.start() for user_id in game.players.keys(): for _ in range(2): await self.deal_random_card(user_id) reply = 'Game started!' keyboard_markup = ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text='Foreign aid'), KeyboardButton(text='Quit game') ]]) except KeyError: reply = 'The game was not created. Create it using /new_game' except GameAlreadyStarted: reply = 'Can\'t join middle game. Finish it or /force_end first' await self.bot.sendMessage( chat_id, reply, reply_to_message_id=message_id, reply_markup=keyboard_markup, )
def message(msg): content_type, chat_type, chat_id = telepot.glance(msg) print('Chat Message:', content_type, chat_type, chat_id) if content_type == 'text': if msg['text'] == '/start': data_entry(chat_id, "Start") bot.sendMessage( chat_id, 'Bienvenido\r\n utiliza el comando /key para iniciar') if msg['text'] == '/key': data_entry(chat_id, "Start Key") bot.sendMessage(chat_id, 'testing custom keyboard', reply_markup=ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text="On"), KeyboardButton(text="Off") ]])) if msg['text'] == 'On': data_entry(chat_id, "Turn on") bot.sendMessage(chat_id, "turning lights on!") if msg['text'] == 'Off': data_entry(chat_id, "Turn Off") bot.sendMessage(chat_id, "turning lights off!") if msg['text'] == '/readdb': read_db(chat_id)
def handle(msg): content_type, chat_type, chat_id = telepot.glance(msg) print(content_type, chat_type, chat_id) if content_type == 'text': #bot.sendMessage(chat_id, msg['from']['first_name']) #print(msg['text']) input = str(msg['text']).lower() if input == 'hallo': # # give a descriptive hint bot.sendMessage( chat_id, "Hallo " + msg['from']['first_name'] + "!\nWelcome back!") bot.sendMessage(chat_id, "What’s up?", reply_markup=ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text="Have a question"), KeyboardButton(text="Wanna track symptoms") ]])) #,force_reply=True) elif input == 'have a question': bot.sendMessage(chat_id, "test1") elif input == 'wanna track symptoms': bot.sendMessage(chat_id, "test2") else: bot.sendMessage(chat_id, "Sorry, I don't understand")
def send_confirm_remove(self, msg): content_type, chat_type, chat_id = telepot.glance(msg) msg_id = telepot.message_identifier(msg) to_delete_id = msg['text'][8:] res = self.getChatMember(group_chat_id, to_delete_id) if res['status'] != 'member': delete_member = Member(res['user']) self.send_message( admin_chat_id, f'can\'t remove {delete_member}, is not in chat user list, status is {res["status"]}' ) return if not to_delete_id.isdigit(): self.send_message( admin_chat_id, f'can\'t remove {to_delete_id}, wrong format of id') return keyboard = keyboard = [[ KeyboardButton(text=f"/confirm_remove_{to_delete_id}"), KeyboardButton(text="/no") ]] self.send_message(admin_chat_id, f'Do you really want to delete {to_delete_id}?', reply_markup=ReplyKeyboardMarkup( keyboard=keyboard, one_time_keyboard=True)) self.deleteMessage(msg_id) # remove the request message
def on_chat_message(msg): content_type, chat_type, chat_id = telepot.glance(msg) print(chat_id) # keyboard = InlineKeyboardMarkup(inline_keyboard=[ # [dict(text='Telegram URL', url='https://core.telegram.org/')], # [InlineKeyboardButton(text='Callback - show notification', callback_data='notification')], # [dict(text='Callback - show alert', callback_data='alert')], # [InlineKeyboardButton(text='Callback - edit message', callback_data='edit')], # [dict(text='Switch to using bot inline', switch_inline_query='initial query')], # ]) # keyboard = InlineKeyboardMarkup(inline_keyboard=[ # [InlineKeyboardButton(text='Press A', callback_data='a')], # [InlineKeyboardButton(text='Press B', callback_data='b')] # ]) # bot.sendMessage(chat_id, 'Use inline keyboard', reply_markup=keyboard) markup = ReplyKeyboardMarkup(keyboard=[ [KeyboardButton(text="Text A")], [KeyboardButton(text='Text B')], [KeyboardButton(text="Text C")], [dict(text='Phone', request_contact=True)], [KeyboardButton(text='Location', request_location=True)], ]) bot.sendMessage(chat_id, 'Custom keyboard with various buttons', reply_markup=markup)
def Food_Preference_Keyboard(): tmp = ReplyKeyboardMarkup( keyboard=[[KeyboardButton(text='Halal Preference')], [KeyboardButton(text='Vegetarian')], [KeyboardButton(text='No Preference')]], one_time_keyboard=True) return tmp
def on_chat_message(msg): global note, chat_id content_type, chat_type, chat_id = telepot.glance(msg) keyboard_on = ReplyKeyboardMarkup(keyboard=[ [KeyboardButton(text='Open Sherlock')], [KeyboardButton(text='Close Sherlock')], [KeyboardButton(text='Leave Note')] ]) keyboard_off = ReplyKeyboardHide(hide_keyboard=True) keyboard_in = InlineKeyboardMarkup(inline_keyboard=[ [InlineKeyboardButton(text='Yes!', callback_data='press')], ]) print msg['text'] bot.sendMessage(chat_id, msg['text'], reply_markup=keyboard_on) if note == False: if (msg['text'] == "Open Sherlock"): GPIO.output(20, True) elif (msg['text'] == "Close Sherlock"): GPIO.output(20, False) elif (msg['text'] == "Leave Note"): bot.sendMessage(chat_id,'Note to be written:', reply_markup=keyboard_off) note = True else: lcd.clear() lcd.message(msg['text']) bot.sendMessage(chat_id, 'Done?', reply_markup=keyboard_in)
def phone_number_confirmed(self, chat_id, c): if c.pending_order_gift_id \ and c.pending_order_gift_id != '': gift = None for g in self.dri.gifts: if c.pending_order_gift_id == g.id: gift = g break if gift is None: return bot.sendMessage(chat_id, 'لطفا آدرس را وارد نمایید.', reply_markup=ForceReply()) else: markup = ReplyKeyboardMarkup(keyboard=[ [KeyboardButton(text=new_gifts_fa)], [KeyboardButton(text=categories_fa)], [KeyboardButton(text=price_oriented_fa)], [KeyboardButton(text=about_us_fa)], ], resize_keyboard=True, one_time_keyboard=True) bot.sendMessage(chat_id, please_choose_fa, reply_markup=markup)
async def on_chat_message(msg): content_type, chat_type, chat_id = telepot.glance(msg) print('Chat:', content_type, chat_type, chat_id) if content_type != 'text': return command = msg['text'][-1:].lower() if command == 'c': markup = ReplyKeyboardMarkup(keyboard=[ ['Plain text', KeyboardButton(text='Text only')], [dict(text='Phone', request_contact=True), KeyboardButton(text='Location', request_location=True)], ]) await bot.sendMessage(chat_id, 'Custom keyboard with various buttons', reply_markup=markup) elif command == 'i': markup = InlineKeyboardMarkup(inline_keyboard=[ [dict(text='Telegram URL', url='https://core.telegram.org/')], [InlineKeyboardButton(text='Callback - show notification', callback_data='notification')], [dict(text='Callback - show alert', callback_data='alert')], [InlineKeyboardButton(text='Callback - edit message', callback_data='edit')], [dict(text='Switch to using bot inline', switch_inline_query='initial query')], ]) global message_with_inline_keyboard message_with_inline_keyboard = await bot.sendMessage(chat_id, 'Inline keyboard with various buttons', reply_markup=markup) elif command == 'h': markup = ReplyKeyboardHide() await bot.sendMessage(chat_id, 'Hide custom keyboard', reply_markup=markup) elif command == 'f': markup = ForceReply() await bot.sendMessage(chat_id, 'Force reply', reply_markup=markup)
def check_for_address(self, chat_id, address): c = Customer.query.filter_by(tg_id=str(chat_id)).first() if c and c.customer_phone and c.customer_phone != '' and \ c.pending_order_gift_id and c.pending_order_gift_id != '': gift = None for g in self.dri.gifts: if c.pending_order_gift_id == g.id: gift = g break if gift is None: return c.destination_address = address db.session.commit() bot.sendMessage( chat_id, 'لطفا تناژ مورد نظر را به صورت یک عدد وارد نمایید.', reply_markup=ForceReply()) else: markup = ReplyKeyboardMarkup(keyboard=[ [KeyboardButton(text=new_gifts_fa)], [KeyboardButton(text=categories_fa)], [KeyboardButton(text=price_oriented_fa)], [KeyboardButton(text=about_us_fa)], ], resize_keyboard=True, one_time_keyboard=True) bot.sendMessage(chat_id, please_choose_fa, reply_markup=markup)
def showEffects(self, gamer): index = self.getIndexFromId(gamer) effects = [] for i in range(len(self.gamer[index].effectEv)): if self.gamer[index].effectEv[i] > 0: effects.append(costant.keyboardEvocation[i]) if len(effects) == 0: return -1 else: key = [] i = 0 while (i < len(effects)): if len(effects) == 1: key.append([KeyboardButton(text=effects[i])]) else: key.append([ KeyboardButton(text=effects[i]), KeyboardButton(text=effects[i + 1]) ]) i += 2 keyboard = ReplyKeyboardMarkup(keyboard=key, one_time_keyboard=True, selective=True) self.bot.sendMessage( self.gamer[1], self.gamer[index].name + " scegli cosa evocare!", reply_to_message_id=self.gamer[index].messageId, reply_markup=keyboard) self.currentTurn = 'Attack' self.bot.sendMessage( self.gamer[1], self.gamer[self.attackTurn].name + " deve attaccare/evocare! ") return 1
def markupLocation(lang): text = translate.markupLocation(lang) return ReplyKeyboardMarkup( keyboard=[[KeyboardButton(text=text[0], request_location=True)], [KeyboardButton(text=text[1])]], resize_keyboard=True, one_time_keyboard=True)
def query_employee(message_offset_id, person, bot_obj, query_msg=None): his_answer = False emp = employee[person]['name'] keyboard = ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True, keyboard=[ [ KeyboardButton(text="yes", callback_data="yes"), KeyboardButton(text="no", callback_data="no") ], ]) if not query_msg: query_msg = "{} needs a {}. Are you available?".format( "Carl", employee[person]['job']) bot_obj.sendMessage(employee[person]['id'], query_msg, reply_markup=keyboard) employee_answer, message_offset_id = get_one_message(message_offset_id) if "callback_query" in employee_answer: markup = ReplyKeyboardRemove() bot_obj.sendMessage(employee[person]['id'], "Ok, got it", reply_markup=markup) if employee_answer["callback_query"]["data"] == "yes": his_answer = emp else: _, action_type, _ = analyze_request(bot_obj, employee_answer['message']['text']) if action_type == "affermative": his_answer = emp return his_answer, message_offset_id
def post(self, request, bot_token): commands = { '/start': _send_help(), 'news': _send_news(), 'help': _send_help(), 'russia': _send_statistic("Russia"), 'all': _send_statistic("All"), 'advices': _send_advices(), } reply_markup = ReplyKeyboardMarkup(keyboard=[ [KeyboardButton(text='Russia')], [KeyboardButton(text='All')], [KeyboardButton(text='News')], [KeyboardButton(text='Advices')], ], resize_keyboard=True) try: telegram_bot = telepot.Bot(bot_token) payload = json.loads(request.body.decode('utf-8')) except ValueError: return HttpResponseBadRequest('Invalid request body') else: chat_id = payload['message']['chat']['id'] cmd = payload['message'].get('text').lower() result = commands.get(cmd) if result: telegram_bot.sendMessage(chat_id, result, reply_markup=reply_markup, parse_mode='Markdown') if cmd == 'all' or cmd == 'russia': telegram_bot.sendPhoto(chat_id, get_statistics_history(cmd)) else: telegram_bot.sendMessage(chat_id, 'Я вас не понимаю, воспользуйтесь командой /help.') return JsonResponse({}, status=200)
def handle(message): content_type, chat_type, chat_id = telepot.glance(message) print(content_type, chat_type, chat_id) keyboard = ReplyKeyboardMarkup(keyboard=[ [KeyboardButton(text=button1), KeyboardButton(text=button2)] ]) if content_type != 'text': return feedback = message['text'].lower() global burgerNumber if feedback == '/freebk': holding_burger_generation(chat_id, keyboard) elif feedback == button1: holding_burger_generation(chat_id, keyboard) elif feedback == button2: burgerNumber = mongo_interact.MongoInteract().countAllBurgerGenerated() bot.sendMessage(chat_id, aboutText, reply_markup=keyboard) elif feedback == '/start': bot.sendMessage(chat_id, welcomeText, reply_markup=keyboard) elif feedback == '/about': burgerNumber = mongo_interact.MongoInteract().countAllBurgerGenerated() bot.sendMessage(chat_id, aboutText, reply_markup=keyboard) else: bot.sendMessage(chat_id, "Press " + button1 + ", get burgers!", reply_markup=keyboard)
def getKeyboard(id): # se aministratore if sql.getUser(id)[0][4] == 1: keyboard = ReplyKeyboardMarkup( keyboard=[ [KeyboardButton(text="Autisti"), KeyboardButton(text="Documenti_oggi")] ] ) return keyboard else: keyboard = ReplyKeyboardMarkup( keyboard=[ [KeyboardButton(text="Consegne di oggi")] ] ) return keyboard
def main_markup(): w_bokal_btn = KeyboardButton(text='Вино по бокалам') w_botl_btn = KeyboardButton(text='Вино по бутылкам') vodka_btn = KeyboardButton(text='Крепкие напитки') coctail_btn = KeyboardButton(text='КОКТЕЙЛЬНАЯ КАРТА') markup = ReplyKeyboardMarkup( keyboard=[[w_bokal_btn], [w_botl_btn], [vodka_btn], [coctail_btn]]) return markup
def shuffle_reset_keys(reply): bot.sendMessage(chat_id, reply, reply_markup=ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text='Shuffle'), KeyboardButton(text='Reset') ]], resize_keyboard=True))
def showOptions(options): buttons = [] if type(options) != str: for option in options: buttons.append([KeyboardButton(text = option)]) else: buttons.append([KeyboardButton(text = options)]) return ReplyKeyboardMarkup(keyboard = buttons, resize_keyboard = True, one_time_keyboard = True, selective = True)
def getKeyboardNotifiche(): kNotifiche = ReplyKeyboardMarkup( keyboard=[ [KeyboardButton(text=emoji.emojize(ini.get("key","deleteNoti"), use_aliases=True))], [KeyboardButton(text=emoji.emojize(ini.get("admin","menu"), use_aliases=True))] ], resize_keyboard=True ) return kNotifiche
def accept_reject_keys(): bot.sendMessage(chat_id, 'Would you like this set of clothes?', reply_markup=ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text='Accept'), KeyboardButton(text='Reject') ]], resize_keyboard=True))