diff --git a/README.md b/README.md index 2f8ba48..ffc701f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ChirpNestBot - [ ] Adjust /time clock for auctions/... (delay between cw and real time ?) - [ ] Update old auctions with client - [ ] Convert config to json and insert sql structure in it -- [ ] add metrics +- [ ] Add metrics - [ ] Eliminate cache map race conditions (all maps with read/write) and use redis ? - [ ] Transform import/export to jobs, feed msg to identification channel instead of inserting directly - [ ] Turn on/off queue consumption @@ -25,6 +25,6 @@ ChirpNestBot - [x] Export/import all messages - [x] Test HTML in message - [x] Update auction from broadcast -Progression : +- Progression : - 0 -> 4 : Forest + Foray ; - 5 -> 10 : Forest + Foray + Arena ; \ No newline at end of file diff --git a/main.go b/main.go index 847dff5..165f65c 100644 --- a/main.go +++ b/main.go @@ -154,6 +154,8 @@ func main() { MQTGCmdQueue = make(chan TGCommand, MQTGCmdQueueSize) JobQueue = make(chan Job, JobQueueSize) clientsQueue = make(map[int64]*MQClient) + clientsKeepAlive = make(map[int64]*MQKeepAlive) + clientsCW = new(sync.Map) clientsKeepAlive = new(sync.Map) diff --git a/obj.go b/obj.go index 21e83d8..8642570 100644 --- a/obj.go +++ b/obj.go @@ -609,32 +609,40 @@ func silentGetObjItemID(code string, name string) int64 { i := v.(ChatWarsItem) return i.ObjID64 } - if ok, _ := regexp.MatchString(`(u|a|e)[0-9]+[a-z]{0,1}`, c); ok { + if ok, _ := regexp.MatchString(`^((u|e)[0-9]+|a[0-9]+[a-e]{0,1})$`, c); ok || len(c) == 0 { r := regexp.MustCompile(`^((?P⚡\+[0-9]+) ){0,1}(?P.+?)( \+(?P[0-9]+)⚔){0,1}( \+(?P[0-9]+)🛡){0,1}( \+(?P[0-9]+)💧){0,1}$`) n2 := r.ReplaceAllString(n, "${BaseName}") if v, ok := cacheObjItem.Load(n2); ok { i := v.(ChatWarsItem) return i.ObjID64 } - fmt.Printf("silentGetObjItemID(unique) : Modifier : `%s`\n", r.ReplaceAllString(n, "${Modifier}")) - fmt.Printf("silentGetObjItemID(unique) : BaseName : `%s`\n", r.ReplaceAllString(n, "${BaseName}")) - fmt.Printf("silentGetObjItemID(unique) : Atk : `%s`\n", r.ReplaceAllString(n, "${Atk}")) - fmt.Printf("silentGetObjItemID(unique) : Def : `%s`\n", r.ReplaceAllString(n, "${Def}")) - fmt.Printf("silentGetObjItemID(unique) : Mana : `%s`\n", r.ReplaceAllString(n, "${Mana}")) + i := ChatWarsItem{} + cacheObjItem.Range(func(k, v interface{}) bool { + i = v.(ChatWarsItem) + if ok, _ := regexp.MatchString(`^(a|e)[0-9]+$`, i.Code); !ok { //only gear can be custom named + return true + } + s := regexp.QuoteMeta(i.Name) + m := fmt.Sprintf("^(%s.*|.*%s)$ ", s, s) + if ok, _ := regexp.MatchString(m, n2); ok { + return false + } else { + i = ChatWarsItem{ + ObjID64: 0, + } + return true + } - } - if len(c) == 0 { - r := regexp.MustCompile(`^((?P⚡\+[0-9]+) ){0,1}(?P.+?)( \+(?P[0-9]+)⚔){0,1}( \+(?P[0-9]+)🛡){0,1}( \+(?P[0-9]+)💧){0,1}$`) - n2 := r.ReplaceAllString(n, "${BaseName}") - if v, ok := cacheObjItem.Load(n2); ok { - i := v.(ChatWarsItem) + }) + if i.ObjID64 != 0 { return i.ObjID64 + } else { + fmt.Printf("silentGetObjItemID : Modifier : `%s`\n", r.ReplaceAllString(n, "${Modifier}")) + fmt.Printf("silentGetObjItemID : BaseName : `%s`\n", r.ReplaceAllString(n, "${BaseName}")) + fmt.Printf("silentGetObjItemID : Atk : `%s`\n", r.ReplaceAllString(n, "${Atk}")) + fmt.Printf("silentGetObjItemID : Def : `%s`\n", r.ReplaceAllString(n, "${Def}")) + fmt.Printf("silentGetObjItemID : Mana : `%s`\n", r.ReplaceAllString(n, "${Mana}")) } - fmt.Printf("silentGetObjItemID(null) : Modifier : `%s`\n", r.ReplaceAllString(n, "${Modifier}")) - fmt.Printf("silentGetObjItemID(null) : BaseName : `%s`\n", r.ReplaceAllString(n, "${BaseName}")) - fmt.Printf("silentGetObjItemID(null) : Atk : `%s`\n", r.ReplaceAllString(n, "${Atk}")) - fmt.Printf("silentGetObjItemID(null) : Def : `%s`\n", r.ReplaceAllString(n, "${Def}")) - fmt.Printf("silentGetObjItemID(null) : Mana : `%s`\n", r.ReplaceAllString(n, "${Mana}")) } return 0