예제 #1
0
def less_day(call):
    try:
        bot.answer_callback_query(call.id, text="Выберете дату")
        now = datetime.now()  # Current date
        chat_id = call.message.chat.id
        date = (now.year, now.month)
        current_shown_dates[
            chat_id] = date  # Saving the current date in a dict
        markup = create_calendar(now.year, now.month)
        conn = sqlite3.connect(dbname)
        cursor = conn.cursor()
        for row in cursor.execute(
                "select header, date, time, place, comment, phone_number,"
                " rowid from orders where chat_id = " +
                str(call.message.chat.id) +
                " and status = 0 order by rowid desc limit 1;"):
            text = order(header=str(row[0]),
                         date=str(row[1]),
                         time=str(row[2]),
                         place=str(row[3]),
                         comment=str(row[4]),
                         number=str(row[5]))
        conn.close()
        bot.edit_message_text(text,
                              call.message.chat.id,
                              call.message.message_id,
                              parse_mode='MARKDOWN',
                              reply_markup=markup)
    except:
        bot.edit_message_text("*Начните новый предзаказ*",
                              call.from_user.id,
                              call.message.message_id,
                              parse_mode='MARKDOWN')
예제 #2
0
def get_calendar(message):
    now = datetime.datetime.now() #Current date
    chat_id = message.chat.id
    date = (now.year,now.month)
    current_shown_dates[chat_id] = date #Saving the current date in a dict
    markup= create_calendar(now.year,now.month)
    bot.send_message(message.chat.id, "легко! Выбери дату твоего события", reply_markup=markup)
예제 #3
0
def calendar(update, context):
    """
    Выбор даты с календаря
    """
    log.info(f"пользователь выберет дату на календаре")
    update.message.reply_text("Пожалуйста, выберите дату: ",
                              reply_markup=telegramcalendar.create_calendar())
예제 #4
0
def calendar_handler(bot, update):
    user = update.message.from_user
    logger.info("Calender command requested by {}.".format(user.first_name))
    update.message.reply_text("Silahkan Pilih Tanggal: ",
                              reply_markup=telegramcalendar.create_calendar())

    return CALENDAR
예제 #5
0
def name(m):
    if m.text == 'Past':
        bot.send_message(m.chat.id,
                         '_' + '\n'.join(map(str, p_info[:5])) + '_',
                         parse_mode='Markdown',
                         reply_markup=pages_keyboard(0, 5, m.text))
    elif m.text == 'Ongoing':
        bot.send_message(m.chat.id,
                         '_' + '\n'.join(map(str, o_info[:5])) + '_',
                         parse_mode='Markdown',
                         reply_markup=pages_keyboard(0, 5, m.text))
    elif m.text == 'Upcoming':
        bot.send_message(m.chat.id,
                         '_' + '\n'.join(map(str, u_info[:5])) + '_',
                         parse_mode='Markdown',
                         reply_markup=pages_keyboard(0, 5, m.text))
    elif m.text == 'Ongoing by date':
        now = datetime.datetime.now()
        chat_id = m.chat.id
        date = (now.year, now.month)
        current_shown_dates[chat_id] = date
        markup = create_calendar(now.year, now.month)
        bot.send_message(m.chat.id,
                         "Please, choose a date",
                         reply_markup=markup)
    if m.text in ['Past', 'Ongoing', 'Upcoming']:
        msg1 = bot.send_message(
            m.chat.id,
            'Table provides information about /ICO name/date/hype score/risk score/goal/'
        )
        bot.register_next_step_handler(msg1, name)
    else:
        msg1 = bot.send_message(m.chat.id, 'Chosen date is:')
        bot.register_next_step_handler(msg1, name)
예제 #6
0
def handle_month_query(call):
    if not check_started(call.message):
        return
    temp = call.data.split(';')
    month_opt = temp[0].split('-')[0]
    year, month = int(temp[1]), int(temp[2])
    chat_id = call.message.chat.id

    if month_opt == 'PREV':
        month -= 1

    elif month_opt == 'NEXT':
        month += 1

    if month < 1:
        month = 12
        year -= 1

    if month > 12:
        month = 1
        year += 1

    date = (year, month)
    current_shown_dates[chat_id] = date
    markup = create_calendar(year, month)
    bot.edit_message_text("Выберите дату",
                          call.from_user.id,
                          call.message.message_id,
                          reply_markup=markup)
