This commit is contained in:
shoopea 2019-05-16 10:16:35 +08:00
parent cfa747fa74
commit 6766c5a22b
3 changed files with 15 additions and 4 deletions

3
def.go
View File

@ -6,7 +6,7 @@ import (
"time" "time"
) )
type ChatWarsCommand struct { type TGCommand struct {
Type int64 `json:"type"` Type int64 `json:"type"`
FromChatID64 int64 `json:"from_chat_id"` FromChatID64 int64 `json:"from_chat_id"`
FromUserID64 int64 `json:"from_user_id"` FromUserID64 int64 `json:"from_user_id"`
@ -183,6 +183,7 @@ const (
SQLCWMsgWorkers = 6 SQLCWMsgWorkers = 6
SQLIdentifyMsgWorkers = 6 SQLIdentifyMsgWorkers = 6
SQLJobWorkers = 3 SQLJobWorkers = 3
TGCmdWorkers = 3
SQLJobSliceSize = 25 SQLJobSliceSize = 25
) )

View File

@ -47,6 +47,7 @@ var (
cfg Config cfg Config
MQCWMsgQueue chan ChatWarsMessage MQCWMsgQueue chan ChatWarsMessage
SQLMsgIdentifyQueue chan int64 SQLMsgIdentifyQueue chan int64
TGMsgQueue chan TGCommand
msgParsingRules map[int]MessageParsingRule msgParsingRules map[int]MessageParsingRule
) )
@ -103,6 +104,7 @@ func main() {
MQCWMsgQueue = make(chan ChatWarsMessage, 100) MQCWMsgQueue = make(chan ChatWarsMessage, 100)
SQLMsgIdentifyQueue = make(chan int64, 100) SQLMsgIdentifyQueue = make(chan int64, 100)
TGCmdQueue = make(chan TGCommand, 100)
for w := 1; w <= MQGetMsgWorkers; w++ { for w := 1; w <= MQGetMsgWorkers; w++ {
go MQGetMsgWorker(w, MQCWMsgQueue) go MQGetMsgWorker(w, MQCWMsgQueue)
@ -116,6 +118,9 @@ func main() {
for w := 1; w <= SQLJobWorkers; w++ { for w := 1; w <= SQLJobWorkers; w++ {
go SQLJobWorker(w) go SQLJobWorker(w)
} }
for w := 1; w <= TGCmdWorkers; w++ {
go TGCmdWorker(w, b, TGCmdQueue)
}
log.Println("Bot started !") log.Println("Bot started !")

View File

@ -176,6 +176,11 @@ func SQLJobWorker(id int) {
log.Printf("SQLJobWorker[" + strconv.Itoa(id) + "] : Closing.") log.Printf("SQLJobWorker[" + strconv.Itoa(id) + "] : Closing.")
} }
/* func TGCmdWorker(id int, b *tb.Bot, cmds <-chan TGCommand) {
func BotMsgWorker(id int, botMsg <-chan log.Printf("TGCmdWorker[" + strconv.Itoa(id) + "] : Starting.")
*/ for c := range cmds {
b, err := json.Marshal(c)
log.Printf("TGCmdWorker["+strconv.Itoa(id)+"] : new command.\n%s\n", string(b))
}
log.Printf("TGCmdWorker[" + strconv.Itoa(id) + "] : Closing.")
}