def process_search_pharm(message): if message.text == "👩🏻⚕️ Аптеки в Районах Бишкека": markup = types.ReplyKeyboardMarkup(resize_keyboard=True) markup.row("Ленинский", "Свердловский", "Первомайский", "Октябрьский", "🚪 Назад") send = bot.send_message(message.chat.id, "Выберите пожалуйста:", reply_markup=markup) bot.register_next_step_handler(send, process_search_region) # 175 строка elif message.text == "🧴 Поиск Маски по названию и адресу": msg = bot.send_message( message.chat.id, "Введите пожалуйста название аптеки:", reply_markup=types.ReplyKeyboardRemove(), ) bot.register_next_step_handler(msg, process_search_names) elif message.text == "🚪 Выйти": exit_(message)
def asked_for_year(userDocument): markup = types.ReplyKeyboardRemove(selective=False) year = message.text.strip() result = re.fullmatch(r'^[0-6]$', year) if result is not None: curYear = datetime.now().year userDocument["userinfo"]["year"] = curYear - int(year) set_user_info(message.from_user.id, userDocument) set_scenario_state(userDocument, c.asked_for_department) bot.send_message( message.chat.id, "Курс обучения успешно задан - " + str(curYear - int(userDocument["userinfo"]["year"]))) bot.send_message( message.chat.id, "Введите название своего факультета в свободной форме", reply_markup=markup) else: bot.send_message(message.chat.id, "Неправильный формат, повторите еще", reply_markup=markup) return
def send_games(message): markup = types.ReplyKeyboardRemove() bot.send_message(message.chat.id, message.text, reply_markup=markup) markup = types.ReplyKeyboardMarkup() markup.row('/kosti') markup.row('/ЖдатьОбновлений😄') answer = "Выберите игру : \n\n" answer += "/kosti - генерирует число от 1 до 6\n" bot.send_message(message.chat.id, answer, reply_markup=markup) print("\n\ngames", "\n\nfrom", message.from_user.first_name, "||") @bot.message_handler(commands=['/kosti']) def send_kosti(message): rNum = random.randrange(1, 7, 1) bot.send_message(message.chat.id, "У вас выпало : " + str(rNum)) print("\n\nkosti", rNum, "\n\nfrom", message.from_user.first_name, "||")
def different_currencies(message): if (message.text == "RUB"): dictionary = finding_needed_dictionary(x, 643) bot.send_message( message.chat.id, "Текущий курс рубля по отношению к гривне: " + str(round(dictionary.get('rate'), 2))) elif (message.text == "USD"): dictionary = finding_needed_dictionary(x, 840) bot.send_message( message.chat.id, "Текущий курс доллара США по отношению к гривне: " + str(round(dictionary.get('rate'), 2))) elif (message.text == "EUR"): dictionary = finding_needed_dictionary(x, 978) bot.send_message( message.chat.id, "Текущий курс евро по отношению к гривне: " + str(round(dictionary.get('rate'), 2))) else: bot.send_message(message.chat.id, 'Спасибо за пользование!', reply_markup=types.ReplyKeyboardRemove())
def add_model_car(message): try: chat_id = message.chat.id model = message.text if message.text is None: msg = bot.reply_to(message, 'Введены неверные данные, попробуйте еще раз') bot.register_next_step_handler(msg, add_model_car) else: logging.info(str(chat_id) + ' ' + str(message.text)) user = user_dict[chat_id] user.model = model msg = bot.reply_to(message, 'Гос.номер автомобиля (например, А012РН196)', reply_markup=types.ReplyKeyboardRemove()) bot.register_next_step_handler(msg, add_car_number) except Exception as e: logging.info(str(chat_id) + ' add_model_car ' + str(e)) msg = bot.reply_to(message, 'Введены неверные данные, попробуйте еще раз') bot.register_next_step_handler(msg, add_model_car)
def handle_2(message): bot.send_message(message.chat.id, 'maybe it will be useful', reply_markup=types.ReplyKeyboardRemove()) ingrid = str(message.text) ingrid = ingrid.lower() dbase = sqlite3.connect('database.db') with dbase: cur = dbase.cursor() cur.execute("SELECT recep FROM cookbook WHERE ingr = '%s'" % ingrid) rows = cur.fetchall() for row in rows: bot.send_message(message.chat.id, row) with dbase: cur = dbase.cursor() cur.execute("SELECT recep FROM cookbook WHERE type = '%s'" % ingrid) rows = cur.fetchall() for row in rows: bot.send_message(message.chat.id, row) dbase.close bot.send_message(message.chat.id, "press /this to try again")
def set_up_vacation_step2(message): global user_to_change users = load_chat_users(chat_id=message.chat.id) user = User(user_id=users[user_to_change], chat_id=message.chat.id) user.check_if_user_exists() markup = types.ReplyKeyboardRemove() if message.text == "On vacation/ill" or message.text == "Not on vacation/ill": if message.text == "On vacation/ill": status = 'True' else: status = 'False' user.change_vacation(value=status) bot.send_message(message.chat.id, 'Done. The user is now ' + str(message.text).lower(), reply_markup=markup) user_to_change = "" else: bot.send_message( message.chat.id, 'In case noone told you - you can not write an essay here, use suggested options.', reply_markup=markup)
def process_soha_step(message): str(message.text) chat_id = message.chat.id user = user_dict[chat_id] user.soha = message.text bot.send_message(chat_id, getRegData(user, 'tg name', message.from_user.first_name), parse_mode="Markdown") bot.send_message('-1001466284053', getRegData(user, 'Заявка от бота', bot.get_me().username), parse_mode="Markdown") markup = types.ReplyKeyboardRemove(selective=False) msg = bot.send_message( chat_id, "Tabriklaymiz muvaffaqiyat registratsiyadan o'tingiz.\n Biz tez orada siz bilan bog'lanamiz.\n/start", reply_markup=markup)
def solo_answer(message_text,user_id): markup = types.ReplyKeyboardRemove() #print(message_text) if message_text in config.positive_answers: unright_detect[user_id] = 0 send_message(user_id, config.point_prediction) theme_id = waiting_answer_from_user[user_id].sended_theme if theme_id in point_callbacks.callbacks.keys(): point_callbacks.callbacks[theme_id](message_sender(user_id, markup)) elif (message_text in config.negative_answers): unright_detect.setdefault(user_id, 0) unright_detect[user_id] += 1 if (unright_detect[user_id] >= 3): send_message(user_id, config.streak3) unright_detect[user_id] = 0 else: send_message(user_id, config.unpoint_prediction, reply_markup=markup) notifications[user_id] = models.motification(user_id, config.help_message, config.notification_delay) pass waiting_answer_from_user[user_id].waiting_response = False
def process_soha_step(message): str(message.text) chat_id = message.chat.id user = user_dict[chat_id] user.soha = message.text bot.send_message(chat_id, getRegData(user, 'tg name', message.from_user.first_name), parse_mode="Markdown") bot.send_message('-1001466284053', getRegData(user, 'Заявка от бота', bot.get_me().username), parse_mode="Markdown") markup = types.ReplyKeyboardRemove(selective=False) msg = bot.send_message( chat_id, "Поздравляем с успешной регистрацией. \n Мы свяжемся с вами в ближайшее время.\n/start", reply_markup=markup)
def current_wheather(bot, city_id, chat_id): request = requests.get(url_base + "weather", params={ 'id': city_id, 'units': 'metric', 'appid': appid, 'lang': 'ru' }) data = request.json() bot.send_message( chat_id, 'погода: {} \nтемпература: {:.0f} °C\n'.format( data['weather'][0]['description'], data['main']['temp']) + 'минимальная температура: {:.0f} °C \n'.format( data['main']['temp_min']) + 'максимальная температура: {:.0f} °C\n'.format( data['main']['temp_max']) + 'скорость ветра: {} м/c\nдавление: {} гПа'.format( data['wind']['speed'], data['main']['pressure'])) bot.send_message(chat_id, 'Введите название населенного пункта.', reply_markup=types.ReplyKeyboardRemove(selective=False))
def echo(message): """ This function remove user from Data Base and sends a farewell message. :param message: :return: """ menu = types.ReplyKeyboardRemove() user_id = message.chat.id if message.chat.id in communications: bot.send_message(communications[user_id]['UserTo'], m_disconnect_user, reply_markup=menu) tmp_id = communications[user_id]['UserTo'] delete_info(tmp_id) delete_user_from_db(user_id) bot.send_message(user_id, m_good_bye)
def choose_task(message): task = Task.objects.get(id=message.text) text = f"<b>Name:</b>\t<i>{task.name}</i>\n\n" \ f"<b>Description:</b>\n<i>{task.description}</i>\n\n" \ f"<b>Date</b>\t<i>{task.date.strftime('%d %B %Y')}</i>\n\n" \ f"<b>Status</b>: <i>{task.get_status_display()}</i>" markup = types.ReplyKeyboardRemove() if task.status == 1: markup = types.InlineKeyboardMarkup() markup.row( types.InlineKeyboardButton( f'{emojis.x} reject {task.id}', callback_data=f'{strings.reject} {task.id}'), types.InlineKeyboardButton( f'{emojis.white_check_mark} accept {task.id}', callback_data=f'{strings.accept} {task.id}'), ) bot.send_message(message.chat.id, text, parse_mode='HTML', reply_markup=markup)
def process_time_step(message): try: if message.text == 'Нет': user_id = message.from_user.id Users(user_id).remove_dates() markup = types.ReplyKeyboardMarkup(one_time_keyboard=False) countries = get_countries() for country in countries: markup.add(country[0]) msg = bot.reply_to(message, text='Выберите страну поиска', reply_markup=markup) bot.register_next_step_handler(msg, process_region_step) elif message.text == 'Да': markup = types.ReplyKeyboardRemove() mes = 'Отправьте дату, *с момента которой* хотите получить ссылки.\n' \ 'Формат ввода даты: `YYYY-MM-DD`' msg = bot.reply_to(message, mes, parse_mode='Markdown', reply_markup=markup) bot.register_next_step_handler(msg, process_after_date_step) except Exception as er: bot.reply_to(message, text='*Произошла ошибка!\n*' '*Попробуйте еще раз!*', parse_mode='Markdown')
def check_answer(message): # Если функция возвращает None -> Человек не в игре answer = str(random.randint(1, 3)) # Как Вы помните, answer может быть либо текст, либо None # Если None: if not answer: bot.send_message(message.chat.id, 'Чтобы начать игру, выберите команду /game') else: # Уберем клавиатуру с вариантами ответа. keyboard_hider = types.ReplyKeyboardRemove() # Если ответ правильный/неправильный if message.text == answer: bot.send_message(message.chat.id, 'Верно!', reply_markup=keyboard_hider) else: bot.send_message( message.chat.id, 'Увы, Вы не угадали. Попробуйте ещё раз! Ответ: ' + answer, reply_markup=keyboard_hider)
def handle_translation(message): """ translate :param message: :return: """ try: string = message.text.split(" ", 1)[1] l.warning('Request from {} - @{}: {}'.format(message.chat.id, message.chat.username, string)) #markup = types.ReplyKeyboardMarkup(row_width=2) rooms = types.ReplyKeyboardRemove(row_width=1) rooms.row(types.KeyboardButton('ERG-409'), types.KeyboardButton('ERG-411'), types.KeyboardButton('ERG-514')) rooms.row(types.KeyboardButton('BTS-Charcoal'), types.KeyboardButton('BTS-Ferrum'), types.KeyboardButton('BTS-Copper')) rooms.row(types.KeyboardButton(u'\U000025C0 ' + 'Отмена')) #print (config.rooms) #print (str([i.split() for i in config.rooms])) #markup.add(types.KeyboardButton()) #markup.add(types.KeyboardButton([str(i.split()) for i in config.rooms])) # for i in config.rooms: # print (i) # markup.add(types.KeyboardButton(i)) #markup.add(itembtn1, itembtn2, itembtn3) #markup.add(config.rooms) bot.send_message(message.chat.id, "Выберите переговорную:", reply_markup=rooms) except LookupError: bot.send_message(message.chat.id, "Попробуйте ввести `/meeting <номер кабинета>`", parse_mode="Markdown")
def text(message): def city_finish(message): users[message.from_user.id]['city'] = message.text # sql_query('INSERT INTO users (name,phone,city) VALUES ({},{},{})'.format(to_base(users[message.from_user.username]['name']),to_base(users[message.from_user.username]['phone']),to_base(users[message.from_user.username]['city']))) mes = 'Теперь вы можете выбрать категорию, по которой хотите получать заказы.' # users.pop(message.from_user.username,1) m = bot.send_message(message.from_user.id, mes, reply_markup=config.get_categoryes()) def phone_city(message): users[message.from_user.id]['phone'] = message.text mes = 'Спасибо, теперь выбери свой город из предложенных ниже🔽' # инструкция m = bot.send_message(message.from_user.id, mes, reply_markup=reply_city()) bot.register_next_step_handler(m, city_finish) def name_phone(message): users[message.from_user.id] = { 'name': message.text, 'phone': '', 'city': '', 'category': '' } mes = 'Приятно познакомиться, {}. Отправь мне свой номер телефона.'.format( message.text) m = bot.send_message(message.from_user.id, mes, reply_markup=types.ReplyKeyboardRemove()) bot.register_next_step_handler(m, phone_city) if message.text == 'Зарегистрироваться': mes = 'Введите свое ФИО' print(message) m = bot.send_message(message.from_user.id, mes, reply_markup=types.ReplyKeyboardRemove()) bot.register_next_step_handler(m, name_phone)
def add_data2(message): date_s = message.text global data_list global new global deadlines_to_print if date_s == "Без дедлайна": data_list.append( datetime.datetime(2222, 2, 22, 23, 59) ) # какое-то абстрактное далёкое будущее для дел без дедлайнов; дату можно изменить deadlines_to_print[new] = "Нет" else: is_year = 0 for i in date_s: if i == ".": is_year += 1 thedate = 0 if ":" in date_s: if is_year == 2: thedate = datetime.datetime.strptime(date_s, '%d.%m.%Y %H:%S') else: thedate = datetime.datetime.strptime(date_s, '%d.%m %H:%S') thedate = thedate.replace(year=curr_day.year) else: if is_year == 2: thedate = datetime.datetime.strptime(date_s, '%d.%m.%Y') thedate = thedate.replace(hour=23, minute=59) else: thedate = datetime.datetime.strptime(date_s, '%d.%m') thedate = thedate.replace(year=curr_day.year) thedate = thedate.replace(hour=23, minute=59) data_list.append(thedate) deadlines_to_print[new] = "{}.{}.{} {}:{}".format( thedate.day, thedate.month, thedate.year, thedate.hour, thedate.minute) keyboard = types.ReplyKeyboardRemove(True) data3 = bot.send_message( message.from_user.id, 'Укажите важность по шкале 1-5, где 5 - наиболее важное дело.', reply_markup=keyboard) bot.register_next_step_handler(data3, add_data3)
def stop(message): remove = types.ReplyKeyboardRemove() user_id = message.chat.id def button(): types.ReplyKeyboardRemove() markup = types.ReplyKeyboardMarkup(one_time_keyboard=False, resize_keyboard=True) markup.add(start_str) return markup if message.chat.id in communications: user_to_id = communications[user_id]['UserTo'] bot.send_message(user_to_id, m_disconnect_user, reply_markup=search_stop()) delete_info(user_to_id) delete_user_from_db(user_id) bot.send_message(user_id, m_good_bye, reply_markup=button())
def default_test(message): if message.chat.id in states: if states[message.chat.id] == "selectingTask": if message.text == "Курс": hand(message, reply_markup=types.ReplyKeyboardRemove()) keyboard = types.InlineKeyboardMarkup() url_button = types.InlineKeyboardButton(text="coinmarketcap", url="https://coinmarketcap.com/") keyboard.add(url_button) bot.send_message(message.chat.id, "Нажми на кнопку и перейди на сайт,чтобы посмотреть курс валют.", reply_markup=keyboard) states[message.chat.id]="free"#сброс состояние обозначил как free elif message.text == "Описание монет": bot.send_message(message.chat.id,"Введи /coin и название интересующей тебя монеты. Например /coin Monero ") states[message.chat.id] = "free" elif message.text == "Новости": pass save_state(message.chat.id, "news") else: bot.send_message(message.chat.id,"Вы ввели неправильную команду. Введите /menu и отправьте. После чего выберите команду ")
def cmd_fold(message: types.Message): game = Game(message) if game.in_game and game.user_id in game.players: if game.users[str(game.user_id)].want_fold: game.fold() bot.delete_message(game.chat_id, game.message_id) markup = types.ReplyKeyboardRemove(selective=True) mention = game.gen_mention() bot.send_message(game.chat_id, f"<i>{mention} вышел из игры.</i>", reply_markup=markup, parse_mode="HTML", disable_notification=True) if len(game.players) == 1: game.end_of_game() else: game.delete_bot_messages() mention = game.gen_mention(game.who_move) msg = bot.send_message(game.chat_id, f"Игра продолжается. \n" f"{mention}, продолжай:", reply_markup=markup, parse_mode="HTML", disable_notification=True) game.messages_to_delete.append(msg.message_id) game.dump() else: game.users[str(game.user_id)].want_fold = True if game.can_move(): markup = game.gen_keyboard_in_game_selective() else: markup = gen_keyboard_in_game_for_any() mention = game.get_player_short_name() msg = bot.send_message(game.chat_id, f'{mention}, ты точно хочешь сдаться?\nОтправь еще раз "/fold" или "Сдаюсь"', reply_markup=markup, parse_mode="HTML", disable_notification=True) markup = game.gen_keyboard_in_game_selective() mention = game.gen_mention(game.who_move) msg2 = bot.send_message(game.chat_id, f"Игра продолжается. \n" f"{mention}, продолжай:", reply_markup=markup, parse_mode="HTML", disable_notification=True) game.messages_to_delete.extend([game.message_id, msg.message_id, msg2.message_id]) game.dump() else: bot.delete_message(game.chat_id, game.message_id)
def messages_handler(message): chat_id = message.chat.id if chat_id in user_step: if user_step[chat_id] == 'schedule_1': # return schedule by day user_step[chat_id] = 'schedule_2' bot.send_chat_action(chat_id, 'typing') parser = MPEIParser(config.phantom_driver_path) db = SQLightHelper(config.database) hide_board = types.ReplyKeyboardRemove() response = parser.get_by_day(db, check_user_group(chat_id), days.index(message.text) + 1, week=1) if not response: bot.send_message(message.chat.id, 'Расписание не найдено!', reply_markup=hide_board) else: bot.send_message(message.chat.id, response, reply_markup=hide_board) response = parser.get_by_day(db, check_user_group(chat_id), days.index(message.text) + 1, week=2) bot.send_message(message.chat.id, response) db.close() user_step[chat_id] = 0 elif user_step[chat_id] == 'init_group_1': # save user group db = SQLightHelper(config.database) db.save_user(message.chat.id, message.text) bot.send_message( message.chat.id, "Группа сохранена! Теперь можно получить свое расписание.") user_step[chat_id] = 0 else: bot.send_message(message.chat.id, "Неизвестная команда") else: bot.send_message(message.chat.id, "Неизвестная команда")
def process_phone_step(message): chat_id = message.chat.id user = user_dict[chat_id] markup = types.ReplyKeyboardRemove() text = (message.text or message.contact.phone_number[1:]) if not phone_number_validation(text)[0]: msg = bot.reply_to( message, 'Неверный формат номера телефона. Попробуй еще раз.') bot.register_next_step_handler(msg, process_phone_step) elif not phone_number_validation(text)[1]: msg = bot.reply_to( message, 'Такой номер телефона уже кем-то используется. Введи, пожалуйста другой.' ) bot.register_next_step_handler(msg, process_phone_step) else: user.phone = text user.status = user_status(user.phone) add_user_db(user) st = 'Поздравляю. Теперь ты зарегистрирован. В любое время напиши мне "/info" и я сообщу о твоей принадлежности рангу' msg = bot.reply_to(message, st, reply_markup=markup) bot.clear_step_handler_by_chat_id(user.chat_id)
def change_politeness_step2(message): global user_to_change print('user to change ', user_to_change) users = load_chat_users(chat_id=message.chat.id) user = User(user_id=users[user_to_change], chat_id=message.chat.id) user.check_if_user_exists() markup = types.ReplyKeyboardRemove() if message.text == 'Please be gentle, senpai!': user.change_politeness(politeness='polite') bot.send_message( message.chat.id, 'Great! We have finally established our relationship!', reply_markup=markup) elif message.text == 'Hurt me, daddy!': user.change_politeness(politeness='rude') bot.send_message( message.chat.id, 'So you enjoy suffering? Okay, but remember, you can say "stop-word" only once a month! ', reply_markup=markup) else: bot.send_message(message.chat.id, 'I am afraid that is not an option.') user_to_change = ""
def price(message): global dataPrice with open(fpath + 'files/data.dat', 'rb') as f: unpickler = pickle.Unpickler(f) dataPrice = unpickler.load() obl = list(dataPrice[language[str(message.from_user.id)]]) if not len(obl): bot.send_message(message.chat.id, config.text['verySorry'][language[str( message.from_user.id)]], reply_markup=types.ReplyKeyboardRemove()) start(message) return 0 fObl.obl = obl keyboard = types.ReplyKeyboardMarkup(resize_keyboard=True) a = login.findLoveCity(message.from_user.id, language[str(message.from_user.id)], cur) if len(a) != 0: cobl = config.text['selectAreaOrCity'][language[str( message.from_user.id)]] keyboard.add( *[types.KeyboardButton(name + u'\U0001F31F') for name in a]) fCity.lov = a else: fCity.lov = [] cobl = config.text['selectArea'][language[str(message.from_user.id)]] fObl.comands = obl[:] # fObl.comands.extend(a) # keyboard.add(*[types.KeyboardButton(name) for name in obl[:2]]) keyboard.add(*[types.KeyboardButton(name) for name in obl[2:]]) keyboard.add( types.KeyboardButton(config.text['home'][language[str( message.from_user.id)]])) obl = bot.send_message(message.chat.id, cobl, reply_markup=keyboard) bot.register_next_step_handler(obl, fObl) botan.track(config.botan_key, message.chat.id, message, 'Цена')
def check_answer(message): # if func returns None - user is out of the game answer = utils.get_answer_for_user(message.chat.id) # answer could be a text as well as None # if answer is None if not answer: bot.send_message(message.chat.id, 'Choose /game command to start the game') else: # closing keyboard with possible answers keyboard_hider = types.ReplyKeyboardRemove() # if answer right/wrong if message.text == answer: bot.send_message(message.chat.id, 'Right!', reply_markup=keyboard_hider) else: bot.send_message(message.chat.id, 'Sorry, that is wrong answer. Try again!', reply_markup=keyboard_hider) # removing user from shelve (game over) utils.finish_user_game(message.chat.id)
def check_answer(message): # Если функция возвращает None -> Человек не в игре answer = utils.get_answer_for_user(message.chat.id) # Как Вы помните, answer может быть либо текст, либо None # Если None: if not answer: bot.send_message(message.chat.id, 'Чтобы начать игру, выберите команду /game') else: # Уберем клавиатуру с вариантами ответа. keyboard_hider = types.ReplyKeyboardRemove() # Если ответ правильный/неправильный if message.text == answer: bot.send_message(message.chat.id, 'Верно!', reply_markup=keyboard_hider) else: bot.send_message(message.chat.id, 'Увы, Вы не угадали. Попробуйте ещё раз!', reply_markup=keyboard_hider) # Удаляем юзера из хранилища (игра закончена) utils.finish_user_game(message.chat.id)
def register(message): print(message.text) chat_id = message.chat.id if chat_id in need_login_student: need_login_student.remove(chat_id) if chat_id in need_login_operator: need_login_operator.remove(chat_id) markup = types.InlineKeyboardMarkup() button1 = types.InlineKeyboardButton(text='Я студент', callback_data='reg_student') button2 = types.InlineKeyboardButton(text='Я оператор', callback_data='reg_operator') markup.add(button1) markup.add(button2) bot.send_message(message.chat.id, '''Здравствуйте!''', reply_markup=types.ReplyKeyboardRemove()) bot.send_message(message.chat.id, '''Зарегестрируйтесь нажав на одну из этих кнопок:''', reply_markup=markup)
def timer_set(message): markup = types.ReplyKeyboardRemove() if message.text == "30秒" or message.text == "1分钟" or message.text == "2分钟" or message.text == "5分钟": bot.send_message(message.chat.id, "成功定时" + message.text + "!") elif message.text == "取消定时": bot.send_message(message.chat.id, "定时取消!") else: bot.send_message(message.chat.id, "参数错误!") if message.text == "30秒": time.sleep(30) bot.send_message(message.chat.id, "30秒到了!") elif message.text == "1分钟": time.sleep(60) bot.send_message(message.chat.id, "1分钟到了!") elif message.text == "2分钟": time.sleep(120) bot.send_message(message.chat.id, "2分钟到了!") elif message.text == "5分钟": time.sleep(300) bot.send_message(message.chat.id, "5分钟到了!")
def user_entering_namepoints(message): cur.execute( 'INSERT INTO viewpoints(name_points, latitude, longitude, location, foto, user_id) VALUES(%s, %s, %s, ST_SetSRID(ST_MakePoint(0.0, 0.0), 4326), %s, %s) RETURNING id;', (message.text, 0.000000, 0.00000, None, message.chat.id)) vp_id[0] = cur.fetchone()[0] con.commit() keyboard = types.ReplyKeyboardRemove() bot.send_message(message.chat.id, "Отличное место, запомню!", reply_markup=keyboard) keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True) button_geo = types.KeyboardButton(text=text_geo, request_location=True) keyboard.add(button_geo) bot.send_message(message.chat.id, "Теперь отправь, пожалуйста, геолокацию", reply_markup=keyboard) set_current_state(LOCATION, message.chat.id)