예제 #7
0
파일: main.py 프로젝트: Cow-berry/hwbot_v2
def previous_month(call, sub=None):
    if active_calendars.get(call.message.chat.id, 0) == 0:
        pass
    elif active_calendars[call.message.chat.id] != call.message.date:
        bot.answer_callback_query(call.id, text="")
        return
    chat_id = call.message.chat.id
    saved_date = current_shown_dates.get(chat_id)
    if (saved_date is not None):
        year, month = saved_date
        month -= 1
        if month < 1:
            month = 12
            year -= 1
        date = (year, month)
        current_shown_dates[chat_id] = date
        markup = create_calendar(year, month, subject=sub)
        bot.edit_message_text("Выберите дату:",
                              call.from_user.id,
                              call.message.message_id,
                              reply_markup=markup)
        active_calendars[call.message.chat.id] = call.message.date
        bot.answer_callback_query(call.id, text="")
    else:
        #Do something to inform of the error
        pass
예제 #8
0
def calendar_handler(update, context):
    """
    Отображение календаря на экране
    """
    log.info("Выбрано показать календарь")
    update.message.reply_text("пожалуйста, выберите дату: ", reply_markup=telegramcalendar.create_calendar())
    return DATE_OF_DEPARTURE
예제 #9
0
def calendar(bot, update, user_data):
    """ Вызов инлайн клавиатуры с календарем """

    query = update.callback_query
    name = query.data
    if name == 'Вова':
        bot.delete_message(chat_id=query.from_user.id,
                           message_id=query.message.message_id)
        bot.send_message(text='Выберите дату: {}'.format(smiles[4]),
                         chat_id=query.from_user.id,
                         message_id=query.message.message_id,
                         reply_markup=telegramcalendar.create_calendar_vova())
    elif name == 'Дима':
        bot.delete_message(chat_id=query.from_user.id,
                           message_id=query.message.message_id)
        bot.send_message(text='Выберите дату: {}'.format(smiles[4]),
                         chat_id=query.from_user.id,
                         message_id=query.message.message_id,
                         reply_markup=telegramcalendar.create_calendar_dima())
    elif name == 'Сергей':
        bot.delete_message(chat_id=query.from_user.id,
                           message_id=query.message.message_id)
        bot.send_message(text='Выберите дату: {}'.format(smiles[4]),
                         chat_id=query.from_user.id,
                         message_id=query.message.message_id,
                         reply_markup=telegramcalendar.create_calendar_serg())
    else:
        bot.delete_message(chat_id=query.from_user.id,
                           message_id=query.message.message_id)
        bot.send_message(text='Выберите дату: {}'.format(smiles[4]),
                         chat_id=query.from_user.id,
                         message_id=query.message.message_id,
                         reply_markup=telegramcalendar.create_calendar())
    user_data['name'] = query.data
    return THIRD
예제 #10
0
def get_calendar(call):
    try:
        chat_id = call.message.chat.id
        customer_mngmnt.get_customer(chat_id).set_current_type_of_thing(
            call.data[15:].upper())
        if not preorder_mngmnt.is_preorder_exist(chat_id):
            now = datetime.datetime.now()  # Current date
            date = (now.year, now.month)
            customer_mngmnt.get_customer(chat_id).set_current_calendar_month(
                date)  # Saving the current date in a dict
            markup = create_calendar(now.year, now.month)
            bot.edit_message_text(
                "Пожалуйста, выберите дату, на которую планируете взять прокат",
                call.from_user.id,
                call.message.message_id,
                reply_markup=markup)
            bot.answer_callback_query(call.id, text="")
        else:
            message = pagination.create_list(
                customer_mngmnt.get_customer(chat_id), 0,
                preorder_mngmnt.get_preorder(chat_id))
            bot.edit_message_text(message['message_text'],
                                  call.from_user.id,
                                  call.message.message_id,
                                  reply_markup=message['markup'],
                                  parse_mode='HTML')
            bot.answer_callback_query(call.id, text="")
    except AttributeError as err:
        attribute_error_handler(err, call)
