예제 #1
0
async def default(chat, message):
    info = message['text'].split(' .')

    if len(info) != 2:
        musicInfo, bitrate = info[0], ''
    else:
        musicInfo, bitrate = info

    if bitrate not in ['128', '192', '320']:
        chat.send_text('音質錯誤!將音質設為 320kbps。')
        await log("{} 輸入了錯誤的音質。".format(chat.sender))
        bitrate = '320'

    musicId = getMusicId(musicInfo)
    if not musicId.isnumeric():
        chat.send_text('輸入錯誤,無法解析!')
        await log("{} 的查詢發生了未知的錯誤。".format(chat.sender))
        return

    musicJson = await search_tracks(musicId, bitrate)
    musicArtist = getArtist(musicJson)
    musicInfoMD = "曲名:{}\n歌手:{}\n\n[解析網址]({})".format(musicJson['song']['name'], musicArtist['markdown'], musicJson['URL'])

    await log("{} 查詢了 {}kbps 的 {} - {}".format(chat.sender, bitrate, musicArtist['text'], musicJson['song']['name']))

    await chat.reply(musicInfoMD, parse_mode='Markdown')
    await chat.send_audio(audio=musicJson['URL'], title=musicJson['song']['name'], performer=musicArtist['text'])
    return
예제 #2
0
def usage(chat, match):
    return chat.send_text(help, parse_mode='Markdown')
예제 #3
0
def usage(chat, match):
    return chat.send_text(greeting, parse_mode='Markdown')