Ejemplo n.º 1
0
def send_tracks(user_id, tracks):
    try:
        names = ds.track_name(tracks)
        lb = list_builder.ListBuilder(names)
        cb = list_builder.ListBuilder(['לחץ לרשימת השירים..'])
        cbq = cb.get_inline_list(callbacks=['inf on tracks'])
        message = bot.send_message(user_id,
                                   lb.get_numerated(),
                                   reply_markup=cbq)
        tracks_in_message[message.message_id] = []
        for i in range(len(tracks)):
            ds.track_info[tracks[i].id] = tracks[i]
            tracks_in_message[message.message_id].append(tracks[i].id)
    except Exception:
        print(traceback.format_exc())
Ejemplo n.º 2
0
def chart(message):
    try:
        user_id = message.from_user.id
        lb = list_builder.ListBuilder(
            list_builder.to_list_of_lists(ds.charts()))
        k = lb.get_keyboard()
        bot.send_message(user_id, 'Select chart', reply_markup=k)
        user_context[user_id] = ds.chart_id
    except Exception:
        print(traceback.format_exc())
Ejemplo n.º 3
0
def send_object_info(user_id, obj):
    if type(obj) == list:
        send_tracks(user_id, obj)
    else:
        user_context[user_id] = obj
        lb = list_builder.ListBuilder([ds.get_options(obj)])
        params = ds.get_parameter_list(obj)
        ans = []
        for p in params:
            ans.append(ds.get_parameter(obj, p))
        bot.send_message(user_id,
                         'no info' if len(ans) == 0 else '\n'.join(ans),
                         reply_markup=lb.get_keyboard())
Ejemplo n.º 4
0
def callback(cbq):
    ids = tracks_in_message[cbq.message.message_id]
    names = []
    for i in ids:
        names.append([ds.track_name(ds.track_info[i])[0]])
    lb = list_builder.ListBuilder(names)
    message = bot.send_message(cbq.from_user.id,
                               'Select track',
                               reply_markup=lb.get_keyboard())
    bot.register_next_step_handler(message,
                                   send_track_info,
                                   ids=ids,
                                   names=names)