use db Notifier for defaults (with regex ...)

This commit is contained in:
Martin/Geno 2019-06-30 09:46:52 +02:00
parent d2ca796145
commit 0a4adad430
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
1 changed files with 13 additions and 7 deletions

View File

@ -71,14 +71,20 @@ func Init(configInterface interface{}, db *database.DB, bot *bot.Bot) output.Out
logger.WithField("jid", config.JID).Info("startup") logger.WithField("jid", config.JID).Info("startup")
for to, muc := range config.Defaults { for to, muc := range config.Defaults {
def := &database.Notify{ var def *database.Notify
Protocol: proto, pro := proto
if muc {
pro = protoGroup
}
if dbNotify, ok := db.NotifiesByAddress[pro+":"+to]; ok {
def = dbNotify
} else {
def = &database.Notify{
Protocol: pro,
To: to, To: to,
RegexIn: make(map[string]*regexp.Regexp), RegexIn: make(map[string]*regexp.Regexp),
MaxPrioIn: log.DebugLevel, MaxPrioIn: log.DebugLevel,
} }
if muc {
def.Protocol = protoGroup
out.Join(to) out.Join(to)
} }
out.defaults = append(out.defaults, def) out.defaults = append(out.defaults, def)