Пример #1
0
def check_data(message):
    global data
    try:
        n, p, e = message.text.split('\n')
        data[message.chat.id].append(n)
        data[message.chat.id].append(p)
        data[message.chat.id].append(e)
    except Exception:
        return False
    else:
        return True


#КЛАВИАТУРЫ
empty_k = ReplyKeyboardMarkup(resize_keyboard=True)
empty_k.add(KeyboardButton('⬅️ Вернуться назад'))

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')
Пример #2
0
# Available status
NONE = 0
TEXT = 1  # Set task's text
DATE = 2  # Set task's date
WDATE = 3  # This week dates
CDATE = 4  # Custom date set
HTIME = 5  # Set hour
MTIME = 6  # Set minute
REP = 7  # Choose if to repeat
REPN = 8  # Select number of repeats
TGAP = 9  # Select time gap for repeats
FIN = 10  # Confirm task and finish

# Date choice keyboard
thisweek = KeyboardButton("This week")
custom = KeyboardButton("Custom")
keyb = ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)
keyb.add(thisweek, custom)

# Weekdays keyb
week_keyb = ReplyKeyboardMarkup(resize_keyboard=True)
for i in range(8):
    week_keyb.add(
        KeyboardButton(
            strftime("%A, %d.%m.%y", localtime(time() + 3600 * 24 * i))))

# Hour keyboard
hour_keyb = ReplyKeyboardMarkup(resize_keyboard=True)
row = []
for i in range(24):
Пример #3
0
def sel_distr():
    kb=ReplyKeyboardMarkup(resize_keyboard=True)
    b1=KeyboardButton("Мирабадский")
    b2=KeyboardButton("Мирзо Улугбекский")
    b3=KeyboardButton("Олмазарский")
    b4=KeyboardButton("Сергелийский")
    b5=KeyboardButton("Учтепинский")
    b6=KeyboardButton("Чиланзарский")
    b7=KeyboardButton("Шайхантохурский")
    b8=KeyboardButton("Юнусабадский")
    b9=KeyboardButton("Яшнабадский")
    b10=KeyboardButton("Яккасарайский")
    b11=KeyboardButton("⬅️ Назад")
    kb.row(b1,b2)
    kb.row(b3,b4)
    kb.row(b5,b6)
    kb.row(b7,b8)
    kb.row(b9,b10)
    kb.row(b11)
    return kb
Пример #4
0
    def set_btn(self, name):
        """
        Создает и возвращает кнопку по входным параметрам
        """

        return KeyboardButton(name)
Пример #5
0
    def __init__(self):

        self.remove = ReplyKeyboardRemove(selective=False)

        self.onlyBack = ReplyKeyboardMarkup().row(KeyboardButton('Back'))
Пример #6
0
def tags_markup(message):
    markup = ReplyKeyboardMarkup(one_time_keyboard=True, row_width=2)
    post = post_dict[message.chat.id]
    word = post.words[0]
    if word.partOfSpeech == "Idiom":
        markup.add(KeyboardButton('#Idioms #B1'),
                   KeyboardButton('#Idioms #B2'),
                   KeyboardButton('#Idioms #C1'),
                   KeyboardButton('#Idioms #C2'))
    elif word.partOfSpeech == "phrasal verb":
        markup.add(KeyboardButton('#PhrasalVerb #B1'),
                   KeyboardButton('#PhrasalVerb #B2'),
                   KeyboardButton('#PhrasalVerb #C1'),
                   KeyboardButton('#PhrasalVerb #C2'))
    else:
        markup.add(KeyboardButton('#Words #B1'), KeyboardButton('#Words #B2'),
                   KeyboardButton('#Words #C1'), KeyboardButton('#Words #C2'))
    return markup
Пример #7
0
 def build(cls):
     keyboard = ReplyKeyboardMarkup(True, False)
     keyboard.add(KeyboardButton(cls.good), KeyboardButton(cls.next))
     keyboard.add(KeyboardButton(cls.back))
     return keyboard
Пример #8
0
 def order_kb(self):
     kb = ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)
     kb.add(*[KeyboardButton(text=text) for text in ORDER_KB.values()])
     return kb
Пример #9
0
 def go_to_category(self):
     kb = ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)
     kb.add(*[KeyboardButton(text=text) for text in CATEGORY_KB.values()])
     return kb
Пример #10
0
 def settings_kb(self):
     kb = ReplyKeyboardMarkup(resize_keyboard=True,
                              row_width=2)  # , one_time_keyboard=True
     kb.add(*[KeyboardButton(text=text) for text in SETTINGS_KB.values()])
     return kb
Пример #11
0
 def home_cart_kb(self):
     kb = ReplyKeyboardMarkup(resize_keyboard=True,
                              row_width=2)  # , one_time_keyboard=True
     kb.add(*[KeyboardButton(text=text) for text in HOME_CART_KB.values()])
     return kb
Пример #12
0
def create_keyboard(*rows):
    kb = ReplyKeyboardMarkup()
    for row in rows:
        kb.row(*[KeyboardButton(a) for a in row])
    return kb
Пример #13
0
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)
Пример #14
0
def skip_markup():
    markup = ReplyKeyboardMarkup(one_time_keyboard=True)
    markup.add(KeyboardButton('@DextyOficialBot'))
    return markup
Пример #15
0
_dish_keyboard_ru = ReplyKeyboardMarkup(resize_keyboard=True, row_width=3)
_dish_keyboard_ru.add(*[str(x) for x in list(range(1, 10))])
_dish_keyboard_ru.add(get_string('catalog.cart'), get_string('go_back'))
_keyboards_ru['catalog.dish_keyboard'] = _dish_keyboard_ru

_shipping_methods_keyboard_ru = ReplyKeyboardMarkup(resize_keyboard=True,
                                                    row_width=2)
_shipping_methods_keyboard_ru.add(
    from_order_shipping_method(Order.ShippingMethods.DELIVERY, 'ru'),
    from_order_shipping_method(Order.ShippingMethods.PICK_UP, 'ru'),
    get_string('go_to_menu'))
_keyboards_ru['order.shipping_methods'] = _shipping_methods_keyboard_ru

_order_location_keyboard_ru = ReplyKeyboardMarkup(resize_keyboard=True,
                                                  row_width=2)
location_button = KeyboardButton(get_string('my_location'),
                                 request_location=True)
_order_location_keyboard_ru.add(location_button)
_order_location_keyboard_ru.add(get_string('go_back'))
_keyboards_ru['order.address'] = _order_location_keyboard_ru

_order_payment_keyboard_ru = ReplyKeyboardMarkup(resize_keyboard=True,
                                                 row_width=2)
_order_payment_keyboard_ru.add(
    from_order_payment_method(Order.PaymentMethods.PAYME, 'ru'),
    from_order_payment_method(Order.PaymentMethods.CLICK, 'ru'),
    from_order_payment_method(Order.PaymentMethods.CASH, 'ru'))
_order_payment_keyboard_ru.add(get_string('go_back'), get_string('go_to_menu'))
_keyboards_ru['order.payment'] = _order_payment_keyboard_ru

_order_confirmation_keyboard_ru = ReplyKeyboardMarkup(resize_keyboard=True,
                                                      row_width=1)
