def _getStartChat(self): self.sender.sendMessage( '<strong>Selamat Datang di Telegram Bot @warungid_bot</strong>\nKunjungi Website kami di <a href="http://warungid.com">Warungid.com</a> untuk informasi lebih lanjut.', parse_mode='HTML', reply_markup=ReplyKeyboardMarkup( keyboard=[ [KeyboardButton(text='/menu')], ], one_time_keyboard=True, resize_keyboard=True, ))
async def on_chosen_inline_result(self, msg): result_id, from_id, query = telepot.glance(msg, flavor='chosen_inline_result') print('Chosen inline result:', result_id, from_id, query) self._suggested_date = datetime.strptime(msg['result_id'], '%Y-%m-%d') self._suggestion_editor = Editor(self.bot, msg) self._votes = {} await self.sender.sendMessage('Decided on %s?' % msg['result_id'], reply_markup=ReplyKeyboardMarkup( keyboard=[[ KeyboardButton(text='Decided'), KeyboardButton(text='Cancel'), ]], one_time_keyboard=True ) ) sent = await self.sender.sendMessage('Yes: %d\nNo: %d' % self._count_votes()) self._counter_editor = Editor(self.bot, sent)
def on_chat_message(msg): content_type, chat_type, chat_id = telepot.glance(msg) texto = msg['text'] if texto == '/menu': global seleccionC, seleccionG, seleccionGr seleccionC = False seleccionG = False seleccionGr = False bot.sendMessage( chat_id, 'Menú principal:\n ¿Qué quieres saber?', reply_markup=ReplyKeyboardMarkup( keyboard=[[ KeyboardButton(text="Horarios"), KeyboardButton(text="Tutorías") ], [ KeyboardButton(text="Profesores"), KeyboardButton(text="Clases") ], [KeyboardButton(text="Fichas docentes")]]))
def handle(msg): chatid = msg['chat']['id'] comando = msg['text'] keyboard=ReplyKeyboardMarkup( keyboard=[ [KeyboardButton(text="Temperatura"), KeyboardButton(text="IP")], [KeyboardButton(text="Memoria"), KeyboardButton(text="UsoSD")], [KeyboardButton(text="UpTime"), KeyboardButton(text="Data")], [KeyboardButton(text="CPU_Info"), KeyboardButton(text="Ajuda")], ]) if comando == '/start': bot.sendMessage(chatid,'Bem Vindo!!') bot.sendMessage(chatid,'Bot desenvolvido por @joao_slv!') bot.sendMessage(chatid,'Iniciando o Bot...') bot.sendMessage(chatid,'Use os comandos do teclado abaixo', reply_markup=keyboard ) elif comando == 'Temperatura': bot.sendMessage(chatid, 'Temperatura : ') elif comando == 'Memoria': bot.sendMessage(chatid, 'Memoria em uso: ') elif comando == 'UpTime': bot.sendMessage(chatid, 'Uptime do Sistema: ') elif comando == 'UsoSD': bot.sendMessage(chatid, 'Uso do MicroSD: ') elif comando == 'Data': bot.sendMessage(chatid, 'Data e Hora do sistema: ') elif comando == 'IP': bot.sendMessage(chatid, 'O Meu IP: 127.0.0') elif comando == 'CPU_Info': bot.sendMessage(chatid, 'Aqui estao as informacoes sobre a CPU:') elif comando == 'Ajuda': bot.sendMessage(chatid, 'Menu de Ajuda aqui voce nao vai encotrar ajuda nem uma =/ ') else: bot.sendMessage(chatid, 'Use os comandos no teclado')
def phone_number_confirmation(self, chat_id, gift_id, c): if c.customer_phone != '': markup = ReplyKeyboardMarkup(keyboard=[ [KeyboardButton(text=confirm_phone_number_fa)], [KeyboardButton(text=send_phone_fa, request_contact=True)], [KeyboardButton(text=cancel_order_fa)], ]) bot.sendMessage(chat_id, phone_number_saved_fa.format(c.customer_phone), reply_markup=markup) else: keyboard = [ [KeyboardButton(text=send_phone_fa, request_contact=True)], [KeyboardButton(text=cancel_order_fa)], ] markup = ReplyKeyboardMarkup(keyboard=keyboard, resize_keyboard=True, one_time_keyboard=True) bot.sendMessage(chat_id, order_text_send_phone_fa.format(str(gift_id)), reply_markup=markup)
def __init__(self, *args, **kwargs): self._state = "start" super(MessageCounter, self).__init__(*args, **kwargs) self._msgContent = "" self.cnx = DBHelper.connection(); self.cursor = DBHelper.setup_cursor(self.cnx) self.reg = Register(self.sender) login = KeyboardButton(text='ورود', request_contact=True) reg = KeyboardButton(text='ثبت نام') self.initial = [[login , reg]] self.userInfo = { 'name': "", 'age': "", 'sex': "", 'field': "" }
def ended(self): if self.score1==self.max_point: player_db.add_player(self.p1.chat__id,'available',self.p1.score + self.score1 - self.score2,self.p1.user_name) bot.sendMessage(int(self.p1.chat__id),"Машала, ти виграла гру") player_db.add_player(self.p2.chat__id, 'available', self.p2.score + self.score2 - self.score1,self.p2.user_name) bot.sendMessage(int(self.p2.chat__id), "Ви знову програли...") elif self.score2 == self.max_point: player_db.add_player(self.p1.chat__id, 'available', self.p1.score + self.score1 - self.score2, self.p1.user_name) bot.sendMessage(int(self.p1.chat__id), "Ви знову програли ...") bot.sendMessage(int(self.p2.chat__id), "Машала, ти виграла гру") player_db.add_player(self.p2.chat__id, 'available', self.p2.score + self.score2 - self.score1, self.p2.user_name) bot.sendMessage(int(self.p1.chat__id), 'خوب از کیبورد زیر بگو واست چی کار کنم', reply_markup=ReplyKeyboardMarkup( keyboard=[[KeyboardButton(text=menu_array[1])], [KeyboardButton(text=menu_array[2]), KeyboardButton(text=menu_array[3])], [KeyboardButton(text=menu_array[5]), KeyboardButton(text=menu_array[6])]], resize_keyboard=True)) bot.sendMessage(int(self.p2.chat__id), 'Ну, з клавіатури нижче, скажіть мені, що мені робити', reply_markup=ReplyKeyboardMarkup( keyboard=[[KeyboardButton(text=menu_array[1])], [KeyboardButton(text=menu_array[2]), KeyboardButton(text=menu_array[3])], [KeyboardButton(text=menu_array[5]), KeyboardButton(text=menu_array[6])]], resize_keyboard=True)) conn = mysql.connector.connect(host='localhost', database='DataBase', user='******', password='******') cur = conn.cursor() try: cur.execute("""UPDATE players SET score=%s WHERE chat_id=%s""", (int(self.p1.score + self.score1 - self.score2),str(self.p1.chat__id))) cur.execute("""UPDATE players SET score=%s WHERE chat_id=%s""", (int(self.p2.score + self.score2 - self.score1),str(self.p2.chat__id))) except Error as e: print(str(e) + " : this error has been occured ") conn.commit() cur.close() conn.close()
def __init__(self, *args, **kwargs): self._token = TOKEN self.callback = [] # Список доступных callback функций self.commands = [] # Список всех доступных комманд бота self._find_bot_functions() # Модифицированные команды: self.modified_commands = { "Все тесты ✍": "all_tests", "Результаты 🏆": "results", "Помощь ❕": "help", "Продолжить тест 👉": "continue_test", "Мои тесты ✍": "my_tests", "Построить график функции": "graphics" } # Главная клавиатура бота self.main_keyboard = ReplyKeyboardMarkup(keyboard=[ [ KeyboardButton(text="Все тесты ✍"), KeyboardButton(text="Мои тесты ✍") ], [ KeyboardButton(text="Помощь ❕"), KeyboardButton(text="Результаты 🏆") ], [KeyboardButton(text="Продолжить тест 👉")], [KeyboardButton(text="Построить график функции")], ])
def handle(msg): content_type, chat_type, chat_id = telepot.glance(msg) print(content_type, chat_type, chat_id) if msg['text'] == '/start': bot.sendMessage(chat_id, "خوش آمدید\n ربات تست من") elif msg['text'] == '/info': bot.sendMessage(chat_id, 'my name is phika\ninstagram:\[email protected]\ntelegram:\t@Phika') elif msg['text'] == '/keyboard': # to create keyboard row1 = [KeyboardButton(text = '0, 0'), KeyboardButton(text = '0, 1')] row2 = [KeyboardButton(text = '1, 0'), KeyboardButton(text = '1, 1'), KeyboardButton(text = 'remove keyboard')] my_keyboard = ReplyKeyboardMarkup(keyboard=[row1, row2]) # to show keyboard bot.sendMessage(chat_id,'keyboard has been created', reply_markup = my_keyboard) elif msg['text'] == 'remove keyboard': # to remove keyboard bot.sendMessage(chat_id, 'keyboard has been Deleted!', reply_markup=ReplyKeyboardRemove()) else: bot.sendMessage(chat_id, "You said '{}'".format(msg["text"]))
def bitva_boss(): hpg = 3 # Здоровье врага hpe = 3 while hpg > 0 and hpe > 0: n = random.randint(1, 2) m = random.randint(1, 2) if n == 2 and m == 2: hpe -= 1 if hpe == 1: keyboard = ReplyKeyboardMarkup( keyboard=[[KeyboardButton(text="В бой!")]]) return keyboard hpg -= 1 if hpg == 0: keyboard = ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text="Вы умерли... Начать сначала") ]]) return keyboard continue elif n == 2 and m == 1: hpe -= 1 if hpe == 1: keyboard = ReplyKeyboardMarkup( keyboard=[[KeyboardButton(text="В бой!")]]) return keyboard continue elif n == 1 and m == 2: hpg -= 1 if hpg == 0: keyboard = ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text="Вы умерли... Начать сначала") ]]) return keyboard continue elif n == 1 and m == 1: continue input() pass
def on_chat_message(msg): content_type, chat_type, chat_id = telepot.glance(msg) print('Chat Message:', content_type, chat_type, chat_id) full = client(GetFullUserRequest(user)) #users.getFullUser if content_type == 'text': if msg['text'] == '/key': print('key...') location_keyboard = KeyboardButton( text="send_location", request_location=True) #creating location button object contact_keyboard = KeyboardButton( 'Share contact', request_contact=True) #creating contact button object custom_keyboard = [[location_keyboard, contact_keyboard]] #creating keyboard object reply_markup = ReplyKeyboardMarkup(custom_keyboard) bot.sendMessage(1204307512, 'Example', reply_markup=reply_markup)
def create_weather_start_keyboard(self): try: fav1 = list(self.cookies['wetter']['fav1'].keys())[0] except (KeyError, IndexError): fav1 = "Favorit 1" try: fav2 = list(self.cookies['wetter']['fav2'].keys())[0] except (KeyError, IndexError): fav2 = "Favorit 2" keyboard = ReplyKeyboardMarkup(keyboard=[ [ KeyboardButton(text=fav1) ], [ KeyboardButton(text=fav2) ], [ KeyboardButton(text="Suche"), KeyboardButton(text="Favoriten bearbeiten") ] ]) return keyboard
def encerraPedido(self, chatID): total = 0 if self.__users[chatID]['pedido']: self.__users[chatID]['status'] = 3 for i in range(0, len(self.__users[chatID]['pedido'])): total += float( self.__precos[self.__users[chatID]['pedido'][i]]) pedido = ", ".join(self.__users[chatID]['pedido']) self.robot.sendMessage(chatID, "Pedido Atual: " + pedido) self.robot.sendMessage(chatID, "Valor Total: " + str(total)) sent = self.robot.sendMessage( chatID, 'Deseja encerrar este pedido ?', reply_markup=ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text="sim ( ͡~ ͜ʖ ͡°)"), KeyboardButton(text="nao") ]], one_time_keyboard=True)) self._keyboard_msg_ident[chatID] = telepot.message_identifier(sent) else: self.robot.sendMessage(chatID, "Ainda não há nenhum pedido :c ") self.__users[chatID]['status'] = 1
def NoNS_Preference_Keyboard(): tmp = ReplyKeyboardMarkup(keyboard=[ [KeyboardButton(text='North Spine Canteen (N) Korean')], [KeyboardButton(text='North Spine Canteen (N) Japanese')], [KeyboardButton(text='North Spine Canteen (N) Chinese')], [KeyboardButton(text='North Spine Canteen (N) Western')], [KeyboardButton(text='North Spine Canteen (N) Malay')], [KeyboardButton(text='North Spine Canteen (N) Indian')], [KeyboardButton(text='North Spine Canteen (N) Vietnamese')], ], one_time_keyboard=True) return tmp
def on_chat_message(msg): content_type, chat_type, chat_id = telepot.glance(msg) game.sendMessage(chat_id, 'Activate keyboard', reply_markup=ReplyKeyboardMarkup(keyboard=[ [ KeyboardButton(text="/left"), KeyboardButton(text="/right"), KeyboardButton(text="/a"), KeyboardButton(text="/a") ], [ KeyboardButton(text="/p1"), KeyboardButton(text="/down"), KeyboardButton(text="/p2"), KeyboardButton(text="/a"), KeyboardButton(text="/a") ], ]))
def Halal_Preference_Keyboard(): tmp = ReplyKeyboardMarkup(keyboard=[ [KeyboardButton(text=' Canteen 2 (H)')], [KeyboardButton(text=' Canteen 14 (H)')], [KeyboardButton(text=' Canteen 16 (H)')], [KeyboardButton(text=' North Hill Canteen (H)')], [KeyboardButton(text=' North Spine Canteen (H)')], [KeyboardButton(text=' South Spine Canteen (H)')], [KeyboardButton(text=' NIE Canteen (H)')], ], one_time_keyboard=True) return tmp
def gift_amount(self, chat_id, amount, 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 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, order_done_fa, reply_markup=markup) s = Sell() s.gift_amount = amount s.sell_address = c.destination_address s.customer_id = c.id s.customer_phone = c.customer_phone s.gift_id = gift.id s.sell_price = gift.gift_price c.pending_order_gift_id = None db.session.add(s) db.session.commit() 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 handle(msg): content_type, chat_type, chat_id = telepot.glance(msg) global hottest_count if content_type == 'text': if msg['text'] == 'Get Random Post': response = urllib.request.urlopen('http://9gag.com/random') bot.sendMessage(chat_id, 'Here you go!') bot.sendMessage(chat_id, response.geturl()) elif msg['text'] == 'Get Hottest Posts': posts_rss = feedparser.parse( 'http://www.9gag-rss-feed.ovh/rss/9GAG_-_Hot.atom') if hottest_count >= len(posts_rss.entries): hottest_count = 0 for post in posts_rss.entries[hottest_count:hottest_count + 10]: hottest_count += 1 bot.sendMessage(chat_id, post.link) else: bot.sendMessage( chat_id, "I don't understand you, I'm not a human, please use the keyboard :(" ) else: bot.sendMessage(chat_id, 'You should type something.') bot.sendMessage(chat_id, 'What do you want?', reply_markup=ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text="Get Random Post"), KeyboardButton(text="Get Hottest Posts") ]], resize_keyboard=True))
def get_reply_keyboard_markup(button_strings, resize_keyboard=True): keyboard_buttons = [] for s in button_strings: keyboard_buttons += [KeyboardButton(text=s)] #3*N keyboard_buttons_reshaped = [] for i in range(0, len(keyboard_buttons), 3): keyboard_buttons_reshaped.append(keyboard_buttons[i:i + 3]) keyboard = ReplyKeyboardMarkup(keyboard=keyboard_buttons_reshaped, resize_keyboard=resize_keyboard, one_time_keyboard=True) return keyboard
def unsettedParams(self): keys = [] if not self.ride_type: keys.append([KeyboardButton(text='/set_category')]) if not self.radius: keys.append([KeyboardButton(text='/set_radius')]) if not self.exp_time: keys.append([KeyboardButton(text='/set_waiting_time')]) if not keys: if not self.isActive(): # users = pickle.load(open('users.pickle', 'r+b')) # for u in users: # if u.chat_id == self.chat_id: # users.remove(u) # users.append(self) # with open('users.pickle', 'w+b') as f: # pickle.dump(users, f) # del users return ReplyKeyboardMarkup( keyboard=[[KeyboardButton(text='/wonnaride')]]) else: return self.quitQueueKeyboard() return ReplyKeyboardMarkup(keyboard=keys)
def categories_result(msg, dri): chat_id = str(msg['from']['id']) categories = dri.categories keyboard = [] twos = False for i in range(len(categories)): if twos: twos = not twos continue if i < len(categories) - 1: keyboard.append([ KeyboardButton(text=categories[i].category_title), KeyboardButton(text=categories[i + 1].category_title) ]) twos = True else: keyboard.append( [KeyboardButton(text=categories[i].category_title)]) keyboard.append([KeyboardButton(text=to_main_menu_fa)]) markup = ReplyKeyboardMarkup(keyboard=keyboard, resize_keyboard=True, one_time_keyboard=True) bot.sendMessage(chat_id, please_choose_fa, reply_markup=markup)
async def makebutton4cancel(flag_NPE, flag_back = False, flag_next = False, *args): temp_markup = [[dict(text = "انصراف")]] markup_in = [] counter_row = 0 for keyboards in args: counter_row += 1 if counter_row == 1: markup_in.append(dict(text = str(keyboards))) elif counter_row == 4: markup_in.append(KeyboardButton(text = keyboards)) counter_row = 0 else: markup_in.append(KeyboardButton(text = keyboards)) if counter_row == 0: temp_markup.append(markup_in) markup_in = [] else: if markup_in: temp_markup.append(markup_in) return temp_markup
def request_add(target_id, message, to_add_cg, to_add_id, to_add_name): logger.info('Superadmin attention was requested from %s to %s' % (chat_id, target_id)) reply_markup = ReplyKeyboardMarkup( keyboard=[ [ KeyboardButton(text='/add %s %s %s' % (to_add_cg, to_add_name, to_add_id)) ], ['Reject'], ], one_time_keyboard=True, ) #self.sendMessage(target_id, message, reply_markup=reply_markup) bot.sendMessage(target_id, message, reply_markup=reply_markup)
def respond_keyboard(self, response): """ Add response to list """ if type(response) is list: buttons = [] for l in response: buttons.append(KeyboardButton(text=l)) if len(buttons) == 0: reply_markup = ReplyKeyboardRemove(remove_keyboard=True) else: reply_markup = ReplyKeyboardMarkup(keyboard=[buttons]) self.response.append({'keyboard': reply_markup}) else: raise ValueError('Response is not correct format')
def handle(msg): global command chat_id = msg['chat']['id'] command = msg['text'] print("Mudun") if command == '/start' or command == '/Kembali' or command == '/Start': bot.sendMessage( chat_id, 'Halo Selamat datang Ada yang bisa dibantu?', reply_markup=ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text="/Voltage"), KeyboardButton(text="/Volume") ], [KeyboardButton(text="/a"), KeyboardButton(text="/b")]])) elif command == '/Voltage': for row in records: id = row[0] nama = row[1] alamat = row[3] bot.sendMessage(chat_id, id) bot = telepot.Bot('576188757:AAESFfKu1T7jvZbASG6wpHf0m1WG0-xlOmQ') bot.message_loop(handle) print('Menunggu Perintah ...')
def Halal1_Preference_Keyboard(): ##Can remove tmp = ReplyKeyboardMarkup( keyboard=[[KeyboardButton(text='Canteen 1 (H) Japanese')], [KeyboardButton(text='Canteen 1 (H) Chinese')], [KeyboardButton(text='Canteen 1 (H) Western')], [KeyboardButton(text='Canteen 1 (H) Malay')], [KeyboardButton(text='Canteen 1 (H) Indian')], [KeyboardButton(text='Canteen 1 (H) Vietnamese')]], one_time_keyboard=True) return tmp
def w_bokal_markup(): global back_main_menu w_bokal_red_btn = KeyboardButton(text='Красное (бокал)') w_bokal_white_btn = KeyboardButton(text='Белое (бокал)') w_bokal_pink_btn = KeyboardButton(text='Розовое (бокал)') w_bokal_strong_btn = KeyboardButton(text='Креплёное (бокал)') w_bokal_desert_btn = KeyboardButton(text='Десертное (бокал)') w_bokal_sparkling_btn = KeyboardButton(text='Игристое (бокал)') back_main_menu = KeyboardButton(text='Назад') markup = ReplyKeyboardMarkup( keyboard=[[w_bokal_red_btn], [w_bokal_white_btn], [w_bokal_pink_btn], [w_bokal_strong_btn], [w_bokal_desert_btn], [w_bokal_sparkling_btn], [back_main_menu]]) return markup
def get_attrs_keyboard(answer, client): attr_ids = [int(x) for x in client.city.attrs.split(';') if x != ''] variants = [] for attr in answer['data']['order_params']: if attr['id'] in attr_ids: if not attr['id'] in json.loads(client.info).get('attr_ids', []): variants.append( emoji.emojize(':heavy_check_mark:') + ' ' + attr['name']) if attr['id'] in json.loads(client.info).get('attr_ids', []): variants.append( emoji.emojize(':heavy_multiplication_x:') + ' ' + attr['name']) variants.sort() return ReplyKeyboardMarkup(keyboard=[[KeyboardButton(text=x)] for x in variants] + [[emoji.emojize(':left_arrow: Назад')]])
def send_msg_location(text, user): textbutton = DB.nexxt_uurregistratie(user) + ' werkdag' try: telegram.delete_msg(user['id'], user['last_tijdregistratie_id']) except: None bericht = bot.sendMessage( text=text, chat_id=user['id'], reply_markup=ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text=vertaal(textbutton, user), request_location=True) ]])) DB.add_user_data(user['id'], 'last_tijdregistratie_id', bericht['message_id'])
def output_choose_shoes_size(chat_id): bot.sendMessage(chat_id, "Какой тип обуви нужно сделать?", reply_markup=ReplyKeyboardMarkup(keyboard=[[ KeyboardButton(text="39"), KeyboardButton(text="40"), KeyboardButton(text="41"), KeyboardButton(text="42"), KeyboardButton(text="43"), KeyboardButton(text="44"), KeyboardButton(text="45") ]], resize_keyboard=True, one_time_keyboard=True))