Esempio n. 1
0
def get_chart_supply(update: Update, context: CallbackContext):
    chat_id = update.message.chat_id

    query_received = update.message.text.split(' ')

    time_type, k_hours, k_days, tokens = commands_util.check_query(
        query_received, ticker)

    current_boob_nbr, current_ecto_nbr = general_end_functions.send_supply_two_pyplot(
        supply_file_path, k_days, k_hours, "BOOB", "ECTO", supply_chart_path)

    current_boob_str = util.number_to_beautiful(current_boob_nbr)
    current_ecto_str = util.number_to_beautiful(current_ecto_nbr)

    msg_time = " " + str(
        k_days) + " day(s) " if k_days > 0 else " last " + str(
            k_hours) + " hour(s) "

    caption = "Supply of the last " + msg_time + ".\nCurrent supply: \n<b>BOOB:</b> <pre>" + current_boob_str + \
              "</pre> \n<b>ECTO:</b> <pre>" + current_ecto_str + "</pre>"

    context.bot.send_photo(chat_id=chat_id,
                           photo=open(supply_chart_path, 'rb'),
                           caption=caption,
                           parse_mode="html")
Esempio n. 2
0
def get_candlestick(update: Update, context: CallbackContext):
    chat_id = update.message.chat_id

    query_received = update.message.text.split(' ')

    time_type, k_hours, k_days, tokens = commands_util.check_query(
        query_received, ticker)
    t_to = int(time.time())
    t_from = t_to - (k_days * 3600 * 24) - (k_hours * 3600)

    if isinstance(tokens, list):
        for token in tokens:
            (message, path, reply_markup_chart
             ) = general_end_functions.send_candlestick_pyplot(
                 token, charts_path, k_days, k_hours, t_from, t_to)
            context.bot.send_photo(chat_id=chat_id,
                                   photo=open(path, 'rb'),
                                   caption=message,
                                   parse_mode="html",
                                   reply_markup=reply_markup_chart)
    else:
        (message, path,
         reply_markup_chart) = general_end_functions.send_candlestick_pyplot(
             tokens, charts_path, k_days, k_hours, t_from, t_to)
        context.bot.send_photo(chat_id=chat_id,
                               photo=open(path, 'rb'),
                               caption=message,
                               parse_mode="html",
                               reply_markup=reply_markup_chart)
Esempio n. 3
0
def get_candlestick(update: Update, context: CallbackContext):
    chat_id = update.message.chat_id

    query_received = update.message.text.split(' ')
    default_default_token = default_token
    if len(query_received) == 1:
        channel_token = __get_default_token_channel(chat_id)
        if channel_token is not None:
            default_default_token = channel_token[0]
        else:
            context.bot.send_message(chat_id=chat_id,
                                     text=rejection_no_default_ticker_message)
            pass

    time_type, k_hours, k_days, tokens = commands_util.check_query(
        query_received, default_default_token)
    t_to = int(time.time())
    t_from = t_to - (k_days * 3600 * 24) - (k_hours * 3600)
    trending = util.get_banner_txt(zerorpc_client_data_aggregator)

    if isinstance(tokens, list):
        for token in tokens:
            (message, path, reply_markup_chart
             ) = general_end_functions.send_candlestick_pyplot(token,
                                                               charts_path,
                                                               k_days,
                                                               k_hours,
                                                               t_from,
                                                               t_to,
                                                               txt=trending)
            util.create_and_send_vote(token, "chart",
                                      update.message.from_user.name,
                                      zerorpc_client_data_aggregator)
            context.bot.send_photo(chat_id=chat_id,
                                   photo=open(path, 'rb'),
                                   caption=message,
                                   parse_mode="html",
                                   reply_markup=reply_markup_chart)
    else:
        (message, path,
         reply_markup_chart) = general_end_functions.send_candlestick_pyplot(
             tokens, charts_path, k_days, k_hours, t_from, t_to, txt=trending)
        util.create_and_send_vote(tokens, "chart",
                                  update.message.from_user.name,
                                  zerorpc_client_data_aggregator)
        context.bot.send_photo(chat_id=chat_id,
                               photo=open(path, 'rb'),
                               caption=message,
                               parse_mode="html",
                               reply_markup=reply_markup_chart)