Пример #16
0
from telebot.types import ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardMarkup, InlineKeyboardButton

from models import *

from app import kassa

back_button = KeyboardButton('🔙Назад')

start_button1 = KeyboardButton('💎 Подписка')
start_button2 = KeyboardButton('🍬 Бонусная программа')
start_button3 = KeyboardButton('🆘 Тех.Поддержка')
start_button4 = KeyboardButton('📈 Статистика')
start_button5 = KeyboardButton('🤖 О боте ')
start_button6 = KeyboardButton('💡Совет')
start_button7 = KeyboardButton('⚡️ Актуальная ставка')
start_button8 = KeyboardButton('📱 Калькулятор банка')

start_keyboard = ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)
start_keyboard.add(*[
    start_button1, start_button4, start_button2, start_button5, start_button3,
    start_button6
])
start_keyboard.row(start_button8)

paymented_start_keyboard = ReplyKeyboardMarkup(resize_keyboard=True,
                                               row_width=2)
paymented_start_keyboard.row(start_button7)
paymented_start_keyboard.add(*[
    start_button1, start_button4, start_button2, start_button5, start_button3,
    start_button6
])
Пример #17
0
def skip_markup():
    markup = ReplyKeyboardMarkup(one_time_keyboard=True)
    markup.add(KeyboardButton('Skip'))
    return markup
Пример #18
0
def call_on_admin_suggestion(call: CallbackQuery, session=None):
    """
    Обработка действий нажатия на кнопки предложки у админа

    :param call:
    :param session:
    """
    callback_data = json.loads(call.data)
    callback_action = callback_data['a']
    if callback_action == ACTION_DECLINE:
        callback_suggestion_id = callback_data['s']
        suggestion = repo.get_suggestion(callback_suggestion_id)
        if suggestion is None:
            raise Exception("Suggestion not found")
        if not suggestion.is_new():
            # Для это действия предложка должна быть только что опубликованной
            bot.answer_callback_query(
                call.id, t("bot.admin.error.decision.wrong_state"))
            return
        # Обновляем сообщение предложки и удаляем кнопки
        suggestion.decision = DECISION_DECLINE
        rerender_suggestion(suggestion)
        # Отображаем плашку с отменой
        answer_callback_decision(call, DECISION_DECLINE)
        # После вынесения решения удаляем предложку из базы
        session.delete(suggestion)
        return
    elif callback_action == ACTION_ACCEPT:
        callback_suggestion_id = callback_data['s']
        suggestion = repo.get_suggestion(callback_suggestion_id)
        if suggestion is None:
            raise Exception("Suggestion not found")
        if not suggestion.is_new():
            # Для это действия предложка должна быть только что опубликованной
            return
        # Отображаем плашку с ответом
        answer_callback_decision(call, DECISION_ACCEPT)
        # Публикуем пост в канале
        channel_post = publish_post(suggestion.file_id)
        # Обновляем предложку
        suggestion.decision = DECISION_ACCEPT
        suggestion.channel_post_id = channel_post.message_id
        # Обновляем сообщение предложки и удаляем кнопки
        rerender_suggestion(suggestion)
        # Отправляем пользователю информацию, что пост одобрен
        notify_user_about_publish(suggestion)
        # После вынесения решения удаляем предложку из базы
        session.delete(suggestion)
    elif callback_action == ACTION_ACCEPT_WITH_POLL:
        callback_suggestion_id = callback_data['s']
        suggestion = repo.get_suggestion(callback_suggestion_id)
        if suggestion is None:
            raise Exception("Suggestion not found")
        # Сохраняем состояние чата админа с ботом
        admin_state = repo.get_admin_state()
        if admin_state is not None and admin_state[
                'state'] == AdminState.STATE_WAIT_BUTTONS:
            # Если другое сообщение уже ожидает эмодзи от пользователя, то возобновляем
            # кнопки в том сообщении
            other_suggestion = repo.get_suggestion(
                admin_state['data']['suggestion_id'])
            if other_suggestion is None:
                raise Exception("Suggestion not found")
            reset_suggestion(other_suggestion)
            admin_id = get_admin_id()
            # Отправляем сообщение о том, что предыдущая операция отменена + удаляем кнопки если есть
            # TODO попробовать совместить с /cancel
            bot.send_message(
                admin_id,
                t("app.bot.admin.previous_action_canceled"),
                reply_to_message_id=other_suggestion.admin_message_id,
                reply_markup=ReplyKeyboardRemove())
        repo.set_admin_state(AdminState.STATE_WAIT_BUTTONS,
                             {"suggestion_id": suggestion.id})
        # Показываем плашку о том, что решение принято
        answer_callback_decision(call, DECISION_ACCEPT_WITH_POLL)
        # Удаляем кнопки
        rerender_suggestion(suggestion)
        # Отправляем сообщение о том, что ждем эмодзи
        suggested_emoji_set_markup = ReplyKeyboardMarkup()
        # К сообщению прикрепляем последние 5 использованных уникальных наборов эмодзи
        previous_emoji_sets = repo.get_previous_emoji_sets()
        for emoji_set in previous_emoji_sets:
            suggested_emoji_set_markup.add(KeyboardButton(emoji_set))
        bot.send_message(call.message.chat.id,
                         t("app.bot.admin.wait_buttons"),
                         reply_to_message_id=suggestion.admin_message_id,
                         reply_markup=suggested_emoji_set_markup
                         if len(previous_emoji_sets) > 0 else None)
        # Устанавливаем состояние предложки в состояние ожидания
        suggestion.state = Suggestion.STATE_WAIT
Пример #19
0
from telebot.types import ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardMarkup, InlineKeyboardButton


# Main_keyboard---------------------------------------------------------------------------------------------------------
# Commands
MAIN_COMMAND_INFO = 'информация'
MAIN_COMMAND_PDT = 'pdt response'
MAIN_COMMAND_PROMOTION = 'заработок и продвижение'
# Init_keyboard
MAIN_MARKUP = ReplyKeyboardMarkup(resize_keyboard=True)
# Init_buttons
MAIN_BUTTON_INFO = KeyboardButton(MAIN_COMMAND_INFO)
MAIN_BUTTON_PDT_RESPONSE = KeyboardButton(MAIN_COMMAND_PDT)
MAIN_BUTTON_PROMOTION = KeyboardButton(MAIN_COMMAND_PROMOTION)
# Add_buttons
MAIN_MARKUP.add(MAIN_BUTTON_INFO, MAIN_BUTTON_PDT_RESPONSE)
MAIN_MARKUP.add(MAIN_BUTTON_PROMOTION)
# ----------------------------------------------------------------------------------------------------------------------


# Inline_keyboards------------------------------------------------------------------------------------------------------
# Inline_main_keyboard--------------------------------------------------------------------------------------------------
# Commands
INLINE_COMMAND_MANAGE_EVENTS = 'Manage Events'
INLINE_COMMAND_MANAGE_USERS = 'Manage Users'
# Init_keyboard
INLINE_MAIN_MARKUP = InlineKeyboardMarkup(row_width=1)
# Init_buttons
INLINE_BUTTON_MANAGE_EVENTS = InlineKeyboardButton(INLINE_COMMAND_MANAGE_EVENTS,
                                                   callback_data=INLINE_COMMAND_MANAGE_EVENTS)
