Archived
1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
i2_bot/lib/appcontext/appcontext.go

35 lines
707 B
Go
Raw Normal View History

2017-10-04 17:56:18 +04:00
// 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()
}