Esempio n. 1
0
async def choose_song(bot, ev):
    key = f'{ev.group_id}-{ev.user_id}'
    if key not in temp:
        if str(ev.group_id) in last_check and datetime.datetime.now(
        ) - last_check[str(ev.group_id)] < expire:
            await bot.send(ev, '不可以替他人选歌哦', at_sender=True)
        return
    song_dict = temp[key]
    song_idx = []
    for msg_seg in ev.message:
        if msg_seg.type == 'text' and msg_seg.data['text']:
            song_idx.append(msg_seg.data['text'].strip())
    if not song_idx:
        await bot.send(ev, '你想听什么呀?', at_sender=True)
    else:
        song_idx = ''.join(song_idx)
        for idx in song_idx:
            if idx in song_dict:
                song = song_dict[idx]
                if song['type'] == '163':
                    music = MessageSegment.music(song['type'], song['id'])
                elif song['type'] == 'custom':
                    music = MessageSegment(type_='music', data=song)
                else:
                    music = MessageSegment(type_='music',
                                           data={
                                               'id': str(song['id']),
                                               'type': song['type'],
                                               'content': song['artists']
                                           })
                await bot.send(ev, music)
        del temp[key]
        del last_check[str(ev.group_id)]
Esempio n. 2
0
async def diansong(bot, event):
    msg = event.message.extract_plain_text().strip()
    if not msg:
        await bot.send(event, '歌名都没有你点个锤子噢')
        return
    mid = query(msg)
    if isinstance(mid, int) is False:
        await bot.send(event, id)
        return
    music = MessageSegment.music(type_='163', id_=mid)
    sv.logger.info(f'{music}')
    await bot.send(event, music)
Esempio n. 3
0
async def choose_song(bot, ev):
    key = f'{ev.group_id}-{ev.user_id}'
    if key not in temp:
        await bot.send(ev, '你还没有点歌呢!', at_sender=True)
        return
    song_dict = temp[key]
    song_idx = []
    for msg_seg in ev.message:
        if msg_seg.type == 'text' and msg_seg.data['text']:
            song_idx.append(msg_seg.data['text'].strip())
    if not song_idx:
        await bot.send(ev, '你想听什么呀?', at_sender=True)
    else:
        song_idx = ''.join(song_idx)
        if song_idx in song_dict:
            song = song_dict[song_idx]
            music = MessageSegment.music(song['type'], song['id'])
            del temp[key]
            await bot.send(ev, music)
        else:
            await bot.send(ev, '只能选择列表中有的歌曲哦', at_sender=True)
            return