update rules

This commit is contained in:
shoopea 2020-01-06 12:05:00 +08:00
parent c37ed1c982
commit eaf41b55aa

46
sql.go
View File

@ -781,52 +781,6 @@ func insertMsgPillageInc(m *ChatWarsMessagePillageInc) error {
return nil
}
func loadMsgParsingRules() (m map[int]MessageParsingRule, err error) {
var (
id int32
priority int32
descn string
rule string
msgTypeID64 int64
)
log.Println("Loading message parsing rules...")
m = make(map[int]MessageParsingRule)
count := int(0)
defer func() {
if rec := recover(); rec != nil {
log.Println("Error parsing rules : ", rec)
err = errors.New("panic")
}
}()
rules, err := db.Query(`SELECT r.id, r.prio, r.descn, r.rule, r.msg_type_id FROM msg_rules r ORDER BY r.prio DESC;`)
if err != nil {
return m, err
}
defer rules.Close()
for rules.Next() {
err = rules.Scan(&id, &priority, &descn, &rule, &msgTypeID64)
if err != nil {
return m, err
}
i := new(MessageParsingRule)
i.ID = id
i.Priority = priority
i.Description = descn
i.Rule = rule
i.MsgTypeID64 = msgTypeID64
i.re = regexp.MustCompile(rule)
m[count] = *i
// log.Printf("New rule : %s\n", rule)
count++
}
return m, nil
}
func getSQLListID64(q string) []int64 {
var (
id int64