예제 #1
0
 def send_currency_alarm_message(message):
     bot.edit_message_text(
         chat_id=call.message.chat.id,
         message_id=call.message.message_id,
         text=message,
         reply_markup=get_message_keyboard(buttons_currency_alarm_rate),
         parse_mode=ParseMode.HTML)
예제 #2
0
def football_start(message):
    user = User.get_user(user_id=message.chat.id)

    sent_football_message(
        user, MSG_FOOTBALL_BASE_CMD,
        get_message_keyboard(*[{
            k: v
        } for (k, v) in bot_config.buttons_football_leagues.items()]))
    DBConnector().insert_analytics(user, message.text)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
def send_football_calendar(user, football_league):
    matches = get_matches(get_site_request_content(
        url=f"{bot_config.football_url}{football_league}{bot_config.football_url_path_calendar}"))

    actual_buttons_football = {
        **bot_config.buttons_football_leagues}  # new dict instance
    football_message_title = actual_buttons_football.pop(football_league)
    message = f"""<b>{football_message_title}</b>

    {get_football_data_message(matches)}"""
    sent_football_message(
        user, message, get_message_keyboard(
            *actual_buttons_football, ParseMode.HTML))
예제 #7
0
def football_country_leagues(call):
    logger().info("Button '{}'".format(call.data))
    user = User.get_user(user_id=call.from_user.id)

    actual_buttons_football = {
        **bot_config.buttons_football_country_leagues
    }  # new dict instance

    sent_football_message(
        user, MSG_FOOTBALL_BASE_CMD,
        get_message_keyboard(*[{
            k: v
        } for (k, v) in actual_buttons_football.items()]))
    DBConnector().insert_analytics(user, call.data)
예제 #8
0
def send_currency_graph(user, bot_message):
    actual_currency = list(
        set(currency_ids) - set([
            currency_data['callback_data'] for currency_data in
            bot_message.json['reply_markup']['inline_keyboard'][1]
        ]))[0]

    currency_data_bot = fetch_currency_list(
        get_currency_response_json(actual_currency))
    fetch_currency_graph(currency_data_bot)

    actual_buttons_currency_selection = dict(buttons_currency_selection)
    del actual_buttons_currency_selection[actual_currency]

    bot.send_photo(
        chat_id=user.user_id,
        reply_markup=get_message_keyboard(actual_buttons_currency_selection),
        photo=open(currency_graph_path, 'rb'))
예제 #9
0
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)