Documentation ¶
Overview ¶
Package core contains bot functionality for iris. Currently following Pomodoro technique.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ClientID, _ = configparser.Register("iris.clientid", "ClientID of the bot", nil)
ClientSecrets, _ = configparser.Register("iris.clientsecret", "ClientSecret of the bot", nil)
BotToken, _ = configparser.Register("iris.authtoken", "authentication token of the bot", nil)
CmdPrefix, _ = configparser.Register("iris.cmdprefix", "prefix for iris", "/i ")
Loaded = false
// VERSION is defined via git.
VERSION = "unknown"
IrisSession *discordgo.Session
IrisUser *discordgo.User
)
TODO: add options to check for valid configuration name.
Functions ¶
Types ¶
type Iris ¶
type Iris struct {
// contains filtered or unexported fields
}
Iris defines the structure for the bot's functionality.
type NotifyInfo ¶
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 NewPom ¶
func NewPom(workDuration time.Duration, onWorkEnd TaskCallback, notify NotifyInfo) *Pomodoro
NewPom create a new pomodoro and start it using time.NewTimer. onWorkEnd will be called after the goroutine.
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.