예제 #11
0
    def handle_month_query(call):

        info = call.data.split(';')
        callback_info = info[0].split('-')[0]
        month_opt = info[0].split('-')[1]
        year, month = int(info[1]), int(info[2])

        if month_opt == 'PREV':
            month -= 1

        elif month_opt == 'NEXT':
            month += 1

        if month < 1:
            month = 12
            year -= 1

        if month > 12:
            month = 1
            year += 1

        opt_msg = 'начала' if callback_info == 'START' else 'окончания'
        handle_month_query_msg = translate_to(lang, 'Выберите дату {}: \n'.format(opt_msg))

        markup = create_calendar(year, month, callback_info)

        bot.edit_message_text(handle_month_query_msg, call.message.chat.id, call.message.message_id,
                              reply_markup=markup)
예제 #12
0
def get_calendar(cid):
    now = datetime.datetime.now()  #Current date
    chat_id = cid
    date = (now.year, now.month)
    current_shown_dates[chat_id] = date  #Saving the current date in a dict
    markup = create_calendar(now.year, now.month)
    bot.send_message(cid, "Please, choose a date", reply_markup=markup)
예제 #13
0
def get_calendar(message):
    global choose_date
    now = datetime.datetime.now()
    markup = telegramcalendar.create_calendar(now.year, now.month)
    choose_date = bot.send_message(message.chat.id,
                                   "Пожалуйста, выберите дату",
                                   reply_markup=markup.to_json())
예제 #14
0
def get_calendar(message):
    now = datetime.datetime.now()  #Current date
    chat_id = message.chat.id
    date = (now.year, now.month)
    current_shown_dates[chat_id] = date  #Saving the current date in a dict
    markup = create_calendar(now.year, now.month)
    bot.reply_to(message, "Пожалуйста, выберите дату.", reply_markup=markup)
예제 #15
0
def show_calendar(message):
    chat_id = message.chat.id
    date = (datetime.datetime.now().year, datetime.datetime.now().month)
    currentShownDates[chat_id] = date
    markup = create_calendar(datetime.datetime.now().year,
                             datetime.datetime.now().month)
    bot.send_message(message.chat.id, "Выберите дату", reply_markup=markup)
예제 #16
0
 def create_calendar(self, update, context):
     query = update.callback_query
     reply_markup = telegramcalendar.create_calendar()
     context.bot.edit_message_text(chat_id=query.message.chat_id,
                                   message_id=query.message.message_id,
                                   text=u"Выберите дату",
                                   reply_markup=reply_markup)
     return CALENDAR
예제 #17
0
def options_callback(query):
    chat_id = query.message.chat.id
    current_options[chat_id] = query.data
    now = datetime.datetime.now()
    date = (now.year, now.month)
    current_shown_dates[chat_id] = date
    markup = create_calendar(now.year, now.month)
    bot.send_message(query.message.chat.id, "Пожалуйста, выберите дату", reply_markup=markup)
예제 #18
0
def callback(call):
    now = datetime.datetime.now()
    chat_id = call.message.chat.id
    date = (now.year, now.month)
    current_shown_dates[chat_id] = date
    markup_calendar = telegramcalendar.create_calendar(now.year, now.month)
    bot.send_message(call.message.chat.id,
                     "What date?",
                     reply_markup=markup_calendar)
예제 #19
0
파일: main.py 프로젝트: Cow-berry/hwbot_v2
def hw_on_day(message):
    now = datetime.datetime.now()  #Current date
    chat_id = message.chat.id
    date = (now.year, now.month)
    current_shown_dates[chat_id] = date  #Saving the current date in a dict
    markup = create_calendar(now.year, now.month)
    active_calendars[message.chat.id] = message.date
    bot.send_message(message.chat.id, "Выберите дату:", reply_markup=markup)
    start(message)
예제 #20
0
def get_calendar(msg):
    now = datetime.datetime.now()  # Current date
    chat_id = msg.chat.id
    telebot.date = (now.year, now.month)
    telebot.current_shown_dates[
        chat_id] = telebot.date  # Saving the current date in a dict
    markup = create_calendar(now.year, now.month)
    bot.send_message(msg.chat.id,
                     "Пожалуйста, выберете дату",
                     reply_markup=markup)
예제 #21
0
def calendar_end(update, context):
    """
    This method set end of calendar range
    :param update:
    :param context:
    :return:
    """
    user_name = update.effective_user.first_name
    update.message.reply_text("Please select end: ",
                              reply_markup=telegramcalendar.create_calendar())
