upd
This commit is contained in:
parent
1824dca693
commit
bd215b8e47
4
def.go
4
def.go
@ -23,4 +23,8 @@ const (
|
||||
objSubTypeMessageHero = 7
|
||||
objSubTypeMessageMe = 8
|
||||
objSubTypeMessageInventory = 9
|
||||
|
||||
MQGetMsgWorkers = 3
|
||||
SQLCWMsgWorkers = 6
|
||||
SQLIdentifyMsgWorkers = 6
|
||||
)
|
||||
|
18
main.go
18
main.go
@ -43,9 +43,9 @@ var (
|
||||
|
||||
db *sql.DB
|
||||
|
||||
cfg Config
|
||||
MQCWMsgQueue chan ChatWarsMessage
|
||||
SQLMsgIdQueue chan int64
|
||||
cfg Config
|
||||
MQCWMsgQueue chan ChatWarsMessage
|
||||
SQLMsgIdentifyQueue chan int64
|
||||
)
|
||||
|
||||
func PrintText(m *tb.Message) {
|
||||
@ -90,16 +90,16 @@ func main() {
|
||||
go StartBot()
|
||||
|
||||
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)
|
||||
}
|
||||
for w := 1; w <= 6; w++ {
|
||||
go SQLCWMsgWorker(w, MQCWMsgQueue, SQLMsgIdQueue)
|
||||
for w := 1; w <= SQLCWMsgWorkers; w++ {
|
||||
go SQLCWMsgWorker(w, MQCWMsgQueue, SQLMsgIdentifyQueue)
|
||||
}
|
||||
for w := 1; w <= 6; w++ {
|
||||
go SQLIdentifyMsgWorker(w, SQLMsgIdQueue)
|
||||
for w := 1; w <= SQLIdentifyMsgWorkers; w++ {
|
||||
go SQLIdentifyMsgWorker(w, SQLMsgIdentifyQueue)
|
||||
}
|
||||
|
||||
fmt.Println("Started !")
|
||||
|
@ -74,7 +74,12 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
|
||||
m, err := getMsg(objId)
|
||||
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Retrieving message.")
|
||||
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.")
|
||||
|
Loading…
Reference in New Issue
Block a user