Pomodoro timer made with Errbot

Why did you make it

Suddenly I wanted to make it (when asked if I would use it, I might not use it?)

contents

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)

Such a behavior memo

Function call in scheduling

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.

The main body logic is just a counter check

Other

By all means, it's for one person, so I'm making a multiplayer version because it's a big deal

Recommended Posts

Pomodoro timer made with Errbot
I made a rigid Pomodoro timer that works with CUI
Container-like # 1 made with C
Container-like # 2 made with C
I made blackjack with python!
SNS Flask (Ajax) made with Flask
I made COVID19_simulator with JupyterLab
I made Word2Vec with Pytorch
I made blackjack with Python.
Othello made with python (GUI-like)
I made wordcloud with Python.
Make Slack chatbot with Errbot
SNS Flask (Model) edition made with Flask
SNS Python basics made with Flask
Easy Slackbot with Docker and Errbot
Numer0n with items made in Python
I made a fortune with Python.
Twitter posting application made with Django
Othello game development made with Python
SNS made with Flask Flask (Blueprint, bcrypt)
Introduce errBot and work with Slack
Twitter search client made with bottle
I made a daemon with Python