2016-03-19 19:32:51 +00:00
|
|
|
// © 2016 the CatBase Authors under the WTFPL license. See AUTHORS for the list of authors.
|
|
|
|
|
2016-03-10 18:37:07 +00:00
|
|
|
package bot
|
|
|
|
|
2016-03-30 14:00:20 +00:00
|
|
|
import (
|
|
|
|
"github.com/jmoiron/sqlx"
|
2016-04-01 14:20:03 +00:00
|
|
|
"github.com/velour/catbase/bot/msg"
|
|
|
|
"github.com/velour/catbase/bot/user"
|
2016-03-30 14:00:20 +00:00
|
|
|
"github.com/velour/catbase/config"
|
|
|
|
)
|
|
|
|
|
2019-02-05 15:54:13 +00:00
|
|
|
const (
|
|
|
|
_ = iota
|
|
|
|
|
|
|
|
// Message any standard chat
|
|
|
|
Message
|
|
|
|
// Reply something containing a message reference
|
|
|
|
Reply
|
|
|
|
// Action any /me action
|
|
|
|
Action
|
|
|
|
// Reaction Icon reaction if service supports it
|
|
|
|
Reaction
|
|
|
|
// Edit message ref'd new message to replace
|
|
|
|
Edit
|
|
|
|
// Not sure what event is
|
|
|
|
Event
|
|
|
|
// Help is used when the bot help system is triggered
|
|
|
|
Help
|
|
|
|
// SelfMessage triggers when the bot is sending a message
|
|
|
|
SelfMessage
|
|
|
|
)
|
|
|
|
|
|
|
|
type kind int
|
|
|
|
|
|
|
|
type Callback func(int, msg.Message, ...interface{}) bool
|
|
|
|
|
2016-03-30 14:00:20 +00:00
|
|
|
type Bot interface {
|
|
|
|
Config() *config.Config
|
|
|
|
DB() *sqlx.DB
|
2016-04-01 14:20:03 +00:00
|
|
|
Who(string) []user.User
|
2019-02-05 15:54:13 +00:00
|
|
|
AddPlugin(string, Plugin)
|
|
|
|
|
|
|
|
// First arg should be one of bot.Message/Reply/Action/etc
|
|
|
|
Send(int, ...interface{}) (error, string)
|
|
|
|
// First arg should be one of bot.Message/Reply/Action/etc
|
|
|
|
Receive(int, msg.Message, ...interface{})
|
|
|
|
// Register a callback
|
|
|
|
Register(int, Callback)
|
|
|
|
|
2016-04-01 14:20:03 +00:00
|
|
|
Filter(msg.Message, string) string
|
|
|
|
LastMessage(string) (msg.Message, error)
|
2019-02-05 15:54:13 +00:00
|
|
|
|
2016-04-01 14:20:03 +00:00
|
|
|
CheckAdmin(string) bool
|
2017-07-24 19:09:27 +00:00
|
|
|
GetEmojiList() map[string]string
|
2017-09-29 04:58:21 +00:00
|
|
|
RegisterFilter(string, func(string) string)
|
2016-03-30 14:00:20 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 18:37:07 +00:00
|
|
|
type Connector interface {
|
2016-04-01 14:20:03 +00:00
|
|
|
RegisterEventReceived(func(message msg.Message))
|
|
|
|
RegisterMessageReceived(func(message msg.Message))
|
2017-10-31 18:14:45 +00:00
|
|
|
RegisterReplyMessageReceived(func(msg.Message, string))
|
2016-03-10 18:37:07 +00:00
|
|
|
|
2019-02-05 15:54:13 +00:00
|
|
|
Send(int, ...interface{}) (error, string)
|
|
|
|
|
2017-07-24 19:09:27 +00:00
|
|
|
GetEmojiList() map[string]string
|
2017-09-07 04:32:53 +00:00
|
|
|
Serve() error
|
2016-04-21 15:19:38 +00:00
|
|
|
|
|
|
|
Who(string) []string
|
2016-03-10 18:37:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Interface used for compatibility with the Plugin interface
|
2019-02-05 15:54:13 +00:00
|
|
|
type Plugin interface {
|
2016-03-10 18:37:07 +00:00
|
|
|
RegisterWeb() *string
|
|
|
|
}
|