This commit is contained in:
shoopea 2019-04-29 14:06:09 +08:00
parent 15859aeb18
commit eb392a7e6a

15
main.go
View File

@ -107,13 +107,19 @@ func ListenCW(c *tdlib.Client) {
return false
}
conn, _ := amqp.Dial("amqp://shoopea:UmDd5g4WRa2MzqOHsG2T@localhost:5672/chatwars/" + strconv.FormatInt(ownUserID64, 10))
conn, err := amqp.Dial("amqp://shoopea:UmDd5g4WRa2MzqOHsG2T@localhost:5672/chatwars/" + strconv.FormatInt(ownUserID64, 10))
if err != nil {
log.Fatal(err)
}
defer conn.Close()
ch, _ := conn.Channel()
ch, err := conn.Channel()
if err != nil {
log.Fatal(err)
}
defer ch.Close()
q, _ := ch.QueueDeclare(
q, err := ch.QueueDeclare(
"msg", // name
false, // durable
false, // delete when unused
@ -121,6 +127,9 @@ func ListenCW(c *tdlib.Client) {
false, // no-wait
nil, // arguments
)
if err != nil {
log.Fatal(err)
}
receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100)
for newMsg := range receiver.Chan {