Archived
1

Refactoring: now we respect gofmt and have some comments

This commit is contained in:
2017-10-18 09:39:50 +04:00
parent 6f374e560e
commit 8dab6c0699
47 changed files with 607 additions and 479 deletions

View File

@@ -18,6 +18,7 @@ import (
"../talkers/talkersinterface"
)
// Context is an application context struct
type Context struct {
Cfg *config.Config
Bot *tgbotapi.BotAPI
@@ -29,6 +30,7 @@ type Context struct {
Getters gettersinterface.GettersInterface
}
// Init is a initialization function for context
func (c *Context) Init() {
c.Cfg = config.New()
c.Cfg.Init()
@@ -36,28 +38,34 @@ func (c *Context) Init() {
c.Db = connections.DBInit(c.Cfg)
}
// RegisterRouterInterface registering router interface in application
func (c *Context) RegisterRouterInterface(ri routerinterface.RouterInterface) {
c.Router = ri
c.Router.Init()
}
// RegisterMigrationsInterface registering migrations interface in application
func (c *Context) RegisterMigrationsInterface(mi migrationsinterface.MigrationsInterface) {
c.Migrations = mi
c.Migrations.Init()
}
// RegisterParsersInterface registering parsers interface in application
func (c *Context) RegisterParsersInterface(pi parsersinterface.ParsersInterface) {
c.Parsers = pi
}
// RegisterTalkersInterface registering talkers interface in application
func (c *Context) RegisterTalkersInterface(ti talkersinterface.TalkersInterface) {
c.Talkers = ti
}
// RegisterGettersInterface registering getters interface in application
func (c *Context) RegisterGettersInterface(gi gettersinterface.GettersInterface) {
c.Getters = gi
}
// RunDatabaseMigrations applies migrations on bot's startup
func (c *Context) RunDatabaseMigrations() {
c.Migrations.SetDialect("mysql")
c.Migrations.Migrate()

View File

@@ -7,6 +7,7 @@ var (
a *Context
)
// New is a Context creation function
func New() *Context {
c := &Context{}
return c