mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
36 lines
628 B
Go
36 lines
628 B
Go
|
package chat
|
||
|
|
||
|
import (
|
||
|
"github.com/demodesk/neko/pkg/types"
|
||
|
)
|
||
|
|
||
|
type Plugin struct {
|
||
|
config *Config
|
||
|
manager *Manager
|
||
|
}
|
||
|
|
||
|
func NewPlugin() *Plugin {
|
||
|
return &Plugin{
|
||
|
config: &Config{},
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (p *Plugin) Name() string {
|
||
|
return PluginName
|
||
|
}
|
||
|
|
||
|
func (p *Plugin) Config() types.PluginConfig {
|
||
|
return p.config
|
||
|
}
|
||
|
|
||
|
func (p *Plugin) Start(m types.PluginManagers) error {
|
||
|
p.manager = NewManager(m.SessionManager, p.config)
|
||
|
m.ApiManager.AddRouter("/chat", p.manager.Route)
|
||
|
m.WebSocketManager.AddHandler(p.manager.WebSocketHandler)
|
||
|
return p.manager.Start()
|
||
|
}
|
||
|
|
||
|
func (p *Plugin) Shutdown() error {
|
||
|
return p.manager.Shutdown()
|
||
|
}
|