Move bot config to separate struct.

This commit is contained in:
Ilja Lapkovskis 2024-01-28 00:16:53 +02:00
parent aa0cdf3719
commit 1b1af39b61
No known key found for this signature in database
GPG key ID: 53D2AA4F0D1079C4
8 changed files with 353 additions and 286 deletions

42
bot_config.go Normal file
View 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
}