INLINE_BUTTON_MANAGE_USERS = InlineKeyboardButton(INLINE_COMMAND_MANAGE_USERS,
Пример #20
0
    def genAllResponses(self):
        # db=Dbhash()
        # db=DbRedis()
        db = DbUserData()
        dbDriver = DbDriverData()
        dbOrder = DbOrder()

        initDrPs = {}
        initDrPs['driver'] = 'pengemudi'
        initDrPs['passenger'] = 'penumpang'
        initDrPs['feedback'] = 'feedback'
        markup = ReplyKeyboardMarkup(row_width=2)
        itembtn1 = KeyboardButton(initDrPs['driver'])
        itembtn2 = KeyboardButton(initDrPs['passenger'])
        itembtn3 = KeyboardButton(initDrPs['feedback'])
        markup.add(itembtn1, itembtn2, itembtn3)
        self.respInitDrPs = ButtonResponse()
        self.respInitDrPs.addText(respL.pilihSiapa())
        self.respInitDrPs.addReplyKeyboard(markup)

        # FOR DRIVER MENU --------------------
        initDriver = {}
        initDriver['aktifkan'] = 'Aktifkan Mangkal'
        initDriver['mod'] = 'Ubah Info'
        markup = ReplyKeyboardMarkup(row_width=1)
        itembtn1 = KeyboardButton(initDriver['aktifkan'])
        itembtn2 = KeyboardButton(initDriver['mod'])
        markup.add(itembtn1, itembtn2)
        respInitDriver = ButtonResponse()
        respInitDriver.addReplyKeyboard(markup)

        modD = {}
        modD['no'] = 'No hp'
        # modD['noMotor'] = 'No plat'
        modD['nama'] = 'Nama'
        modD['desc'] = 'Deskripsi'
        modD['ojek'] = 'Kendaraan'
        modDriver = ButtonResponse()
        markup = ReplyKeyboardMarkup(row_width=2)
        itembtn1 = KeyboardButton(modD['no'])
        # itembtn2=KeyboardButton(modD['noMotor'])
        itembtn3 = KeyboardButton(modD['nama'])
        itembtn4 = KeyboardButton(modD['desc'])
        itembtn5 = KeyboardButton(modD['ojek'])
        markup.add(itembtn1, itembtn3, itembtn4, itembtn5)
        modDriver.addText(respL.ubahInfo())
        modDriver.addReplyKeyboard(markup)

        dvKey = {}
        dvKey['checkin'] = 'Perbarui Mangkal'
        dvKey['selese'] = 'Tutup'
        dvResp = ButtonResponse()
        markup = ReplyKeyboardMarkup(row_width=1)
        item1 = KeyboardButton(dvKey['checkin'], request_location=True)
        item2 = KeyboardButton(dvKey['selese'])
        markup.add(item1, item2)
        dvResp.addText(respL.driverMangkal())
        dvResp.addReplyKeyboard(markup)

        noDriver = ButtonResponse()
        markup = ReplyKeyboardMarkup(row_width=1)
        item = KeyboardButton('Kirim no', request_contact=True)
        markup.add(item)
        noDriver.addReplyKeyboard(markup)
        noDriver.addText(respL.ubahHp())

        namaDriver = TextResponse()
        namaDriver.addText(respL.ubahNama())
        markup = ReplyKeyboardRemove(selective=False)
        namaDriver.addReplyMarkup(markup)

        descMotor = TextResponse()
        descMotor.addText(respL.driverDeskripsi())
        markup = ReplyKeyboardRemove(selective=False)
        descMotor.addReplyMarkup(markup)

        ojkDriver = ButtonResponse()
        ojkDriver.addText(respL.userKendaraan())
        markup = ReplyKeyboardMarkup(row_width=2)
        tipeD = {}
        tipeD['motor'] = 'motor'
        tipeD['mobil'] = 'mobil'
        tipeD['bentor'] = 'bentor'
        tipeD['delman'] = 'delman'
        # tipeD['becak']='becak'
        tipeD['kapal'] = 'kapal'
        tipeD['bajaj'] = 'bajaj'
        item1 = KeyboardButton('motor')
        item2 = KeyboardButton('mobil')
        item3 = KeyboardButton('bentor')
        item4 = KeyboardButton('delman')
        # item5=KeyboardButton('becak')
        item5 = KeyboardButton('kapal')
        item6 = KeyboardButton('bajaj')
        markup.add(item1, item2, item3, item4, item5, item6)
        ojkDriver.addReplyKeyboard(markup)

        kembaliDriver = ButtonResponse()
        kembaliDriver.addText(respL.driverGetOrder())
        markup = ReplyKeyboardMarkup(row_width=1)
        typeKembali = {}
        typeKembali['kembali'] = 'Kembali'
        item1 = KeyboardButton(typeKembali['kembali'])
        markup.add(item1)
        kembaliDriver.addReplyKeyboard(markup)

        feedbackResponse = TextResponse()
        feedbackResponse.addText(respL.feedback())
        markup = ReplyKeyboardRemove(selective=False)
        feedbackResponse.addReplyMarkup(markup)

        initDriverSt = OptionButtonState()
        initDriverSt.setResponse(respInitDriver)
        initDriverSt.name = 'init-state-driver'
        handler = InitDriverHandler()
        handler.setDbCon(dbDriver)
        initDriverSt.setPostDataHandler(handler)

        dvReadySt = LocationMessageState()
        dvReadySt.name = 'dvready-state-driver'
        dvReadySt.setResponse(dvResp)
        handler = DReadyHandler()
        handler.setDbCon(dbDriver)
        dvReadySt.setPostDataHandler(handler)
        print(handler, 'POST')
        handler = DOutHandler()
        handler.setDbCon(dbDriver)
        dvReadySt.setPreDataHandler(handler)
        print(handler, 'PRE')

        modDriverSt = OptionButtonState()
        modDriverSt.setResponse(modDriver)
        modDriverSt.name = 'mod-state-driver'

        noDriverSt = ShareContactState()
        noDriverSt.setResponse(noDriver)
        noDriverSt.name = 'no-state-driver'
        handler = DriverPhone()
        handler.setDbCon(dbDriver)
        noDriverSt.setPreDataHandler(handler)

        namaDriverSt = MessageState()
        namaDriverSt.setResponse(namaDriver)
        namaDriverSt.name = 'nama-state-driver'
        handler = DriverName()
        handler.setDbCon(dbDriver)
        namaDriverSt.setPreDataHandler(handler)

        descMotorSt = MessageState()
        descMotorSt.setResponse(descMotor)
        descMotorSt.name = 'desc-state-driver'
        handler = DriverDesc()
        handler.setDbCon(dbDriver)
        descMotorSt.setPreDataHandler(handler)

        ojkDriverSt = OptionButtonState()
        ojkDriverSt.setResponse(ojkDriver)
        ojkDriverSt.name = 'ojek-state-driver'
        handler = DriverOjek()
        handler.setDbCon(dbDriver)
        ojkDriverSt.setPreDataHandler(handler)

        kembaliDriverSt = OptionButtonState()
        kembaliDriverSt.setResponse(kembaliDriver)
        kembaliDriverSt.name = 'kembali-state-driver'

        feedbackResponseSt = MessageState()
        feedbackResponseSt.setResponse(feedbackResponse)
        feedbackResponseSt.name = 'feedback-state'
        handler = AppendF()
        feedbackResponseSt.setPreDataHandler(handler)
        # END DRIVER MENU --------------------

        init = {}
        init['find'] = 'Cari Ojek'
        init['mod'] = 'Ubah Info'
        markup = ReplyKeyboardMarkup(row_width=1)
        itembtn1 = KeyboardButton(init['find'])
        itembtn2 = KeyboardButton(init['mod'])
        markup.add(itembtn1, itembtn2)
        self.respInit = ButtonResponse()
        reply_keyboard = [[init['find']], [init['mod']]]
        self.respInit.addReplyKeyboard(markup)

        opOrd = {}
        opOrd['selese'] = 'Tutup'
        ordStr = ButtonResponse()
        markup = ReplyKeyboardMarkup(row_width=1)
        item = KeyboardButton(opOrd['selese'])
        markup.add(item)
        ordStr.addText(respL.tungguOrder())
        ordStr.addReplyKeyboard(markup)

        mod = {}
        mod['no'] = 'No hp'
        mod['dari'] = 'Dari'
        mod['ke'] = 'Ke'
        mod['harga'] = 'Harga'
        mod['ojek'] = 'Kendaraan'
        mod['nama'] = 'Nama'
        self.respMod = ButtonResponse()
        markup = ReplyKeyboardMarkup(row_width=2)
        itembtn1 = KeyboardButton(mod['no'])
        itembtn2 = KeyboardButton(mod['dari'])
        itembtn3 = KeyboardButton(mod['ke'])
        itembtn4 = KeyboardButton(mod['harga'])
        itembtn5 = KeyboardButton(mod['ojek'])
        itembtn6 = KeyboardButton(mod['nama'])
        markup.add(itembtn1, itembtn2, itembtn3, itembtn4, itembtn5, itembtn6)
        self.respMod.addText(respL.ubahInfo())
        self.respMod.addReplyKeyboard(markup)

        self.respModNo = ButtonResponse()
        markup = ReplyKeyboardMarkup(row_width=1)
        item = KeyboardButton('Kirim no', request_contact=True)
        markup.add(item)
        self.respModNo.addReplyKeyboard(markup)
        self.respModNo.addText(respL.ubahHp())

        self.respModLocation = ButtonResponse()
        markup = ReplyKeyboardMarkup(row_width=1)
        item = KeyboardButton('Kirim lokasi', request_location=True)
        markup.add(item)

        textDari = respL.lokasiDari()
        self.respModLocation.addText(textDari)
        self.respModLocation.addReplyKeyboard(markup)
        #
        keyKirim = {}
        keyKirim['yes'] = 'kirim'
        #
        self.repsModKe = TextResponse()
        # textKe='Beberapa cara mengirim lokasi:\n'
        # textKe+='-> Untuk men-set lokasi baru tekan tombol attachment('+emo.paperclip+') dibawah dan pilih location. Lokasi bisa dipilih ' \
        #             'di map atau di-search\n'
        # textKe+='-> Gunakan foursquare untuk realtime location, ketik "@foursquare alamat-anda", tunggu sampe menu keluar kemudian pilih'
        textKe = respL.lokasiKe()
        self.repsModKe.addText(textKe)
        markup = ReplyKeyboardRemove()
        markup.selective = False
        self.repsModKe.addReplyMarkup(markup)

        namaPassenger = TextResponse()
        namaPassenger.addText(respL.ubahNama())
        markup = ReplyKeyboardRemove(selective=False)
        namaPassenger.addReplyMarkup(markup)
        #
        self.respHarga = TextResponse()
        self.respHarga.addText(respL.userHarga())
        markup = ReplyKeyboardRemove(selective=False)
        self.respHarga.addReplyMarkup(markup)
        #
        self.respOjk = ButtonResponse()
        self.respOjk.addText(respL.userKendaraan())
        markup = ReplyKeyboardMarkup(row_width=2)
        tipe = {}
        tipe['motor'] = 'motor'
        tipe['mobil'] = 'mobil'
        tipe['bentor'] = 'bentor'
        tipe['delman'] = 'delman'
        tipe['kapal'] = 'kapal'
        tipe['bajaj'] = 'bajaj'
        item1 = KeyboardButton('motor')
        item2 = KeyboardButton('mobil')
        item3 = KeyboardButton('bentor')
        item4 = KeyboardButton('delman')
        item5 = KeyboardButton('kapal')
        item6 = KeyboardButton('bajaj')
        markup.add(item1, item2, item3, item4, item5, item6)
        self.respOjk.addReplyKeyboard(markup)

        #
        replyBool = {}
        replyBool['y'] = 'yes'
        replyBool['n'] = 'no'
        markup = ReplyKeyboardMarkup(row_width=2)
        markup.add(replyBool['y'], replyBool['n'])
        reply_keyboard = markup
        # reply_keyboard = [[replyBool['y'], replyBool['n']]]
        #
        self.confNo = MultiResponse()
        confNoTemp = PhoneNoResponse()
        self.confNo.addResponse(confNoTemp)
        confNoTemp = ButtonResponse()
        confNoTemp.addText('Apakah no di atas benar')
        confNoTemp.addReplyKeyboard(reply_keyboard)
        self.confNo.addResponse(confNoTemp)
        #
        self.confLoc = MultiResponse()
        confLocTemp = LocationResponse()
        self.confLoc.addResponse(confLocTemp)
        confLocTemp = TextResponse()
        confLocTemp.addText('Lokasi kamu')
        self.confLoc.addResponse(confLocTemp)
        confLocTemp = ButtonResponse()
        confLocTemp.addText("Apakah lokasi di atas benar")
        confLocTemp.addReplyKeyboard(reply_keyboard)
        self.confLoc.addResponse(confLocTemp)
        #
        #
        self.repsModKeConf = MultiResponse()
        confLocKeTemp = LocationResponse()
        self.repsModKeConf.addResponse(confLocKeTemp)
        confLocKeTemp = TextResponse()
        confLocKeTemp.addText('Lokasi tujuan')
        self.repsModKeConf.addResponse(confLocKeTemp)
        confLocKeTemp = ButtonResponse()
        confLocKeTemp.addText("Apakah lokasi di atas benar")
        confLocKeTemp.addReplyKeyboard(reply_keyboard)
        self.repsModKeConf.addResponse(confLocKeTemp)

        kembaliUser = ButtonResponse()
        kembaliUser.addText(respL.userGetOrder())
        typeKembaliUser = {}
        typeKembaliUser['kembali'] = 'Kembali'
        item1 = KeyboardButton(typeKembaliUser['kembali'])
        markup = ReplyKeyboardMarkup(row_width=1)
        markup.add(item1)
        kembaliUser.addReplyKeyboard(markup)

        lihatResponse = ButtonResponse()
        lihatResponse.addText(respL.lihatDriver())
        markup = ReplyKeyboardMarkup(row_width=2)
        typeLihat = {}
        typeLihat['lihat'] = 'Lihat'
        typeLihat['order'] = 'Order'
        typeLihat['tutup'] = 'Tutup'
        item1 = KeyboardButton(typeLihat['lihat'])
        item2 = KeyboardButton(typeLihat['order'])
        item3 = KeyboardButton(typeLihat['tutup'])
        markup.add(item1, item2, item3)
        lihatResponse.addReplyKeyboard(markup)
        # STATE----------

        initDrPsSt = OptionButtonState()
        initDrPsSt.setResponse(self.respInitDrPs)
        initDrPsSt.name = 'init-state-drps'

        self.initState = OptionButtonState()
        self.initState.setResponse(self.respInit)
        self.initState.name = 'init-state'
        handler = InitStateHandler()
        handler.setDbCon(db)
        self.initState.setPostDataHandler(handler)

        passOrderSt = OptionButtonState()
        passOrderSt.setResponse(ordStr)
        handler = PReadyHandler()
        handler.setDbCon(db)
        passOrderSt.setPostDataHandler(handler)
        handler = POutHandler()
        handler.setDbCon(db)
        passOrderSt.setPreDataHandler(handler)

        self.modifState = OptionButtonState()
        self.modifState.setResponse(self.respMod)
        self.modifState.name = 'modif-state'

        # self.respFJState = OptionButtonState()
        # self.respFJState.setResponse(self.respFJ)
        #
        self.respModNoSt = ShareContactState()
        self.respModNoSt.setResponse(self.respModNo)
        self.respModNoSt.name = 'phone-state'
        handler = PhoneDataHandler()
        handler.setDbCon(db)
        self.respModNoSt.setPreDataHandler(handler)
        #
        self.respModLocationSt = ShareLocationState()
        self.respModLocationSt.setResponse(self.respModLocation)
        self.respModLocationSt.name = 'dari-state'
        handler = DariDataHandler()
        handler.setDbCon(db)
        self.respModLocationSt.setPreDataHandler(handler)
        #
        self.repsModKeSt = ShareLocationState()
        self.repsModKeSt.setResponse(self.repsModKe)
        self.repsModKeSt.name = 'ke-state'
        handler = KeDataHandler()
        handler.setDbCon(db)
        self.repsModKeSt.setPreDataHandler(handler)
        #
        self.respHargaSt = MessageState()
        self.respHargaSt.setResponse(self.respHarga)
        self.respHargaSt.name = 'harga-state'
        handler = HargaDataHandler()
        handler.setDbCon(db)
        self.respHargaSt.setPreDataHandler(handler)

        namaPassengerSt = MessageState()
        namaPassengerSt.setResponse(namaPassenger)
        namaPassengerSt.name = 'nama-state-user'
        handler = UserName()
        handler.setDbCon(db)
        namaPassengerSt.setPreDataHandler(handler)

        #
        self.respOjkSt = OptionButtonState()
        self.respOjkSt.setResponse(self.respOjk)
        self.respOjkSt.name = 'ojek-state'
        handler = OjekDataHandler()
        handler.setDbCon(db)
        self.respOjkSt.setPreDataHandler(handler)
        #
        self.confNoSt = OptionButtonState()
        self.confNoSt.setResponse(self.confNo)
        #
        #
        self.confLocSt = OptionButtonState()
        self.confLocSt.setResponse(self.confLoc)
        self.confLocSt.name = 'conf-dari-state'
        handler = ConfLocDataHandler()
        handler.setDbCon(db)
        self.confLocSt.setPreDataHandler(handler)
        #
        self.repsModKeConfSt = OptionButtonState()
        self.repsModKeConfSt.setResponse(self.repsModKeConf)
        self.repsModKeConfSt.name = 'conf-ke-state'
        handler = ConfLocKeDataHandler()
        handler.setDbCon(db)
        self.repsModKeConfSt.setPreDataHandler(handler)

        kembaliUserSt = OptionButtonState()
        kembaliUserSt.setResponse(kembaliUser)
        kembaliUserSt.name = 'kembali-user-state'

        lihatResponseSt = OptionButtonState()
        lihatResponseSt.setResponse(lihatResponse)
        lihatResponseSt.name = 'lihat-user-state'
        handler = LihatHandler()
        handler.setDbCon(db)
        lihatResponseSt.setPreDataHandler(handler)

        self.router = Router(initDrPsSt)
        # self.router = Router(self.initState)
        dbredis = DbRedis()
        handler = RouteHandler()
        handler.setDbCon(dbredis)
        self.router.addHandler(handler)

        self.inlineRoute = InlineRoute()
        # self.inlineRoute.addBot(self.router.bot)
        self.inlineRoute.addDriverDB(dbDriver)
        self.inlineRoute.addUserDB(db)
        self.inlineRoute.setFinalState('driver', kembaliDriverSt)
        self.inlineRoute.setFinalState('user', kembaliUserSt)
        self.inlineRoute.setRouteHandler(handler)
        # self.inlineRoute.setupRoute()

        handler = NegoHandler()
        handler.setDbCon(dbDriver)
        self.router.addSpecHandler(dvReadySt, handler)
        handler = ResetHandler()
        handler.setDbUser(db)
        handler.setDbCon(dbDriver)
        self.router.setResetHandler(handler)

        self.router.addRoute(initDrPs['driver'], initDrPsSt, initDriverSt)
        self.router.addRoute(initDriver['aktifkan'], initDriverSt, dvReadySt)
        self.router.addRoute(dvKey['selese'], dvReadySt, initDriverSt)
        self.router.addRoute(dvReadySt.name, dvReadySt, dvReadySt)
        self.router.addRoute(initDriver['mod'], initDriverSt, modDriverSt)
        self.router.addRoute(modD['no'], modDriverSt, noDriverSt)
        self.router.addRoute(modD['nama'], modDriverSt, namaDriverSt)
        self.router.addRoute(modD['desc'], modDriverSt, descMotorSt)
        self.router.addRoute(modD['ojek'], modDriverSt, ojkDriverSt)
        self.router.addRoute(noDriverSt.name, noDriverSt, initDriverSt)
        self.router.addRoute(descMotorSt.name, descMotorSt, initDriverSt)
        self.router.addRoute(namaDriverSt.name, namaDriverSt, initDriverSt)
        self.router.addRoute(tipeD['motor'], ojkDriverSt, initDriverSt)
        self.router.addRoute(tipeD['mobil'], ojkDriverSt, initDriverSt)
        self.router.addRoute(tipeD['delman'], ojkDriverSt, initDriverSt)
        self.router.addRoute(tipeD['kapal'], ojkDriverSt, initDriverSt)
        self.router.addRoute(tipeD['bentor'], ojkDriverSt, initDriverSt)
        self.router.addRoute(tipeD['bajaj'], ojkDriverSt, initDriverSt)
        self.router.addRoute(typeKembali['kembali'], kembaliDriverSt,
                             initDriverSt)

        self.router.addRoute(initDrPs['passenger'], initDrPsSt, self.initState)
        self.router.addRoute(init['find'], self.initState, lihatResponseSt)
        self.router.addRoute(typeLihat['order'], lihatResponseSt, passOrderSt)
        self.router.addRoute(typeLihat['lihat'], lihatResponseSt,
                             lihatResponseSt)
        self.router.addRoute(typeLihat['tutup'], lihatResponseSt,
                             self.initState)

        self.router.addRoute(opOrd['selese'], passOrderSt, self.initState)
        self.router.addRoute(init['mod'], self.initState, self.modifState)
        self.router.addRoute(mod['no'], self.modifState, self.respModNoSt)
        self.router.addRoute(mod['dari'], self.modifState,
                             self.respModLocationSt)
        self.router.addRoute(mod['ke'], self.modifState, self.repsModKeSt)
        self.router.addRoute(mod['harga'], self.modifState, self.respHargaSt)
        self.router.addRoute(mod['ojek'], self.modifState, self.respOjkSt)
        self.router.addRoute(mod['nama'], self.modifState, namaPassengerSt)
        self.router.addRoute(self.repsModKeSt.name, self.repsModKeSt,
                             self.repsModKeConfSt)
        self.router.addRoute(self.respModLocationSt.name,
                             self.respModLocationSt, self.confLocSt)
        self.router.addRoute(self.respModNoSt.name, self.respModNoSt,
                             self.initState)
        self.router.addRoute(namaPassengerSt.name, namaPassengerSt,
                             self.initState)
        self.router.addRoute(replyBool['n'], self.confLocSt,
                             self.respModLocationSt)
        self.router.addRoute(replyBool['y'], self.confLocSt, self.initState)
        self.router.addRoute(replyBool['n'], self.repsModKeConfSt,
                             self.repsModKeSt)
        self.router.addRoute(replyBool['y'], self.repsModKeConfSt,
                             self.initState)
        self.router.addRoute(self.respHargaSt.name, self.respHargaSt,
                             self.initState)
        self.router.addRoute(tipe['motor'], self.respOjkSt, self.initState)
        self.router.addRoute(tipe['mobil'], self.respOjkSt, self.initState)
        self.router.addRoute(tipe['bentor'], self.respOjkSt, self.initState)
        self.router.addRoute(tipe['delman'], self.respOjkSt, self.initState)
        self.router.addRoute(tipe['kapal'], self.respOjkSt, self.initState)
        self.router.addRoute(tipe['bajaj'], self.respOjkSt, self.initState)
        self.router.addRoute(typeKembaliUser['kembali'], kembaliUserSt,
                             self.initState)

        self.router.addRoute(initDrPs['feedback'], initDrPsSt,
                             feedbackResponseSt)
        self.router.addRoute(feedbackResponseSt.name, feedbackResponseSt,
                             initDrPsSt)
Пример #21
0
import telebot
from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove, KeyboardButton

mark1 = InlineKeyboardMarkup()
mark1.row_width = 2
mark1.add(InlineKeyboardButton("Да", callback_data="y0"),
          InlineKeyboardButton("Нет", callback_data="n0"))

m1 = ReplyKeyboardMarkup(resize_keyboard=True)
m1.add(KeyboardButton("📲 Доступные для загрузки приложения"))
m1.add(KeyboardButton("✉ Пригласить друга"), KeyboardButton('📃 Информация'))

m2 = ReplyKeyboardMarkup(resize_keyboard=True)
m2.add(KeyboardButton("⬅ Главное меню"))

m4 = ReplyKeyboardMarkup()
m4.row_width = 1
m4.add(KeyboardButton('Joom – товары из Китая [Android 5.0+]'))
m4.add(KeyboardButton('Joom – покупай и экономь! [IOS]'))
m4.add(KeyboardButton('Auto.ru [Android 5.0+]'))
m4.add(KeyboardButton('Auto.ru [IOS]'))
m4.add(KeyboardButton('Winline [IOS]'))
m4.add(KeyboardButton('Париматч: ставки на спорт [IOS]'))
m4.add(KeyboardButton('Book of Slots [IOS]'))

md1 = ReplyKeyboardMarkup(resize_keyboard=True)
md1.add(KeyboardButton("📲 Доступные приложения для загрузки"))
md1.add(KeyboardButton("⬇ Скачать Joom[Android]"))
md1.add(KeyboardButton("⬅ Главное меню"))

md2 = ReplyKeyboardMarkup(resize_keyboard=True)
Пример #22
0
    def button(self, tip):
        self.kb = ReplyKeyboardMarkup(resize_keyboard=True,
                                      one_time_keyboard=True)

        if tip == 'start':
            but = KeyboardButton('/help')
            self.kb.add(but)

        elif tip == 'which':
            but1 = KeyboardButton('"Что быстрее?"')
            but2 = KeyboardButton('"В какую из?"')
            self.kb.add(but1, but2)

        elif tip == 'game':
            but = KeyboardButton('Начинаем!')
            self.kb.add(but)

        elif tip == 'razlog':
            but1 = KeyboardButton(raz[self.igra[1]].split(', ')[0])
            but2 = KeyboardButton(raz[self.igra[2]].split(', ')[0])
            but3 = KeyboardButton('Давай закончим')
            self.kb.add(but1, but2)
            self.kb.add(but3)

        elif tip == 'musorki':
            b1, b2, b3, b4, b5, b6, b7, b8 = map(KeyboardButton,
                                                 self.igra[2].keys())
            but = KeyboardButton('Давай закончим')
            self.kb.add(b1, b2, b3)
            self.kb.add(b4, b5)
            self.kb.add(b6, b7, b8)
            self.kb.add(but)
            main.igra.append(self.kb)

        elif tip == 'sin':
            but1 = KeyboardButton('Синий')
            but2 = KeyboardButton('Серый')
            self.kb.add(but1, but2)

        elif tip == 'res':
            but1 = KeyboardButton('Давай еще раз')
            but2 = KeyboardButton('Давай закончим')
            self.kb.add(but1, but2)
            main.igra[3] = self.kb  #В случае ошибки кнопки должны сохраниться
Пример #23
0
    'onstart': 'Здравсвуйте. Пожалуйста выберите язык. Assalomu aleykum. Iltimos, hohlagan tilingizni tanlang.',
    
}

