deprecatedrunner

package
v0.0.0-...-99e36ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package deprecatedrunner contains v1 bot functionality, deprecated in next update.

Package pomodoro defines our pomodoro logics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iris

type Iris struct {
	// contains filtered or unexported fields
}

Iris defines the structure for the bots' functionality.

func New

func New() *Iris

New creates a new instance of Iris that can deploy over Heroku.

func (*Iris) Start

func (ir *Iris) Start() error

Start will start the bot, blocking til completed.

type NotifyInfo

type NotifyInfo struct {
	TitleID string
	User    *database.User
}

NotifyInfo defines notification message for users.

type Pomodoro

type Pomodoro struct {
	// contains filtered or unexported fields
}

Pomodoro defines a single state of a pomodoro sessions. Usage of channel to handle cancel signal.

func NewPomodoro

func NewPomodoro(workDuration time.Duration, onWorkEnd TaskCallback, notify NotifyInfo) *Pomodoro

NewPomodoro create a new pomodoro and start it using time.NewTimer. onWorkEnd will be called after the goroutine.

func (*Pomodoro) Cancel

func (pom *Pomodoro) Cancel()

Cancel is used to cancel the current state of the goroutine. sync.Once to prevent panic.

type TaskCallback

type TaskCallback func(info NotifyInfo, finished bool)

TaskCallback receives NotifyInfo and a boolean to define whether the task is completed or not.

type UserPomodoroMap

type UserPomodoroMap struct {
	// contains filtered or unexported fields
}

UserPomodoroMap is a map-like structure to init a single pomodoro in a channel. It has goroutine safe ops.

func NewUserPomodoroMap

func NewUserPomodoroMap() UserPomodoroMap

NewUserPomodoroMap creates a ChannelPomMap and prepares it to be used.

func (*UserPomodoroMap) Count

func (u *UserPomodoroMap) Count() int

Count counts the number of current Pomodoro being tracked.

func (*UserPomodoroMap) CreateIfEmpty

func (u *UserPomodoroMap) CreateIfEmpty(duration time.Duration, onWorkEnd TaskCallback, notify NotifyInfo) bool

CreateIfEmpty will create a new Pomodoro for given user according to their discordID if user has none. The pomodoro will then be removed from the mapping once completed or canceled.

func (*UserPomodoroMap) RemoveIfExists

func (u *UserPomodoroMap) RemoveIfExists(discordID string) bool

RemoveIfExists will remove a Pomodoro from given channel i one already exists.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL