Suddenly I wanted to make it (when asked if I would use it, I might not use it?)
pomodoro.py
# -*- coding:utf8 -*-
from __future__ import division, print_function, absolute_import
"""Pomodoro timer
"""
from errbot import BotPlugin, botcmd
class Pomodoro(BotPlugin):
def __init__(self, bot):
super().__init__(bot)
self._timer = [None, None]
def activate(self):
super().activate()
self.start_poller(60, self.pomodoro)
def pomodoro(self):
time_counter = self._timer[0]
target = self._timer[1]
if time_counter is None:
return
time_counter += 1
if time_counter >= 25:
time_counter = -5
self.send(target, "5 minutes break")
elif time_counter == 0:
self.send(target, "25 minutes intensive")
self._timer[0] = time_counter
@botcmd(name='pomodoro_start')
def start(self, msg, args):
self._timer = [0, msg.frm]
return 'Timer on'
@botcmd(name='pomodoro_stop')
def stop(self, msg, args):
self._timer = [None, None]
return 'Timer off'
Click here for installation (Slightly adjusted for publication)
! Pomodoro_start
.! Pomodoro_stop
As I wrote earlier, Errbot can call functions at regular intervals by using start_poller ()
.
Set the timer on / off aside, and let the logic of the main unit work every minute for the time being.
None
By all means, it's for one person, so I'm making a multiplayer version because it's a big deal
Recommended Posts