Archived
1

Initial commit

This commit is contained in:
Vladimir Hodakov
2017-10-04 17:56:18 +04:00
commit 4fec8f0fe7
14 changed files with 449 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package appcontext
import (
// 3rd-party
"github.com/jmoiron/sqlx"
"gopkg.in/telegram-bot-api.v4"
// local
"../config"
"../connections"
// interfaces
"../router/routerinterface"
)
type Context struct {
Cfg *config.Config
Bot *tgbotapi.BotAPI
Router routerinterface.RouterInterface
Db *sqlx.DB
}
func (c *Context) Init() {
c.Cfg = config.New()
c.Cfg.Init()
c.Bot = connections.BotInit(c.Cfg)
c.Db = connections.DBInit(c.Cfg)
}
func (c *Context) RegisterRouterInterface(ri routerinterface.RouterInterface) {
c.Router = ri
c.Router.Init()
}

View File

@@ -0,0 +1,13 @@
// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package appcontext
var (
a *Context
)
func New() *Context {
c := &Context{}
return c
}