Пример #1
0
    def send(self, texts=None, callback_data=None, inline=None, url=None):
        if isinstance(callback_data, list):
            for k, v in callback_data:
                self.inline.add(InlineKeyboardButton(text=k, callback_data=v))
            return self.inline

        if inline:
            for text in texts:
                if text == 'Отправить!':
                    self.inline.add(
                        InlineKeyboardButton(
                            text=text,
                            callback_data=callback_data or text,
                            url='https://t.me/share/url?url=https%3A//telegram'
                            '.me/RS_Work_bot'))
                    return self.inline
                elif text == 'Оплатить':
                    self.inline.add(
                        InlineKeyboardButton(text=text,
                                             callback_data=callback_data
                                             or text,
                                             url=url))
                    return self.inline

                self.inline.add(
                    InlineKeyboardButton(text=text, callback_data=text))
            return self.inline

        for text in texts:
            if text == 'Мой счет':
                self.markup.row(KeyboardButton(text=text,
                                               request_contact=True))
            else:
                self.markup.row(KeyboardButton(text=text))
        return self.markup
Пример #2
0
def receive_change_weather(msg):
    telebot.keyboard = ReplyKeyboardMarkup()
    telebot.keyboard.add(KeyboardButton('Да'), KeyboardButton('Нет'))
    bot.send_message(msg.chat.id,
                     text="Хочешь, чтобы я сообщел тебе погоду каждый день?",
                     reply_markup=telebot.keyboard)
    telebot.action[msg.chat.id] = 'weather_reg'
Пример #3
0
def order_confirm(call):
    cart = Cart.get_or_create_cart(user_id=call.from_user.id)
    order_info = ''
    if len(cart.get_cart_products()) == 0:
        bot.send_message(call.from_user.id,
                         text='Вы еще не добавили товары в корзину',
                         reply_markup='')
    else:
        products = {
            str(cart_product.product.id): cart_product.product
            for cart_product in cart.get_cart_products()
        }
        sum_total = 0
        for id_pro, cart_pro in products.items():
            sum_total += cart.get_count_product(
                product=cart_pro.id) * cart_pro.get_price()
            header = f'ООО "Рога и Копыта"\n г.Киев'
            user_info = f'Покупатель: {cart.user.username}' if cart.user.phone_number is None else \
                f'Покупатель: {cart.user.username}\nТел. {cart.user.phone_number}'
            delimiter = '-' * 40
            order_info = f'{header}\n{delimiter}\nСумма заказа: {sum_total}\n' \
                         f'НДС 20%: {round(sum_total/6,2)}\n{delimiter}\n{user_info}'
        bot.send_message(call.from_user.id, order_info, reply_markup='')

        orders_menu = ReplyKeyboardMarkup(row_width=2)
        orders_menu.add(
            KeyboardButton(text='🗺️ Самовывоз - ближайший магазин',
                           request_location=True),
            KeyboardButton(text='☎ Адресная доставка', request_contact=True),
            KeyboardButton(text=START_KB['start']))
        bot.send_message(call.from_user.id,
                         text=f'Выберите способ получения заказа',
                         reply_markup=orders_menu)
Пример #4
0
def make_game_keyboard():
    keyboard = ReplyKeyboardMarkup(row_width=2)

    buttons = [KeyboardButton("Робот!"), KeyboardButton("Толстой!")]
    keyboard.add(*buttons)

    return keyboard
Пример #5
0
def contact():
    button_1=KeyboardButton(text.send_number,request_contact=True)
    button_2=KeyboardButton(text.to_main)
    kb=ReplyKeyboardMarkup(resize_keyboard=True)
    kb.row(button_1)
    kb.row(button_2)
    return kb
Пример #6
0
def checkout(message):
    user = Users.get_user(user_id=str(message.chat.id))
    txid = message.text
    if txid in ABORT_BUTTON.values():
        kb = ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)
        kb.add(*[KeyboardButton(text=START_KB[button][user.lang])
                 for button in START_KB.keys()])
        bot.send_message(message.chat.id, HELP_TEXT[user.lang], reply_markup=kb)
        PrePayments.cancel(str(message.chat.id))
        return
    elif (len(txid) == 64 and txid.isalnum()) or (len(txid) == 11 and txid.isdigit()):
        user_id, payment_type, amount, duration = PrePayments.read(user.chat_id)

        Payments.create(user_id=user_id,
                        payment_type=payment_type,
                        payment_end_date=datetime.datetime.now() + datetime.timedelta(days=duration * 30),
                        amount=amount,
                        tx_id=txid)
        PrePayments.cancel(str(message.chat.id))

        kb = ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)
        kb.add(*[KeyboardButton(text=START_KB[button][user.lang])
                 for button in START_KB.keys()])
        bot.send_message(message.chat.id, PAID_TEXT[user.lang], reply_markup=kb)
    else:
        kb = ReplyKeyboardMarkup(resize_keyboard=True)
        kb.add(KeyboardButton(ABORT_BUTTON[user.lang]))
        bot.send_message(message.chat.id, INVALID_TXID[user.lang] + ABORT_BUTTON[user.lang],
                         reply_markup=kb)
