def send_cinema_soon_list(user): movies = get_movies( get_site_request_content( url=bot_config.cinema_url + bot_config.cinema_url_path_soon, params=bot_config.cinema_soon_params)) bot.send_message(chat_id=user.user_id, text=get_cinema_data_message(movies), parse_mode=ParseMode.HTML)
def geo_request(user): keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True) button_geo = types.KeyboardButton( text=f"{EMOJI_LOCATION} Send location", request_location=True) keyboard.add(button_geo) bot.send_message( user.user_id, f"{EMOJI_LOCATION} Hello! Click on the button and give me your location. {EMOJI_FINGER_DOWN}", reply_markup=keyboard)
def send_cinema_list(user): movies = get_movies( get_site_request_content( f"{bot_config.cinema_url}{bot_config.cinema_url_path_today}")) bot.send_message( chat_id=user.user_id, text=get_cinema_data_message(movies), reply_markup=get_message_keyboard( bot_config.button_cinema_soon), parse_mode=ParseMode.HTML)
def send_msg_alarm_currency(user): today_currency_rate, db_user_alarm_currency_rate = get_actual_currency_rate_for_alarm( user) bot.send_message( chat_id=user.user_id, text=MSG_CURRENCY_ALARM_BOT.format(today_rate=today_currency_rate, around_today_rate=round( db_user_alarm_currency_rate, 1)), reply_markup=get_message_keyboard(buttons_currency_alarm_rate), parse_mode=ParseMode.HTML)
def send_currency_rate(user, currency_id: int): actual_buttons_currency_selection = dict(buttons_currency_selection) del actual_buttons_currency_selection[currency_id] buttons = [button_currency_graph, actual_buttons_currency_selection] if currency_id == currency_dollar_id: buttons.append(button_currency_alarm) bot.send_message(chat_id=user.user_id, text=get_currency_message(currency_id), reply_markup=get_message_keyboard(*buttons), parse_mode=ParseMode.HTML)
def sent_virus_data(user): country = 'Belarus' logger().info("Get virus data for country '{}'".format(country)) country_all_data_virus = get_location_all_virus_covid_data_dir(country) country_actual_data_virus = get_last_virus_covid_data_dir( country, country_all_data_virus) world_actual_data_virus = get_last_virus_covid_data_dir() fetch_covid_graph(country_all_data_virus, country_actual_data_virus) bot.send_photo(chat_id=user.user_id, photo=open(covid_graph_path, 'rb')) bot.send_message( user.user_id, get_covid_virus_msg_content(country_actual_data_virus, world_actual_data_virus))
def send_to_user_insta_post_media_content(insta_post, user): fetch_insta_post_data(insta_post) bot.send_message(chat_id=user.user_id, reply_to_message_id=insta_post.message_id, text=MSG_INSTAGRAM_POST_CONTENT.format( insta_post.post_description, "\n".join([ MSG_HTML_LINK.format( link=link, title="Media {}".format(title)) for title, link in zip( range(1, len(insta_post.media_urls) + 1), insta_post.media_urls) ])), parse_mode=ParseMode.HTML)
def job(): users = DBConnector().get_db_users_alarm_currency_rate() for user in users: today_currency_rate = get_today_currency_rate() if today_currency_rate >= user['alarm_rate']: actual_buttons_currency_selection = dict( bot_config.buttons_currency_selection) del actual_buttons_currency_selection[ bot_config.currency_dollar_id] bot.send_message(chat_id=user['id'], text=f""" <b>Currency Alarm</b> {get_currency_message(bot_config.currency_dollar_id)}""", reply_markup=get_message_keyboard( bot_config.button_currency_graph, actual_buttons_currency_selection, bot_config.button_currency_alarm), parse_mode=ParseMode.HTML)
def send_map_location(bot, user, message): wait_message = bot.send_message( chat_id=user.user_id, reply_to_message_id=message.message_id, text="Data processing may take up to 15 seconds. Please wait.") geo = Geo( message.location.latitude, message.location.longitude, location_atm) fetch_map(geo) map_message = bot.send_photo(chat_id=user.user_id, reply_to_message_id=message.message_id, photo=open(geo.screen_path, 'rb')) bot.delete_message(chat_id=user.user_id, message_id=wait_message.message_id) bot.send_message( chat_id=user.user_id, reply_to_message_id=map_message.message_id, text=MSG_LOCATION_MAP.format(link=geo.geo_map_url), parse_mode=ParseMode.HTML)
def start_step(user): bot.send_message( chat_id=user.user_id, text=MSG_START_CMD_BASE)
def instagram_start(message): user = User.get_user(user_id=message.chat.id) bot.send_message(user.user_id, MSG_INSTAGRAM_BOT) DBConnector().insert_analytics(user, message.text)
def sent_football_message(user, message, buttons, parse_mode=None): bot.send_message( chat_id=user.user_id, text=message, reply_markup=buttons, parse_mode=parse_mode)