Use safe host / channel default

Use nonexistent irc server and empty channel list as default config
options to avoid unwanted surprises when testing the bot.

Addresses https://github.com/google/alertmanager-irc-relay/issues/5

Signed-off-by: Luca Bigliardi <shammash@google.com>
This commit is contained in:
Luca Bigliardi 2020-03-05 09:12:02 +00:00
parent c122337b53
commit 96acecb3a5
2 changed files with 3 additions and 3 deletions

View File

@ -52,11 +52,11 @@ func LoadConfig(configFile string) (*Config, error) {
IRCNick: "alertmanager-irc-relay", IRCNick: "alertmanager-irc-relay",
IRCNickPass: "", IRCNickPass: "",
IRCRealName: "Alertmanager IRC Relay", IRCRealName: "Alertmanager IRC Relay",
IRCHost: "irc.freenode.net", IRCHost: "example.com",
IRCPort: 7000, IRCPort: 7000,
IRCUseSSL: true, IRCUseSSL: true,
IRCVerifySSL: true, IRCVerifySSL: true,
IRCChannels: []IRCChannel{IRCChannel{Name: "#airtest"}}, IRCChannels: []IRCChannel{},
MsgOnce: false, MsgOnce: false,
UsePrivmsg: false, UsePrivmsg: false,
} }

2
irc.go
View File

@ -215,7 +215,7 @@ func (notifier *IRCNotifier) Run() {
keepGoing := true keepGoing := true
for keepGoing { for keepGoing {
if !notifier.Client.Connected() { if !notifier.Client.Connected() {
log.Printf("Connecting to IRC") log.Printf("Connecting to IRC %s", notifier.Client.Config().Server)
notifier.BackoffCounter.Delay() notifier.BackoffCounter.Delay()
if err := notifier.Client.Connect(); err != nil { if err := notifier.Client.Connect(); err != nil {
log.Printf("Could not connect to IRC: %s", err) log.Printf("Could not connect to IRC: %s", err)