#The dictionary consisting key-value QA's
chat_logic_ru = {
    'Привет':'Привет!',
    'Как дела?':'Хорошо! Как у тебя?',
}
chat_logic_uz = {
    'Salom':'Salom!',
    'Ishla qale?':'Yaxmale!',
}
stages = {
    
}
#Language menu
markup = ReplyKeyboardMarkup()
set_to_russian = KeyboardButton(text="Русский")
set_to_uzbek = KeyboardButton(text="O'zbekcha")
markup.add(set_to_russian)
markup.add(set_to_uzbek)
stages['language_pref'] = markup
#After the language was chosen comes main menu (Russian)
markup = ReplyKeyboardMarkup()
products = KeyboardButton(text='Продукты')
support = KeyboardButton(text='Поддержка')
markup.add(products)
markup.add(support)
stages['main_ru'] = markup
Пример #24
0
    InlineKeyboardMarkup, InlineKeyboardButton
from database import DataBase as DB
from analyzer import DostN as NN
import puzzle_generator as pg

bot = telebot.TeleBot('1715413219:AAG-psejdspI_Q1HsXq6nMbhF6H80AQXe7o')
db = DB()

mark = InlineKeyboardMarkup(row_width=3)
one = InlineKeyboardButton('1', callback_data=1)
two = InlineKeyboardButton('2', callback_data=2)
tri = InlineKeyboardButton('3', callback_data=3)
mark.add(one, two, tri)

