def gen_skip_markup(): markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add(InlineKeyboardButton("Ruka neno", callback_data='ruka'), InlineKeyboardButton("Ondoka", callback_data='ondoka')) return markup
def inl_gainer_third_pos_two(self): markup = InlineKeyboardMarkup(row_width=2) first_b = InlineKeyboardButton("+", callback_data='ig3p2') second_b = InlineKeyboardButton("Назад", callback_data='ig3next1') markup.add(first_b, second_b) return markup
def inl_amino_first_pos_one(self): markup = InlineKeyboardMarkup(row_width=2) first_b = InlineKeyboardButton("+", callback_data='ia1p1') second_b = InlineKeyboardButton("Далее", callback_data='iaa21next2') markup.add(first_b, second_b) return markup
def inl_protein_sixth_pos_two(self): markup = InlineKeyboardMarkup(row_width=2) first_b = InlineKeyboardButton("+", callback_data='ip6p2') second_b = InlineKeyboardButton("Назад", callback_data='ip6next1') markup.add(first_b, second_b) return markup
def inl_protein_ninth_pos_one(self): markup = InlineKeyboardMarkup(row_width=2) first_b = InlineKeyboardButton("+", callback_data='ip9p1') markup.add(first_b) return markup
def gen_markup(): markup = InlineKeyboardMarkup() markup.row_width = 1 markup.add(InlineKeyboardButton("Azo bo'ling", url='t.me/onideal'), InlineKeyboardButton("Azo bo'ling", url='t.me/quyichirchiq_bozori'), InlineKeyboardButton("Tasdiqlash", callback_data="yes")) return markup
def create_calendar( self, name: str = "calendar", year: int = None, month: int = None, ) -> InlineKeyboardMarkup: """ Create a built in inline keyboard with calendar :param name: :param year: Year to use in the calendar if you are not using the current year. :param month: Month to use in the calendar if you are not using the current month. :return: Returns an InlineKeyboardMarkup object with a calendar. """ now_day = datetime.datetime.now() if year is None: year = now_day.year if month is None: month = now_day.month calendar_callback = CallbackData(name, "action", "year", "month", "day") data_ignore = calendar_callback.new("IGNORE", year, month, "!") data_months = calendar_callback.new("MONTHS", year, month, "!") keyboard = InlineKeyboardMarkup(row_width=7) keyboard.add( InlineKeyboardButton( self.__lang.months[month - 1] + " " + str(year), callback_data=data_months, )) keyboard.add(*[ InlineKeyboardButton(day, callback_data=data_ignore) for day in self.__lang.days ]) for week in calendar.monthcalendar(year, month): row = list() for day in week: if day == 0: row.append( InlineKeyboardButton(" ", callback_data=data_ignore)) elif (f"{now_day.day}.{now_day.month}.{now_day.year}" == f"{day}.{month}.{year}"): row.append( InlineKeyboardButton( f"({day})", callback_data=calendar_callback.new( "DAY", year, month, day), )) else: row.append( InlineKeyboardButton( str(day), callback_data=calendar_callback.new( "DAY", year, month, day), )) keyboard.add(*row) keyboard.add( InlineKeyboardButton( "<", callback_data=calendar_callback.new("PREVIOUS-MONTH", year, month, "!"), ), InlineKeyboardButton( "Cancel", callback_data=calendar_callback.new("CANCEL", year, month, "!"), ), InlineKeyboardButton(">", callback_data=calendar_callback.new( "NEXT-MONTH", year, month, "!")), ) return keyboard
def send_help(message): keyboard = InlineKeyboardMarkup() url_button = InlineKeyboardButton(text="Перейти на наш сайт", url=URL) keyboard.add(url_button) bot.send_message(message.chat.id, HELP_TEXT, reply_markup=keyboard)
def render_round_buttons(data): markup = ReplyKeyboardMarkup(True, True) markup.add(*(InlineKeyboardButton('Вариант {}'.format(i)) for i in range(1, len(data) + 1))) return markup
import telebot from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton from constants import token, db_conn, updateMessage, messages if __name__ == '__main__': bot = telebot.TeleBot(token) markup = InlineKeyboardMarkup() markup.add( InlineKeyboardButton(text=messages['menu'], callback_data='menu')) counter = 0 with db_conn.cursor() as cur: sql_query = 'SELECT user_id, first_name FROM user_settings WHERE created_at >= \'2018-03-29 16:00:00\';' cur.execute(sql_query) for i in cur: try: bot.send_message(chat_id=i[0], text=updateMessage.format(i[1]), parse_mode='Markdown', reply_markup=markup) print(i) except: print(i, 'PASS') counter += 1 continue print(counter)
def queue_callback(self): #print 'sqlite_callback' try: message = self.request_queue.get_nowait() except QueueEmpty: pass else: start = False is_reset = False if message['text'] in [COMMANDS['full_cmd'], COMMANDS['full_txt']]: message.update({ 'date': int(time.time()), 'kbm': '3', 'osago_type': 'full' }) row = self.sql.execute(''' INSERT INTO osago (date, chat_id, username, first_name, last_name, osago_type) VALUES (%(date)s, '%(chat_id)s', '%(username)s', '%(first_name)s', '%(last_name)s', '%(osago_type)s');''' % message) start = True elif message['text'] in [COMMANDS['simple_cmd'], COMMANDS['simple_txt']]: message.update({ 'date': int(time.time()), 'osago_type': 'simple', 'vladelec': '1', 'usloviya': '0', 'kbm': '3', 'tip_ts': 'b', 'region': '3', 'period_in': '10' }) row = self.sql.execute(''' INSERT INTO osago (date, chat_id, username, first_name, last_name, vladelec, usloviya, tip_ts, region, period_in, osago_type, kbm) VALUES (%(date)s, '%(chat_id)s', '%(username)s', '%(first_name)s', '%(last_name)s', '%(vladelec)s', '%(usloviya)s', '%(tip_ts)s', '%(region)s', '%(period_in)s', '%(osago_type)s', '%(kbm)s');''' % message) start = True elif message['text'] in [COMMANDS['reset_cmd'], COMMANDS['reset_txt']]: markup = ReplyKeyboardMarkup(row_width=2, resize_keyboard=True) # button_osago = KeyboardButton(text=COMMANDS['full_txt']) button_simple = KeyboardButton(text=COMMANDS['simple_txt']) # markup.add(button_osago) markup.add(button_simple) self.response_queue.put({ 'chat_id':message['chat_id'], 'wait_message_id':message['wait_message_id'], 'message_text':WELCOME_TEXT, 'markup': markup }) is_reset = True elif message['text'] == 'contact': self.save_contact(message) markup = ReplyKeyboardMarkup(one_time_keyboard=True, resize_keyboard=True) reset_button = KeyboardButton(text=COMMANDS[u'reset_txt']) markup.add(reset_button) self.response_queue.put({ 'chat_id':message['chat_id'], 'wait_message_id':message['wait_message_id'], 'message_text': 'contact', 'markup': markup }) is_reset = True if not is_reset: self.sql.commit() question, markup, is_calc = self.get_question(message, start=start) self.response_queue.put({ 'chat_id':message['chat_id'], 'wait_message_id':message['wait_message_id'], 'message_text':question, 'markup': markup }) if is_calc: markup = InlineKeyboardMarkup() url_button = InlineKeyboardButton(text="Перейти на наш сайт", url=URL) markup.add(url_button) question = u'Более подробную информацию Вы можете узнать на нашем сайте.' self.response_queue.put({ 'chat_id':message['chat_id'], 'wait_message_id':message['wait_message_id'], 'message_text': question, 'markup': markup }) self.request_queue.task_done()
def task_new(id_course): button = InlineKeyboardButton("Новое задание", callback_data=dumps( dict(type='new_task', id=id_course))) return button
"""Кнопки преподователей""" from json import dumps from telebot.types import InlineKeyboardButton from Models import Course from Models import User # выводит управляемые курсы manage_list = InlineKeyboardButton('Управление курсами', callback_data=dumps( dict(type='menu', cmd='teach_courses', page=0))) def manage(id, prev=None): button = InlineKeyboardButton('Управление', callback_data=dumps( dict(type='c_act', cmd='mng', id=id, prev=prev))) return button create = InlineKeyboardButton('Создать курс', callback_data=dumps( dict(type='new_course', cmd='NONE')))
def gen_exit_rankings_markup(): markup = InlineKeyboardMarkup() markup.row_width = 1 markup.add(InlineKeyboardButton("Nimetii!!", callback_data='ondoka')) return markup
def callback_query(call): global im variants = {} if not call.data.startswith("select"): category = call.data bot.answer_callback_query(call.id, f"Some variants for {category}") images = get_images(category) im = images[:] for image, idx in images: send_with_rerun(bot.send_photo, call.message.chat.id, image, caption=idx) keyboard = telebot.types.InlineKeyboardMarkup(row_width=5) for i, variant in enumerate(range(1, RESULT_NUMBER + 1), 1): variants[i] = 0 keyboard.add( InlineKeyboardButton(f"Variant {variant}: 0", callback_data=f"select-{variant}")) send_with_rerun(bot.send_message, call.message.chat.id, vote(variants), reply_markup=keyboard) else: voted = int(call.data.split("-")[1]) send_with_rerun(bot.answer_callback_query, call.id, f"You voted for {voted}") change(im[voted], V_SERVER_IP) j = call.message.json["reply_markup"] for find in re.findall(r"(\d+)(( - )?(\d+))?", call.message.json["text"]): if find[0] == str(voted): cur_val = find[-1] print(f"cur_v: '{cur_val}'") print(voted) variants[str(voted)] = 1 + (int(cur_val) if cur_val else 0) else: if int(find[0]) in list(range(1, RESULT_NUMBER)): variants[find[0]] = (find[-1] or 0) kb = j["inline_keyboard"] for button in kb: b = button[0] if call.data == b["callback_data"]: text = b["text"] cur_val = re.match("Variant (\d+): (\d+)", text).group(2) b["text"] = "Variant {}: {}".format(voted, int(cur_val) + 1) keyboard = telebot.types.InlineKeyboardMarkup(row_width=5) for button in kb: b = button[0] keyboard.add( InlineKeyboardButton(b["text"], callback_data=b["callback_data"])) send_with_rerun(bot.edit_message_text, vote(variants), call.message.chat.id, call.message.message_id, reply_markup=InlineKeyboardMarkup(keyboard)) send_with_rerun(bot.edit_message_reply_markup, call.message.chat.id, call.message.message_id, reply_markup=keyboard)
mk_b(f'Талон {mk_u(coupon_number)}\nотмечен неиспользованным'), reply_markup=start_menu_markup, parse_mode='HTML') else: bot.send_message( call.message.chat.id, mk_b( f'Невозможно отменить пометку,\nтак как талон {mk_u(coupon_number)}\nне использованный.' ), reply_markup=start_menu_markup, parse_mode='HTML') MENUS = { 'start_menu': [(InlineKeyboardButton('Загрузить талоны', callback_data='upload_coupons'), upload_coupons), (InlineKeyboardButton('Получить все доступные', callback_data='get_all_coupons'), get_all_coupons), (InlineKeyboardButton('Показать информацию по талонам', callback_data='get_summary'), get_summary_coupons_info), (InlineKeyboardButton('Получить талон', callback_data='get_coupon'), get_coupon)], 'coupon': [ (InlineKeyboardButton('Еще талон', callback_data='next_coupon'), get_coupon), ] } def get_buttons(menu_key: str) -> List[InlineKeyboardButton]:
def get_back_markup(stock): markup = InlineKeyboardMarkup(row_width=1) back = InlineKeyboardButton("◀️", callback_data=f"backMain_{stock}") markup.add(back) return markup
from export import excel, pdf with sqlite3.connect('Murojaat.sqlite3') as conn: cursor = conn.cursor() cursor.execute(""" CREATE TABLE IF NOT EXISTS "murojaatlar" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT, "user_id" INTEGER, "name" TEXT, "murojaat" TEXT) """) yangi_murojaat_inline = InlineKeyboardMarkup() yangi_murojaat_inline.add( InlineKeyboardButton("Yangi Murojaat yaratish", callback_data='new')) TOKEN = "1663406803:AAHRMKNA65Tn9iqzvQ6hL8EiOgI3lDvj_OA" bot = TeleBot(token=TOKEN) @bot.message_handler(commands=['start']) def start(msg): step_message = bot.send_message( msg.from_user.id, "Assalomu alaykum! \n\nIsm, familyangizni kiriting") bot.register_next_step_handler(step_message, anketa_name) def anketa_name(msg): name = msg.text
def reply(id, message): vip_id = file_reader("id/vip_id.txt", "\n") if vip_id.__contains__(id): keyboard = ReplyKeyboardMarkup(resize_keyboard=True) keyboard.row('Інформація', "Відкрити двері") keyboard.row("Подивитися паролі") keyboard.row("Добавити адміністратора") keyboard.max_row_keys = 4 print('Received:', message) now = datetime.datetime.now() if message.lower() == 'інформація': os.system('vcgencmd measure_temp > /home/pi/raspberry_bot/id/bot') with open('id/bot', 'r') as file: temp = file.read() bot.send_message(id, temp + 'Час: ' + str(now.hour) + ':' + str(now.minute) + ':' + str(now.second) + '\n' + 'Дата: ' + str(now.day) + '/' + str(now.month) + str('/') + str(now.year), reply_markup=keyboard) elif message.lower() == 'відкрити двері': bot.send_message(id, 'Відкрито...', reply_markup=keyboard) # GPIO.output(red_led_pin, True) sleep(2) # GPIO.output(red_led_pin, False) bot.send_message(id, 'Зачинено!', reply_markup=keyboard) elif message.lower() == 'подивитися паролі': passwords = file_reader("id/pass.txt", "#*#") bot.send_message(id, "\n".join(passwords)) elif message.lower() == "добавити адміністратора": user_id = file_reader("id/id.txt", "\n") s = "" num = 1 for i in user_id: if (str(i) == ""): break else: s += str(num) + ". " + str(i) + "\n" num += 1 j = 1 inline_keboard = InlineKeyboardMarkup() while j < num: data = "data" + str(j) but1 = InlineKeyboardButton(text=str(j), callback_data=data) inline_keboard.add(but1) j += 1 global count_users count_users = num - 1 bot.send_message(id, s, reply_markup=inline_keboard) else: keyboard = ReplyKeyboardMarkup(resize_keyboard=True) keyboard.row('Інформація', "Відкрити двері") print('Received:', message) now = datetime.datetime.now() if message.lower() == 'інформація': os.system('vcgencmd measure_temp > /home/pi/raspberry_bot/id/bot') with open('id/bot', 'r') as file: temp = file.read() bot.send_message(id, temp + 'Час: ' + str(now.hour) + ':' + str(now.minute) + ':' + str(now.second) + '\n' + 'Дата: ' + str(now.day) + '/' + str(now.month) + str('/') + str(now.year), reply_markup=keyboard) elif message.lower() == 'відкрити двері': bot.send_message(id, 'Відкрито...', reply_markup=keyboard) # GPIO.output(red_led_pin, True) sleep(2) # GPIO.output(red_led_pin, False) bot.send_message(id, 'Зачинено!', reply_markup=keyboard)
def __init__(self, name, text, next, **kwargs): self.name = name self.text = text self.next = next self.ikbutton = InlineKeyboardButton(text, **kwargs) self.callback = self.ikbutton.callback_data
def intro_inline(): markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add(InlineKeyboardButton('投稿', url='https://t.me/tooru_post_bot'), InlineKeyboardButton('加群', callback_data=f'cb_add_group')) return markup
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 call: inline_message = call.message buttons = [] markup = None events = util.database.get_event() if len(events) == 0: bot.reply_to(initial_message, text="Es gibt aktuell keine Termine.") return if kwargs.get('event_id') is None: text = "Wähle einen Termin aus:" markup = InlineKeyboardMarkup(row_width=1) buttons = list( InlineKeyboardButton(text=s.get_inline_str(), callback_data=self.command + json.dumps({'event_id': s.event_id})) for s in database.get_event()) markup.add(*tuple(buttons)) markup.add(InlineKeyboardButton("Beenden", callback_data="end")) if inline_message: msg = bot.edit_message_text(inline_message=inline_message, 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 event = util.database.get_event(event_id=kwargs['event_id']) text = util.functions.get_event_summary(**kwargs) if not kwargs.get('detail', False): # erinnerung if kwargs['event_id'] in [s.event_id for s in util.database.events_that_need_reminder()] and \ not self.store[user_id].get('sent_reminder', False): buttons.append( InlineKeyboardButton(text="Erinnern", callback_data=self.command + json.dumps({'remind': True}))) # detail if not kwargs.get('detail', False) and any( s['attendance'] >= 2 for s in util.database.get_event_attendance(event=event)): buttons.append( InlineKeyboardButton(text="Details", callback_data=self.command + json.dumps({'detail': True}))) # back button if kwargs.get('detail', False): dump = {'detail': False} else: dump = {'event_id': None} buttons.append( InlineKeyboardButton(text="Zurück", callback_data=self.command + json.dumps(dump))) markup = InlineKeyboardMarkup(row_width=2) markup.add(*tuple(buttons)) if kwargs.get('remind', False): util.functions.send_reminder_for(from_user_id=user_id, _id=kwargs['event_id']) self.store[user_id]['sent_reminder'] = True text = "Es wurden Erinnerungen versandt." dump = {'remind': False, 'detail': False} markup = InlineKeyboardMarkup(row_width=1) markup.add( InlineKeyboardButton(text="Zurück", callback_data=self.command + json.dumps(dump))) if markup is None and kwargs['detail']: markup = InlineKeyboardMarkup() markup.add( InlineKeyboardButton(text="Zurück", callback_data=self.command + json.dumps({'detail': False}))) if inline_message: msg = bot.edit_message_text(inline_message=inline_message, 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
def inl_protein_eigth_pos_one(self): markup = InlineKeyboardMarkup(row_width=2) first_b = InlineKeyboardButton("+", callback_data='ip8p1') second_b = InlineKeyboardButton("Далее", callback_data='ip8next2') markup.add(first_b, second_b) return markup
def myrolle(): markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add(InlineKeyboardButton(text="PM", callback_data="impm"), InlineKeyboardButton(text="DEV", callback_data="imdev")) return markup
def inl_gainer_first_pos_three(self): markup = InlineKeyboardMarkup(row_width=2) first_b = InlineKeyboardButton("+", callback_data='ig1p3') second_b = InlineKeyboardButton("Назад", callback_data='ig1next2') markup.add(first_b, second_b)
def reg_button(): markup = InlineKeyboardMarkup() markup.row_width = 1 markup.add( InlineKeyboardButton(text="Авторизация 🔑", callback_data="click_reg")) return markup
def inl_creatine_second_pos_one(self): markup = InlineKeyboardMarkup(row_width=2) first_b = InlineKeyboardButton("+", callback_data='ic2p1') markup.add(first_b) return markup
def bet_choyse(call, next_call_data, bet_size=''): if bet_size != '': bet_size += '_' if call.data.split('_')[1] == '1': bet_numbers_kb = InlineKeyboardMarkup(row_width=3) buttons_list = [] numbers = { '36': '🔴', '35': '⚫', '34': '🔴', '33': '⚫', '32': '🔴', '31': '⚫', '30': '🔴', '29': '⚫', '28': '⚫', '27': '🔴', '26': '⚫', '25': '🔴', '24': '⚫', '23': '🔴', '22': '⚫', '21': '🔴', '20': '⚫', '19': '🔴', '18': '🔴', '17': '⚫', '16': '🔴', '15': '⚫', '14': '🔴', '13': '⚫', '12': '🔴', '11': '⚫', '10': '⚫', '9': '🔴', '8': '⚫', '7': '🔴', '6': '⚫', '5': '🔴', '4': '⚫', '3': '🔴', '2': '⚫', '1': '🔴', '0': '🍏' } for bet_number, bet_color in numbers.items(): buttons_list.append( InlineKeyboardButton(text=bet_number + bet_color, callback_data=f'{next_call_data}_' + bet_size + str(bet_number))) bet_numbers_kb.add(*buttons_list) bot.send_message(call.message.chat.id, text='Выберите ваше число:', reply_markup=bet_numbers_kb) elif call.data.split('_')[1] == '2': bet_color_kb = InlineKeyboardMarkup(row_width=3) buttons_list = [] colors = ('🔴', '⚫') for bet_color in colors: buttons_list.append( InlineKeyboardButton(text=bet_color, callback_data=f'{next_call_data}_' + bet_size + bet_color)) bet_color_kb.add(*buttons_list) bot.send_message(call.message.chat.id, text='Выберите цвет ставки:', reply_markup=bet_color_kb) elif call.data.split('_')[1] == '3': bet_choice_kb = InlineKeyboardMarkup(row_width=2) buttons_list = [] bets = ('Четные', 'Нечетные') for bet in bets: buttons_list.append( InlineKeyboardButton(text=bet, callback_data=f'{next_call_data}_' + bet_size + bet)) bet_choice_kb.add(*buttons_list) bot.send_message(call.message.chat.id, text='Выберите тип ставки:', reply_markup=bet_choice_kb) elif call.data.split('_')[1] == '4': bet_choice_kb = InlineKeyboardMarkup(row_width=2) buttons_list = [] bets = ('1-18', '19-36') for bet in bets: buttons_list.append( InlineKeyboardButton(text=bet, callback_data=f'{next_call_data}_' + bet_size + bet)) bet_choice_kb.add(*buttons_list) bot.send_message(call.message.chat.id, text='Выберите тип ставки:', reply_markup=bet_choice_kb) elif call.data.split('_')[1] == '5': bet_choice_kb = InlineKeyboardMarkup(row_width=3) buttons_list = [] bets = ('1-12', '13-24', '25-36') for bet in bets: buttons_list.append( InlineKeyboardButton(text=bet, callback_data=f'{next_call_data}_' + bet_size + bet)) bet_choice_kb.add(*buttons_list) bot.send_message(call.message.chat.id, text='Выберите тип ставки:', reply_markup=bet_choice_kb)
def inl_amino_first_pos_four(self): markup = InlineKeyboardMarkup(row_width=2) first_b = InlineKeyboardButton("+", callback_data='ia1p4') second_b = InlineKeyboardButton("Назад", callback_data='ia1next3') markup.add(first_b, second_b) return markup
def gen_subsequent_markup(): markup = InlineKeyboardMarkup() markup.row_width = 2 markup.add(InlineKeyboardButton("Endelea", callback_data='endelea'), InlineKeyboardButton("Ondoka", callback_data='ondoka')) return markup