Пример #7
0
def admin_old():
    markup = ReplyKeyboardMarkup(row_width=2)
    markup.add(KeyboardButton("📆 Termine verwalten"),
               KeyboardButton("🏷 Umfragen verwalten"))
    markup.add(KeyboardButton("🔔 Erinnerung senden"),
               KeyboardButton("🔙 Hauptmenü"))
    return markup
Пример #8
0
def go_to_shopping_basket(user):
    text = f'{user.text("ваш никнейм")}: {user.username}\n' \
           f'{user.text("ваше золото")}: {user.gold}\n' \
           f'{user.text("ваши товары")}: {user.purchased_goods}\n' \
           f'{user.text("товаров в корзине")}: {len(user.shopping_basket)}\n' \
           f'{user.help_message}\n\n' \
           f'{user.text_with_symbols("корзина"):}\n'

    for num, products in enumerate(user.shopping_basket, start=1):
        text += f'{num}) - '
        for weapon, properties in products.items():
            text += f'{user.text(weapon)}\n' \
                    f'{user.text("золото")}: {properties["золото"]}\n' \
                    f'{user.text("количество")}: {properties["количество"]}\n' \
                    f'{user.text("урон")}: {properties["урон"]}\n' \
                    f'{user.text("количество ударов")}: {properties["количество ударов"]}\n' \
                    f'{user.text("кто может владеть")}: {properties["кто может владеть"]}\n' \
                    f'{"-" * 25}\n'

    keyboard = ReplyKeyboardMarkup(one_time_keyboard=True)
    keyboard.row(KeyboardButton(user.button_with_emoji('купить')))
    keyboard.row(KeyboardButton(user.button_with_emoji('удалить из корзины')))
    keyboard.row(KeyboardButton(user.button_with_emoji('назад')))
    user.resend_message(text, keyboard)
    bot.register_next_step_handler_by_chat_id(user.chat_id,
                                              go_to_shopping_basket_handler)
Пример #9
0
def main_menu(user):
    text = '---= Главное меню =---'
    keyboard = ReplyKeyboardMarkup(one_time_keyboard=True)
    keyboard.row(KeyboardButton('Играть'), KeyboardButton('Магазин'))
    keyboard.row(KeyboardButton('Настройки аккаунта'))
    user.resend_message(text, keyboard)
    bot.register_next_step_handler_by_chat_id(user.chat_id, main_handler)
Пример #10
0
def dist_conf():
    mp = ReplyKeyboardMarkup(one_time_keyboard=True, row_width=2)
    mp.add(
        KeyboardButton("Да"),
        KeyboardButton("Нет"),
    )
    return mp
Пример #11
0
def menu_language(user):
    text = user.text_with_symbols("меню выбора языка")
    keyboard = ReplyKeyboardMarkup(one_time_keyboard=True)
    keyboard.row(KeyboardButton('RU'), KeyboardButton('EN'))
    user.resend_message(text, keyboard)
    bot.register_next_step_handler_by_chat_id(user.chat_id,
                                              menu_language_handler)
Пример #12
0
def cont():
    phone=KeyboardButton("📞 Отправить контакт",request_contact=True)
    back=KeyboardButton('◀️ Назад')
    kb=ReplyKeyboardMarkup(resize_keyboard=True)
    kb.row(phone)
    kb.row(back)
    return kb
Пример #13
0
 def build(cls):
     keyboard = ReplyKeyboardMarkup(True, False)
     keyboard.add(KeyboardButton(cls.find))
     keyboard.add(KeyboardButton(cls.active))
     keyboard.add(KeyboardButton(cls.history))
     keyboard.add(KeyboardButton(cls.info))
     return keyboard
Пример #14
0
def kv():
    kb=ReplyKeyboardMarkup(resize_keyboard=True)
    b1=KeyboardButton("Зарегистрироваться.")
    b2=KeyboardButton('◀️ Назад.')
    kb.row(b1)
    kb.row(b2)
    return kb
Пример #15
0
 def mainMenu(self, user: EasyDBEntry):
     return ReplyKeyboardMarkup().row(
         #KeyboardButton('Posts List'),
         KeyboardButton('Create Post'))
     if user.get('admin'):
         markup.row(KeyboardButton('Admin'))
     return markup
Пример #16
0
 def team_menu(self):
     menu = ReplyKeyboardMarkup(resize_keyboard=True)
     menu.add(KeyboardButton('/connect'),
              KeyboardButton('/points'),
              KeyboardButton('/me'),
              KeyboardButton('/logout'))
     return menu
Пример #17
0
 def common_user_menu(self):
     menu = ReplyKeyboardMarkup(resize_keyboard=True)
     menu.add(KeyboardButton(f'/me'),
              KeyboardButton(f'/team'),
              KeyboardButton(f'/teams'),
              KeyboardButton(f'/points'))
     return menu