예제 #22
0
def echo_task(message):
    global_m_text.append(message.text)
    now = datetime.datetime.now()  #Текущая дата
    markup = types.InlineKeyboardMarkup()
    row_set = create_calendar(now.year, now.month)

    for i in row_set:
        markup.row(*i)
    bot.send_message(message.chat.id,
                     "Пожалуйста, выберите дату",
                     reply_markup=markup)
예제 #23
0
파일: main.py 프로젝트: Cow-berry/hwbot_v2
def choose_dates(message):
    now = datetime.datetime.now()  #Current date
    chat_id = message.chat.id
    date = (now.year, now.month)
    current_shown_dates[chat_id] = date  #Saving the current date in a dict
    markup = create_calendar(now.year, now.month, subject=' ')
    bot.send_message(message.chat.id,
                     "Выберите две даты:",
                     reply_markup=markup)
    active_calendars[message.chat.id] = message.date
    start(message)
예제 #24
0
    def handle_request_text(message):
        
        # write in temp arr
        tmp_requests.append({})
        requests_count = len(tmp_requests) - 1
        tmp_requests[requests_count]['request_text'] = message.text
        tmp_requests[requests_count]['request_create_date'] = datetime.datetime.now().strftime('%d.%m.%Y')
        handle_request_text_msg = translate_to(lang, 'Выберите дату начала: \n')

        # this is markup
        start_date = create_calendar(callback_info='START')
        bot.send_message(message.chat.id, handle_request_text_msg, reply_markup=start_date)
예제 #25
0
def on_massage_anti(update: Update, context: CallbackContext):
    user_data = context.user_data
    category = 'Вид массажа'
    massage = 'Антицеллюлитный'
    user_data[category] = massage

    query = update.callback_query
    query.answer()

    query.edit_message_text("Выберите дату: ", reply_markup=telegramcalendar.create_calendar())

    return STATE_SELECT_DATE
예제 #26
0
def add(bot, update, user_data):
    """Handler for 'add' command, which adds schedule for new dates

    Handler actually only creates calendar keyboard
    """
    try:
        del (user_data['start'])
        del (user_data['end'])
    except KeyError:
        pass
    update.message.reply_text("Выбери первую дату: ",
                              reply_markup=telegramcalendar.create_calendar())
예제 #27
0
    def handle_edit_date_query(call):

        info = call.data.split(';')
        callback_info = info[0].split('-')[0]

        opt_msg = 'начала' if callback_info == 'START' else 'окончания'
        handle_edit_date_query_msg = translate_to(lang,'Выберите дату {}: \n'.format(opt_msg))

        # this is markup
        markup = create_calendar(callback_info=callback_info)
        bot.edit_message_text(handle_edit_date_query_msg, call.message.chat.id, call.message.message_id,
                              reply_markup=markup)
예제 #28
0
    def set_end_date(message):

        requests_count = len(tmp_requests) - 1
        tmp_requests[requests_count]['request_time'] = message.text
        tmp_requests[requests_count]['user_id'] = message.from_user.id
        tmp_requests[requests_count]['chat_id'] = message.chat.id

        set_end_date_msg = translate_to(lang, 'Выберите дату окончания:')

        markup = create_calendar(callback_info='END')

        bot.send_message(message.chat.id, set_end_date_msg, reply_markup=markup)
예제 #29
0
    def other_date(self, bot, update):
        """
        Pick a date for delayed posting
        :param bot:
        :param update:
        :return:
        """
        logger.info("PICK OTHER DATE")
        update.message.reply_text(
            "Please select a date: ",
            reply_markup=telegramcalendar.create_calendar())

        return 2
예제 #30
0
def name(update, context):
    name = update.message.text
    if name == "/cancel":
        cancel(update, context)
        return ConversationHandler.END
    username = update.message["chat"]["id"]
    json_editor(username, "name", name)
    logger.info("Name: %s", update.message.text)
    update.message.reply_text(
        f"\U0001F4C5* Установка напоминания *\U0001F4C5\n\nКогда вам нужно напомнить?\n *{name}*?",
        reply_markup=telegramcalendar.create_calendar(),
        parse_mode="markdown")
    return DATE_Q