begin = ReplyKeyboardMarkup(resize_keyboard=True)
info = KeyboardButton("Начать")
begin.add(info)


@bot.message_handler(commands=['start', 'help'])
def start(message):
    db = DB()
    try:
        ans = db.getAns(message.chat.id)
        if ans != 0:
            db.setAns(message.chat.id, 0)
    except Exception as e:
        print(e, 28)
    bot.send_message(message.chat.id, f'Привет, {message.from_user.first_name}! Я Рефлексо. Я могу отразить твое '
                                      f'настроение. Для '
                                      f'этого по возможности пиши мне о своем состоянии. Также в будущем ты сможешь '
Пример #25
0
def callback_query(call):
    # if call.data == "cb_yes":
    #     print(call.data)
    #     bot.edit_message_text("test", call.message.chat.id, call.message.message_id, reply_markup=gen_markup())
    #     bot.answer_callback_query(call.id, "Answer is Yes")
    # elif call.data == "cb_no":
    #     bot.answer_callback_query(call.id, "Answer is No")
    if call.data == "questions":
        if call.message.chat.id != -1001290867279:
            markup = ReplyKeyboardMarkup()
            for i in questions["spis_vop"]:
                markup.add(KeyboardButton(i))
            markup.add(KeyboardButton("Меню"))
            bot.send_message(call.message.chat.id,
                             "🗳 Выберите интересующий вас вопрос",
                             reply_markup=markup)
        else:
            markup = ReplyKeyboardMarkup()
            for i in questions_col["spis_vop"]:
                markup.add(KeyboardButton(i))
            markup.add(KeyboardButton("Меню"))
            bot.send_message(call.message.chat.id,
                             "🗳 Выберите интересующий вас вопрос",
                             reply_markup=markup)
        # de = chunks(questions["spis_vop"], 15)
        # l = list(de)
        # ff = 1
        # for i in l:
        #     #if ff == 1:
        #         #bot.send_message(call.message.chat.id, "Выберете номер интересуещего вас вопроса\n\n" + str('\n\n'.join(i)))
        #     #elif ff == len(l):
        #         #bot.send_message(call.message.chat.id, '\n\n'.join(i), reply_markup=gen_markup(0, len(questions["spis_nom"])))
        #     #else:
        #     bot.send_message(call.message.chat.id, '\n\n'.join(i))
        #     ff += 1
        # bot.send_message(call.message.chat.id, "🗳 Выберете номер интересуещего вас вопроса",
        #                  reply_markup=gen_markup(0, len(questions["spis_nom"])))
        # bot.edit_message_text("Выберете номер интересуещего вас вопроса", call.message.chat.id, call.message.message_id,
        #                       reply_markup=gen_markup(0, len(questions["spis_nom"])))

    elif call.data == "competition":
        if call.message.chat.type == "private":
            create_mongo["create_mongo"].add_user(call.message.chat.id, 0)
            res = loop_new.run_until_complete(
                create_mongo["create_mongo"].users_directions_add_start(
                    call.message.chat.id))
            f = 0
            if res:
                f = 1
            bot.edit_message_text("🧩 Выберите нужную функцию",
                                  call.message.chat.id,
                                  call.message.message_id,
                                  reply_markup=gen_competition(f))
    elif call.data == "competition_add":
        if call.message.chat.type == "private":
            create_mongo["create_mongo"].add_user(call.message.chat.id, 5)
            res = loop_new.run_until_complete(
                create_mongo["create_mongo"].users_directions_add_start(
                    call.message.chat.id))
            f = 0
            if res:
                f = 1
            bot.edit_message_text("Введите ваш СНИЛС/уникальный номер",
                                  call.message.chat.id,
                                  call.message.message_id,
                                  reply_markup=gen_competition(f))

    elif call.data == "competition_anonymous":
        if call.message.chat.type == "private":
            create_mongo["create_mongo"].add_user(call.message.chat.id, 6)
            res = loop_new.run_until_complete(
                create_mongo["create_mongo"].users_directions_add_start(
                    call.message.chat.id))
            f = 0
            if res:
                f = 1
            bot.edit_message_text("Введите СНИЛС/уникальный номер",
                                  call.message.chat.id,
                                  call.message.message_id,
                                  reply_markup=gen_competition(f))

    elif call.data == "my_situation":
        if call.message.chat.type == "private":
            loop_new.run_until_complete(
                create_mongo["create_mongo"].users_directions_add_start(
                    call.message.chat.id))
            msg = snils_check(call.message.chat.id, flag=1)
            g = 1
            for i in msg[1]:
                if g == len(msg[1]):
                    bot.send_message(call.message.chat.id,
                                     "\n\n".join(i),
                                     reply_markup=gen_competition(msg[0]))
                else:
                    bot.send_message(call.message.chat.id, "\n\n".join(i))
                g += 1

    elif call.data == "menu":
        if call.message.chat.type == "private":
            check = check_users(call.from_user.id, call.message.chat.id)
            if check:
                del_users(call.from_user.id, call.message.chat.id)
            bot.edit_message_text(
                "🌐 Команды бота:\n\n"
                "📝 Вопросы — покажет список часто задаваемых вопросов.\n\n"
                "📃 Направления — подберёт перспективные направления по проходным баллам",
                call.message.chat.id,
                call.message.message_id,
                reply_markup=gen_menu(True))
        else:
            bot.edit_message_text(
                "🌐 Команды бота:\n\n"
                "📝 Вопросы — покажет список часто задаваемых вопросов.\n\n",
                call.message.chat.id,
                call.message.message_id,
                reply_markup=gen_menu(False))
    elif call.data == "choice":
        if call.message.chat.type == "private":
            bot.edit_message_text(
                "💡 Для выбора сданных вами предметов используйте соответствующие кнопки.\n\n"
                "🧮 Для ввода суммы баллов отправьте сумму баллов.\n\n"
                "📃 Для получения списка программ необходимо выбрать набор сданных предметов "
                "и ввести сумму баллов.",
                call.message.chat.id,
                call.message.message_id,
                reply_markup=gen_choice("0"))

    elif call.data == "forward":
        if call.message.chat.type == "private":
            check = check_users(call.from_user.id, call.message.chat.id)
            if check:
                if int(check[4] + 1) < len(check[5]):
                    f = 0
                    if check[4] + 1 == len(check[5]) - 1:
                        f = 2
                    bot.edit_message_text(check[6] +
                                          "\n\n".join(check[5][check[4] + 1]),
                                          call.message.chat.id,
                                          call.message.message_id,
                                          parse_mode='HTML',
                                          reply_markup=gen_menu_one(f))
                    add_users(call.message.message_id,
                              call.from_user.id,
                              call.message.chat.id,
                              subjects=check[2],
                              spis=check[5],
                              f=check[4] + 1,
                              perv=check[6])

    elif call.data == "back":
        if call.message.chat.type == "private":
            check = check_users(call.from_user.id, call.message.chat.id)
            if check:
                if int(check[4] - 1) != -1:
                    f = 0
                    if check[4] - 1 == 0:
                        f = 1
                    bot.edit_message_text(check[6] +
                                          "\n\n".join(check[5][check[4] - 1]),
                                          call.message.chat.id,
                                          call.message.message_id,
                                          parse_mode='HTML',
                                          reply_markup=gen_menu_one(f))
                    add_users(call.message.message_id,
                              call.from_user.id,
                              call.message.chat.id,
                              subjects=check[2],
                              spis=check[5],
                              f=check[4] - 1,
                              perv=check[6])

    elif call.data == "nap1":
        if call.message.chat.type == "private":
            subjects = {
                "math&rus&info": "Математика Русский Информатика и ИКТ",
                "math&rus&phys": "Математика Русский Физика",
                "math&rus&chem": "Математика Русский Химия",
                "math&rus&soc": "Математика Русский Обществознание",
                "rus&soc&hist": "Русский Обществознание История",
                "math&rus&art": "Математика Русский Творческий экзамен",
                "rus&soc&art": "Русский Обществознание Творческий экзамен",
                "reduction": "rus&soc&art"
            }
            check = check_users(call.from_user.id, call.message.chat.id)
            add_users(call.message.message_id,
                      call.from_user.id,
                      call.message.chat.id,
                      subjects=check[2],
                      f=1)
            predmets = check[2].split("&")
            #print(check, predmets)
            pol_sql = pol_js(predmets[0], predmets[1], predmets[2],
                             str(check[3]), 1)
            spis = []
            for i in pol_sql["programs"]:
                spis.append(
                    f"🔮 <a href='{i['link']}'>{i['name']} {i['code']}</a>\n📊 Прошлогодний проходной балл на бюджет:{i['bal']}\n"
                    f"👥 Количество бюджетных мест: {i['places']}")
            de = chunks(spis, 10)
            l = list(de)
            #print(len(l))

            ff = 1
            for i in l:
                if ff == 1:
                    bot.send_message(call.message.chat.id,
                                     "🔎 Высокие шансы поступления:\n\n" +
                                     "\n\n".join(i),
                                     parse_mode='HTML')
                # elif ff == len(l):
                #     bot.send_message(call.message.chat.id, "\n\n".join(i),
                #                      reply_markup=gen_choice(call.data),
                #                      parse_mode='HTML')
                else:
                    bot.send_message(call.message.chat.id,
                                     "\n\n".join(i),
                                     parse_mode='HTML')
                ff += 1

            m = bot.send_message(
                call.message.chat.id,
                "💡 Для выбора сданных вами предметов используйте соответствующие кнопки.\n\n"
                "🧮 Для ввода суммы баллов отправьте сумму баллов.\n\n"
                "📃 Для получения списка программ необходимо выбрать набор сданных предметов "
                "и ввести сумму баллов.\n\n"
                f"📚 Выбранные предметы: {subjects[check[2]]}\n\n"
                f"💿 Введённые баллы: {check[3]}",
                reply_markup=gen_choice(check[2], int(pol_sql["quantity"])))
            #print(m)
            add_users(m.message_id,
                      call.from_user.id,
                      call.message.chat.id,
                      subjects=check[2],
                      bal=check[3],
                      f=1)
            # bot.edit_message_text("💡 Для выбора сданных вами предметов используйте соответствующие кнопки.\n\n"
            #                       "🧮 Для ввода суммы баллов отправьте сумму баллов.\n\n"
            #                       "📃 Для получения списка программ необходимо выбрать набор сданных предметов "
            #                       "и ввести сумму баллов.\n\n"
            #                       f"📚 Выбранные предметы: {subjects[check[2]]}\n\n"
            #                       f"💿 Введённые баллы: {check[3]}",
            #                       call.message.chat.id, call.message.message_id,
            #                       reply_markup=gen_choice(check[2]))

    elif call.data in [
            i for i in [
                "math&rus&info", "math&rus&phys", "math&rus&chem",
                "math&rus&soc", "rus&soc&hist", "math&rus&art", "rus&soc&art"
            ]
    ]:
        if call.message.chat.type == "private":
            subjects = {
                "math&rus&info": "Математика Русский Информатика и ИКТ",
                "math&rus&phys": "Математика Русский Физика",
                "math&rus&chem": "Математика Русский Химия",
                "math&rus&soc": "Математика Русский Обществознание",
                "rus&soc&hist": "Русский Обществознание История",
                "math&rus&art": "Математика Русский Творческий экзамен",
                "rus&soc&art": "Русский Обществознание Творческий экзамен",
                "reduction": "rus&soc&art"
            }
            check = check_users(call.from_user.id, call.message.chat.id)
            pl = ""
            if check:
                if check[3] != 0:
                    pl = f"\n\n💿 Введённые баллы: {check[3]}"
                add_users(call.message.message_id, call.from_user.id,
                          call.message.chat.id, call.data, check[3])
            else:
                add_users(call.message.message_id, call.from_user.id,
                          call.message.chat.id, call.data)

            bot.edit_message_text(
                "💡 Для выбора сданных вами предметов используйте соответствующие кнопки.\n\n"
                "🧮 Для ввода суммы баллов отправьте сумму баллов.\n\n"
                "📃 Для получения списка программ необходимо выбрать набор сданных предметов "
                "и ввести сумму баллов.\n\n"
                f"📚 Выбранные предметы: {subjects[call.data]}{pl}",
                call.message.chat.id,
                call.message.message_id,
                reply_markup=gen_choice(call.data))
    elif call.data in questions["spis_nom"]:  #[str(i) for i in range(24)]:

        bot.edit_message_text(
            f"💡 Выбран вопрос с номером {call.data}\n\n"
            f"❓ {questions['vopr'][str(call.data)]}\n\n"
            f"ℹ️ {questions['nom'][str(call.data)]}",
            call.message.chat.id,
            call.message.message_id,
            reply_markup=gen_markup(int(call.data),
                                    len(questions["spis_nom"])))
Пример #26
0
from telebot.types import KeyboardButton, ReplyKeyboardMarkup

from .types import MainKeyboardTypes as Keys

return_to_cabinet_keyboard_markup = ReplyKeyboardMarkup()

return_to_cabinet_keyboard_markup.row(KeyboardButton(Keys.CABINET))

__all__ = ['return_to_cabinet_keyboard_markup']
Пример #27
0
def not_found():
    kb=ReplyKeyboardMarkup(resize_keyboard=True)
    b2=KeyboardButton("📲 Главное меню")
    kb.row(b2)
    return kb    
Пример #28
0
 def __init__(self, name: str, **kwargs: Any) -> None:
     self._button: JsonSerializable = KeyboardButton(name, kwargs)
Пример #29
0
def fin3():
    kb=ReplyKeyboardMarkup(resize_keyboard=True)
    b1=KeyboardButton("📲 Главное меню")
    kb.row(b1)
    return kb
Пример #30
0
def start(message):
    kb = ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
    kb.add(*[KeyboardButton(text=text) for text in LANGUAGE.keys()])

    bot.send_message(message.chat.id, 'Выберите язык', reply_markup=kb)