playlist.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:ddmbot 作者: Budovi 项目源码 文件源码
def _peek(self, user_id, *, start=1, playlist_name=None):
        if start <= 0:
            raise dec.UserInputError('Start must be a positive number')
        # offset is start -1
        items, playlist_name, total = await self._db.show(user_id, start - 1, 20, playlist_name)

        if not items:
            if start == 1 or total == 0:
                await self._bot.whisper('**Playlist** {} **is empty**'.format(playlist_name))
            else:
                await self._bot.whisper(
                    '**There are no songs in the playlist** {} **, starting from the** {} **song**'
                    .format(playlist_name, self._ordinal(start)))
            return

        reply = '**{} song(s) (out of {}) from playlist** {}**, starting from the **{}**:**\n **>** ' \
                .format(len(items), total, playlist_name, self._ordinal(start)) + \
                '\n **>** '.join(['[{}] {}'.format(*item) for item in items])
        await self._bot.whisper(reply)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号