TG branding
This commit is contained in:
parent
7563649d9b
commit
5a8c818876
2
def.go
2
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"`
|
||||
|
8
main.go
8
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 !")
|
||||
|
2
mq.go
2
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")
|
||||
|
2
td.go
2
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")
|
||||
|
Loading…
Reference in New Issue
Block a user