This commit is contained in:
parent
9c78ea2d48
commit
7c684af8c3
79 changed files with 3594 additions and 3257 deletions
32
internal/platform/init.go
Normal file
32
internal/platform/init.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package platform
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.nakama.town/fmartingr/butterrobot/internal/config"
|
||||
"git.nakama.town/fmartingr/butterrobot/internal/platform/slack"
|
||||
"git.nakama.town/fmartingr/butterrobot/internal/platform/telegram"
|
||||
)
|
||||
|
||||
// InitializePlatforms initializes all available platforms
|
||||
func InitializePlatforms(cfg *config.Config) error {
|
||||
// Initialize Slack platform
|
||||
if cfg.SlackConfig.Token != "" && cfg.SlackConfig.BotOAuthAccessToken != "" {
|
||||
slackPlatform := slack.New(&cfg.SlackConfig)
|
||||
if err := slackPlatform.Init(cfg); err == nil {
|
||||
Register("slack", slackPlatform)
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize Telegram platform
|
||||
if cfg.TelegramConfig.Token != "" {
|
||||
telegramPlatform := telegram.New(&cfg.TelegramConfig)
|
||||
if err := telegramPlatform.Init(cfg); err == nil {
|
||||
Register("telegram", telegramPlatform)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("telegram token is required")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue