Exemple #1
0
def playlists(bot, update):
    bot.sendChatAction(chat_id=update.message.chat_id,
                       action=ChatAction.TYPING)
    if config.client() is not None:
        plays = config.client().listplaylists()
        buttons = []
        for playlist in plays:
            buttons.append(
                telegram.InlineKeyboardButton('🎵 %s' % playlist['playlist'],
                                              callback_data='mpd_list:%s' %
                                              playlist['playlist'])),
        update.message.reply_text(text='Choose playlist:',
                                  reply_markup=telegram.InlineKeyboardMarkup(
                                      Helper.build_menu(buttons, n_cols=2)))
Exemple #2
0
                                   Helper.list_get(sys.argv, 5, False)))
downloader = Downloader(config)

updates = {}

button_list = [
    telegram.InlineKeyboardButton("▶ Play", callback_data='mpd_play'),
    telegram.InlineKeyboardButton("⏸ Pause", callback_data='mpd_pause'),
    telegram.InlineKeyboardButton("🗃 All Playlists",
                                  callback_data='mpd_lists'),
    telegram.InlineKeyboardButton("🔊 Up +5", callback_data='mpd_up'),
    telegram.InlineKeyboardButton("🔇 Mute", callback_data='mpd_mute'),
    telegram.InlineKeyboardButton("🔉 Down -5", callback_data='mpd_down')
]
reply_markup = telegram.InlineKeyboardMarkup(
    Helper.build_menu(button_list, n_cols=3))


@run_async
def link(bot, update):
    text = str(update.message.text.encode('utf-8'))
    if _validate_link(text):
        updates.update({text: update})
        downloader.question(bot, update, text)


def _validate_link(text):
    regex_list = [
        r"^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$",
        r"^http(s?):\/\/soundcloud.com\/(.*)\/[a-zA-Z-0-9]+$"
    ]