Пример #18
0
def fin2():
    kb=ReplyKeyboardMarkup(resize_keyboard=True)
    b1=KeyboardButton("🎥 Посмотреть")
    b2=KeyboardButton("📲 Главное меню")
    kb.row(b1)
    kb.row(b2)
    return kb
Пример #19
0
 def main_menu(self):
     self.reset_keyboard()
     self.keyboard.add(KeyboardButton('Автобусы'))
     self.keyboard.add(KeyboardButton('Славянки'))
     self.keyboard.add(KeyboardButton('Электрички'))
     self.keyboard.add(KeyboardButton('Файл с расписанием'))
     return self.keyboard
Пример #20
0
def loc():
    locat = KeyboardButton("📌Отправить местоположение", request_location=True)
    back = KeyboardButton('◀️ Назад')
    kb = ReplyKeyboardMarkup(resize_keyboard=True)
    kb.row(locat)
    kb.row(back)
    return kb
Пример #21
0
def Hudud():
    reply_markup = ReplyKeyboardMarkup(row_width=2, resize_keyboard=2)
    reply_markup.add(*[
        KeyboardButton(text='Toshkent'),
        KeyboardButton(text='Samarqand'),
        KeyboardButton(text='Qarshi'),
        KeyboardButton(text='Andijon')
    ])
Пример #22
0
 def governor_menu(self, pid):
     menu = ReplyKeyboardMarkup(resize_keyboard=True)
     menu.add(KeyboardButton(f'/me'),
              KeyboardButton(f'/teams'),
              KeyboardButton(f'/connected {pid}'),
              KeyboardButton(f'/prices {pid}'),
              KeyboardButton(f'/logout'))
     return menu
Пример #23
0
def master():
    markup = ReplyKeyboardMarkup(row_width=2)
    markup.row(KeyboardButton("📝 Show Table"))
    # markup.add(KeyboardButton("📝 Show Table"), KeyboardButton("SQL Command"))
    markup.add(KeyboardButton("Manage Members"),
               KeyboardButton("Remove Event")),
    markup.row(KeyboardButton("Remove Survey"), KeyboardButton("🔙 Main Menu"))
    return markup
Пример #24
0
def symbols_in_the_title(user):
    text = f'{user.text_with_symbols("знаки в оглавлении")}'
    keyboard = ReplyKeyboardMarkup(one_time_keyboard=True)
    keyboard.row(KeyboardButton(user.button_with_emoji('знаки в начале')),
                 KeyboardButton(user.button_with_emoji('знаки в конце')))
    user.resend_message(text, keyboard)
    bot.register_next_step_handler_by_chat_id(user.chat_id,
                                              symbols_in_the_title_handler)
Пример #25
0
def address_list():
    markup = ReplyKeyboardMarkup(one_time_keyboard=True)
    markup.add(
        KeyboardButton("Определить местоположение", request_location=True))
    markup.add(KeyboardButton("Отправить номер телефона",
                              request_contact=True))
    #markup.add(KeyboardButton("Ввести адрес вручную", callback_data="manual_address"))
    return markup
Пример #26
0
def delete_list_mp(chat_id):
    lists = List.select().where(List.owner == chat_id)

    mp = ReplyKeyboardMarkup(row_width=1)
    mp.add(*(KeyboardButton("❌ 📝 " + list_.name) for list_ in lists))
    mp.add(KeyboardButton(_("🔙 Back")))

    return mp
Пример #27
0
def sel_sost():
    kb=ReplyKeyboardMarkup(resize_keyboard=True)
    b=KeyboardButton("С ремонтом")
    b1=KeyboardButton("Без ремонта")
    bb=KeyboardButton("⬅️ Назад")
    kb.row(b,b1)
    kb.row(bb)
    return kb
Пример #28
0
def button_settings(user):
    text = user.text_with_symbols("эмоджи на кнопках")
    keyboard = ReplyKeyboardMarkup(one_time_keyboard=True)
    keyboard.row(KeyboardButton(user.text('вкл')),
                 KeyboardButton(user.text('выкл')))
    user.resend_message(text, keyboard)
    bot.register_next_step_handler_by_chat_id(user.chat_id,
                                              button_settings_handler)
Пример #29
0
 def connected_team_menu(self, pid):
     menu = ReplyKeyboardMarkup(resize_keyboard=True)
     menu.add(KeyboardButton(f'/prices {pid}'),
              KeyboardButton('/trade'),
              KeyboardButton(f'/connected {pid}'),
              KeyboardButton(f'/disconnect'),
              KeyboardButton(f'/me'))
     return menu
Пример #30
0
def manage_events():
    markup = ReplyKeyboardMarkup(row_width=2)
    markup.add(KeyboardButton("🆕 Neuer Termin"),
               KeyboardButton("🔄 Termin bearbeiten"))
    markup.add(KeyboardButton("ℹ️ Terminzusammenfassung"),
               KeyboardButton("⏹ Termin absagen"))
    markup.row(KeyboardButton("🔙 Admin Menü"))
    return markup