Move bot config to separate struct.
This commit is contained in:
parent
aa0cdf3719
commit
1b1af39b61
8 changed files with 353 additions and 286 deletions
42
bot_config.go
Normal file
42
bot_config.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package tgbotapi
|
||||
|
||||
type BotConfigI interface {
|
||||
GetApiEndpoint() string
|
||||
GetToken() string
|
||||
GetDebug() bool
|
||||
}
|
||||
|
||||
type BotConfig struct {
|
||||
token string
|
||||
debug bool
|
||||
|
||||
apiEndpoint string
|
||||
}
|
||||
|
||||
func NewBotConfig(token, apiEndpoint string, debug bool) *BotConfig {
|
||||
return &BotConfig{
|
||||
token: token,
|
||||
debug: debug,
|
||||
apiEndpoint: apiEndpoint,
|
||||
}
|
||||
}
|
||||
|
||||
func NewDefaultBotConfig(token string) *BotConfig {
|
||||
return &BotConfig{
|
||||
token: token,
|
||||
debug: false,
|
||||
apiEndpoint: APIEndpoint,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *BotConfig) GetApiEndpoint() string {
|
||||
return c.apiEndpoint
|
||||
}
|
||||
|
||||
func (c *BotConfig) GetToken() string {
|
||||
return c.token
|
||||
}
|
||||
|
||||
func (c *BotConfig) GetDebug() bool {
|
||||
return c.debug
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue