diff --git a/bot/command.go b/bot/command.go index 119b9a8..6f74480 100644 --- a/bot/command.go +++ b/bot/command.go @@ -34,10 +34,18 @@ func (b *Bot) addSend(answer func(string), from string, params []string) { if h == nil { h = b.db.NewHost(host) } + if h == nil { + answer(fmt.Sprintf("could not create host %s", host)) + return + } n, ok := b.db.NotifiesByAddress[to] if !ok { n = b.db.NewNotify(to) } + if n == nil { + answer(fmt.Sprintf("could not create notify %s in list of %s", to, host)) + return + } h.AddNotify(n) answer(fmt.Sprintf("added %s in list of %s", to, host)) diff --git a/database/notify.go b/database/notify.go index d614fec..22fc748 100644 --- a/database/notify.go +++ b/database/notify.go @@ -86,6 +86,9 @@ func (db *DB) AddNotify(n *Notify) { func (db *DB) NewNotify(to string) *Notify { addr := strings.Split(to, ":") + if len(addr) != 2 { + return nil + } n := &Notify{ Protocol: addr[0], To: addr[1],