TG branding

This commit is contained in:
shoopea 2019-05-16 10:05:27 +08:00
parent 7563649d9b
commit 5a8c818876
4 changed files with 7 additions and 7 deletions

2
def.go
View File

@ -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"`

View File

@ -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 !")

2
mq.go
View File

@ -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")

2
td.go
View File

@ -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")