Compentize Workload (#4)
This commit is contained in:
22
common/component.go
Normal file
22
common/component.go
Normal file
@ -0,0 +1,22 @@
|
||||
package common
|
||||
|
||||
type Component interface {
|
||||
Initialize(birdbot ComponentManager) error
|
||||
}
|
||||
|
||||
type ComponentManager interface {
|
||||
OnReady(func() error) error
|
||||
|
||||
OnNotify(func(string) error) error
|
||||
|
||||
// Event events
|
||||
OnEventCreate(func(Event) error) error
|
||||
OnEventDelete(func(Event) error) error
|
||||
OnEventUpdate(func(Event) error) error
|
||||
OnEventComplete(func(Event) error) error
|
||||
|
||||
RegisterGameModule(ID string, plugin GameModule) error
|
||||
|
||||
CreateEvent(event Event) error
|
||||
Notify(message string) error
|
||||
}
|
18
common/event.go
Normal file
18
common/event.go
Normal file
@ -0,0 +1,18 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Event struct {
|
||||
Name string
|
||||
ID string
|
||||
Location string
|
||||
Completed bool
|
||||
DateTime time.Time
|
||||
CompleteDateTime time.Time
|
||||
Description string
|
||||
ImageURL string
|
||||
|
||||
Organizer User
|
||||
}
|
6
common/game_plugin.go
Normal file
6
common/game_plugin.go
Normal file
@ -0,0 +1,6 @@
|
||||
package common
|
||||
|
||||
type GameModule interface {
|
||||
SendMessage(user string, message string)
|
||||
RecieveMessage(user User, message string)
|
||||
}
|
18
common/user.go
Normal file
18
common/user.go
Normal file
@ -0,0 +1,18 @@
|
||||
package common
|
||||
|
||||
import "fmt"
|
||||
|
||||
type User struct {
|
||||
ID string
|
||||
AvatarURL string
|
||||
DisplayName string
|
||||
}
|
||||
|
||||
// DiscordMention generated a Discord mention string for the user
|
||||
func (user *User) DiscordMention() string {
|
||||
if user == nil {
|
||||
return "<NULL>"
|
||||
}
|
||||
|
||||
return fmt.Sprintf("<@%s>", user.ID)
|
||||
}
|
Reference in New Issue
Block a user