upd
This commit is contained in:
parent
1824dca693
commit
bd215b8e47
4
def.go
4
def.go
@ -23,4 +23,8 @@ const (
|
|||||||
objSubTypeMessageHero = 7
|
objSubTypeMessageHero = 7
|
||||||
objSubTypeMessageMe = 8
|
objSubTypeMessageMe = 8
|
||||||
objSubTypeMessageInventory = 9
|
objSubTypeMessageInventory = 9
|
||||||
|
|
||||||
|
MQGetMsgWorkers = 3
|
||||||
|
SQLCWMsgWorkers = 6
|
||||||
|
SQLIdentifyMsgWorkers = 6
|
||||||
)
|
)
|
||||||
|
14
main.go
14
main.go
@ -45,7 +45,7 @@ var (
|
|||||||
|
|
||||||
cfg Config
|
cfg Config
|
||||||
MQCWMsgQueue chan ChatWarsMessage
|
MQCWMsgQueue chan ChatWarsMessage
|
||||||
SQLMsgIdQueue chan int64
|
SQLMsgIdentifyQueue chan int64
|
||||||
)
|
)
|
||||||
|
|
||||||
func PrintText(m *tb.Message) {
|
func PrintText(m *tb.Message) {
|
||||||
@ -90,16 +90,16 @@ func main() {
|
|||||||
go StartBot()
|
go StartBot()
|
||||||
|
|
||||||
MQCWMsgQueue = make(chan ChatWarsMessage, 100)
|
MQCWMsgQueue = make(chan ChatWarsMessage, 100)
|
||||||
SQLMsgIdQueue = make(chan int64, 100)
|
SQLMsgIdentifyQueue = make(chan int64, 100)
|
||||||
|
|
||||||
for w := 1; w <= 3; w++ {
|
for w := 1; w <= MQGetMsgWorkers; w++ {
|
||||||
go MQGetMsgWorker(w, MQCWMsgQueue)
|
go MQGetMsgWorker(w, MQCWMsgQueue)
|
||||||
}
|
}
|
||||||
for w := 1; w <= 6; w++ {
|
for w := 1; w <= SQLCWMsgWorkers; w++ {
|
||||||
go SQLCWMsgWorker(w, MQCWMsgQueue, SQLMsgIdQueue)
|
go SQLCWMsgWorker(w, MQCWMsgQueue, SQLMsgIdentifyQueue)
|
||||||
}
|
}
|
||||||
for w := 1; w <= 6; w++ {
|
for w := 1; w <= SQLIdentifyMsgWorkers; w++ {
|
||||||
go SQLIdentifyMsgWorker(w, SQLMsgIdQueue)
|
go SQLIdentifyMsgWorker(w, SQLMsgIdentifyQueue)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Started !")
|
fmt.Println("Started !")
|
||||||
|
@ -74,7 +74,12 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
|||||||
m, err := getMsg(objId)
|
m, err := getMsg(objId)
|
||||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Retrieving message.")
|
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Retrieving message.")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Message retrieved\n%s\n", m.Text)
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Message retrieved (%d)\n%s\n", objId, m.Text)
|
||||||
|
// War reports
|
||||||
|
r := regexp.MustCompile(`^(?P<Castle>[.]{1})(?P<Guild>(\[[A-Z]{3}\]){0,1})(?P<User>(\[[A-Za-z0-9 ]*\]){1}) ⚔:(?P<Attack>[0-9]+) ?:(?P<Defense>[0-9]+) Lvl: (?P<Level>[0-9]+)(?s:.*)$`)
|
||||||
|
if r.FindStringSubmatch(item) != nil {
|
||||||
|
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : War report identified (%d)\n", objId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Printf("SQLIdentifyMsgWorker[" + strconv.Itoa(id) + "] : Closing.")
|
log.Printf("SQLIdentifyMsgWorker[" + strconv.Itoa(id) + "] : Closing.")
|
||||||
|
Loading…
Reference in New Issue
Block a user