timercommands.py 文件源码

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

项目:PomodoroBot 作者: VicenteRD 项目源码 文件源码
def toggle_countdown(self, ctx: commands.Context, toggle=None):
        """ Turns the timer's countdown setting on or off. If no state is
            specified, it will toggle it

        :param toggle: True, yes or on to turn the setting on. False, no or off
            to turn the setting off. If not specified, or None is given,
             it will toggle the setting.
        """
        author = ctx.message.author
        channel = self.bot.spoof(author, lib.get_channel(ctx))
        interface = self.bot.get_interface(channel)
        timer = interface.timer

        toggle = lib.to_boolean(toggle)
        if timer.countdown == toggle:
            return  # No need to edit it if it's the same.
        timer.toggle_countdown(toggle)

        await self.bot.edit_message(interface.time_message, timer.time())
        await self.bot.say("Successfully toggled the countdown setting {}!"
                           .format("on" if timer.countdown else "off"),
                           delete_after=self.bot.ans_lifespan)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号