Exemple #1
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)
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)
Exemple #3
0
def refresh_chart(update: Update, context: CallbackContext):
    print("refreshing chart")
    query = update.callback_query.data

    k_hours = int(re.search(r'\d+', query.split('h:')[1]).group())
    k_days = int(re.search(r'\d+', query.split('d:')[1]).group())
    token = query.split('t:')[1]

    t_to = int(time.time())
    t_from = t_to - (k_days * 3600 * 24) - (k_hours * 3600)

    banner_txt = util.get_banner_txt(zerorpc_client_data_aggregator)

    chat_id = update.callback_query.message.chat_id
    message_id = update.callback_query.message.message_id

    (message, path,
     reply_markup_chart) = general_end_functions.send_candlestick_pyplot(
         token, charts_path, k_days, k_hours, t_from, t_to, banner_txt)
    context.bot.send_photo(chat_id=chat_id,
                           photo=open(path, 'rb'),
                           caption=message,
                           parse_mode="html",
                           reply_markup=reply_markup_chart)
    context.bot.delete_message(chat_id=chat_id, message_id=message_id)
Exemple #4
0
def get_candlestick(context: CallbackContext):

    rand = random.randint(0, 10)

    t_to = int(time.time())
    if rand > 5:
        t_from = t_to - 3600 * 24
        k_hours, k_days = 0, 1
        options = None
    else:
        t_from = t_to - 3600 * 6
        k_hours, k_days = 6, 0
        options = None

    trending = util.get_banner_txt(zerorpc_client_data_aggregator)

    for channel in get_my_channels():
        if _should_send(channel):
            (message, path, reply_markup_chart
             ) = general_end_functions.send_candlestick_pyplot(channel.ticker,
                                                               charts_path,
                                                               k_days,
                                                               k_hours,
                                                               t_from,
                                                               t_to,
                                                               txt=trending,
                                                               options=options)

            context.bot.send_photo(chat_id=channel.channel_id,
                                   photo=open(path, 'rb'),
                                   caption=message,
                                   parse_mode="html")