diff --git a/def.go b/def.go index 3089784..3b6cfde 100644 --- a/def.go +++ b/def.go @@ -4,7 +4,7 @@ import ( "time" ) -type ChatWarsCommand struct { +type TGCommand struct { Type int64 `json:"type"` FromChatID64 int64 `json:"from_chat_id"` FromUserID64 int64 `json:"from_user_id"` diff --git a/main.go b/main.go index 5579a7e..08ff692 100644 --- a/main.go +++ b/main.go @@ -46,7 +46,7 @@ var ( ownUserID32 = int32(0) lastOwnTDMsg time.Time MQCWMsgQueue chan ChatWarsMessage - MQCWCmdQueue chan ChatWarsCommand + MQTDCmdQueue chan TDCommand ) func main() { @@ -127,15 +127,15 @@ func main() { return } - MQCWCmdQueue = make(chan ChatWarsCommand, 100) + MQTDCmdQueue = make(chan TDCommand, 100) for w := 1; w <= 3; w++ { - go MQReceiveMsgWorker(w, MQCWCmdQueue) + go MQReceiveMsgWorker(w, MQTDCmdQueue) } lastOwnTDMsg = time.Now() go ListenCW(client) - go ListenMQ(client, MQCWCmdQueue) + go ListenMQ(client, MQTDCmdQueue) go ListenMe(client) fmt.Println("Started !") diff --git a/mq.go b/mq.go index 932f223..3335999 100644 --- a/mq.go +++ b/mq.go @@ -51,7 +51,7 @@ func MQSendMsgWorker(id int, msgs <-chan ChatWarsMessage) { } -func MQReceiveMsgWorker(id int, cmd chan<- ChatWarsCommand) { +func MQReceiveMsgWorker(id int, cmd chan<- TDCommand) { var c ChatWarsCommand conn, err := amqp.Dial("amqp://" + cfg.Rabbit.User + ":" + cfg.Rabbit.Password + "@" + cfg.Rabbit.Host + "/" + cfg.Rabbit.ReceiveQueue) failOnError(err, "MQReceiveMsgWorker["+strconv.Itoa(id)+"] : Failed to connect to RabbitMQ") diff --git a/td.go b/td.go index d4c3bb2..2596848 100644 --- a/td.go +++ b/td.go @@ -27,7 +27,7 @@ func ListenMe(c *tdlib.Client) { } } -func ListenMQ(c *tdlib.Client, msgs <-chan ChatWarsCommand) { +func ListenMQ(c *tdlib.Client, msgs <-chan TGCommand) { for m := range msgs { for now := time.Now(); lastOwnTDMsg.Add(time.Second).After(now); { log.Printf("ListenMQ : channel busy, waiting before acting...\n")