Archived
1

Work on squads, some refactoring

Closes #14
See #8
This commit is contained in:
2017-11-19 22:16:11 +04:00
parent 95a9a2146a
commit e4102e9a90
26 changed files with 587 additions and 112 deletions

View File

@@ -6,6 +6,7 @@ package appcontext
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/jmoiron/sqlx"
"lab.pztrn.name/fat0troll/i2_bot/lib/chatter/chatterinterface"
"lab.pztrn.name/fat0troll/i2_bot/lib/config"
"lab.pztrn.name/fat0troll/i2_bot/lib/connections"
"lab.pztrn.name/fat0troll/i2_bot/lib/forwarder/forwarderinterface"
@@ -14,6 +15,7 @@ import (
"lab.pztrn.name/fat0troll/i2_bot/lib/parsers/parsersinterface"
"lab.pztrn.name/fat0troll/i2_bot/lib/pinner/pinnerinterface"
"lab.pztrn.name/fat0troll/i2_bot/lib/router/routerinterface"
"lab.pztrn.name/fat0troll/i2_bot/lib/squader/squaderinterface"
"lab.pztrn.name/fat0troll/i2_bot/lib/talkers/talkersinterface"
"lab.pztrn.name/fat0troll/i2_bot/lib/welcomer/welcomerinterface"
"lab.pztrn.name/golibs/mogrus"
@@ -34,6 +36,8 @@ type Context struct {
Getters gettersinterface.GettersInterface
Welcomer welcomerinterface.WelcomerInterface
Pinner pinnerinterface.PinnerInterface
Chatter chatterinterface.ChatterInterface
Squader squaderinterface.SquaderInterface
}
// Init is a initialization function for context
@@ -106,6 +110,18 @@ func (c *Context) RegisterForwarderInterface(fi forwarderinterface.ForwarderInte
c.Forwarder.Init()
}
// RegisterChatterInterface registers chatter interface in application
func (c *Context) RegisterChatterInterface(ci chatterinterface.ChatterInterface) {
c.Chatter = ci
c.Chatter.Init()
}
// RegisterSquaderInterface registers squader interface in application
func (c *Context) RegisterSquaderInterface(si squaderinterface.SquaderInterface) {
c.Squader = si
c.Squader.Init()
}
// RunDatabaseMigrations applies migrations on bot's startup
func (c *Context) RunDatabaseMigrations() {
c.Migrations.SetDialect("mysql")