test
This commit is contained in:
parent
72cf245064
commit
02ad65b1f2
28
td.go
28
td.go
@ -9,21 +9,16 @@ import (
|
|||||||
"github.com/Arman92/go-tdlib"
|
"github.com/Arman92/go-tdlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ListenCW(c *tdlib.Client) {
|
func ListenMe(c *tdlib.Client) {
|
||||||
eventFilter := func(msg *tdlib.TdMessage) bool {
|
eventFilter := func(msg *tdlib.TdMessage) bool {
|
||||||
updateMsg := (*msg).(*tdlib.UpdateNewMessage)
|
updateMsg := (*msg).(*tdlib.UpdateNewMessage)
|
||||||
chatID := updateMsg.Message.ChatID
|
senderUserID := updateMsg.Message.SenderUserID
|
||||||
forwardInfo := updateMsg.Message.ForwardInfo
|
if senderUserID == ownUserID32 {
|
||||||
if (chatID == user_chtwrsbot ||
|
|
||||||
(chatID == chat_war && cfg.Listen.War) ||
|
|
||||||
(chatID == chat_war_mini && cfg.Listen.WarMini) ||
|
|
||||||
(chatID == chat_auction && cfg.Listen.Auctions)) &&
|
|
||||||
forwardInfo == nil {
|
|
||||||
return true
|
return true
|
||||||
}
|
} else {
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100)
|
receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100)
|
||||||
for newMsg := range receiver.Chan {
|
for newMsg := range receiver.Chan {
|
||||||
@ -33,7 +28,7 @@ func ListenCW(c *tdlib.Client) {
|
|||||||
|
|
||||||
func ListenMQ(c *tdlib.Client, msgs <-chan ChatWarsCommand) {
|
func ListenMQ(c *tdlib.Client, msgs <-chan ChatWarsCommand) {
|
||||||
for m := range msgs {
|
for m := range msgs {
|
||||||
for now := time.Now(); lastOwnTDMsg.Add(time.Second) > now; {
|
for now := time.Now(); lastOwnTDMsg.Add(time.Second).After(now); {
|
||||||
log.Printf("ListenMQ : channel busy, waiting before acting...\n")
|
log.Printf("ListenMQ : channel busy, waiting before acting...\n")
|
||||||
time.Sleep(time.Until(lastOwnTDMsg.Add(time.Second)))
|
time.Sleep(time.Until(lastOwnTDMsg.Add(time.Second)))
|
||||||
now = time.Now()
|
now = time.Now()
|
||||||
@ -43,11 +38,16 @@ func ListenMQ(c *tdlib.Client, msgs <-chan ChatWarsCommand) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListenMe(c *tdlib.Client) {
|
func ListenCW(c *tdlib.Client) {
|
||||||
eventFilter := func(msg *tdlib.TdMessage) bool {
|
eventFilter := func(msg *tdlib.TdMessage) bool {
|
||||||
updateMsg := (*msg).(*tdlib.UpdateNewMessage)
|
updateMsg := (*msg).(*tdlib.UpdateNewMessage)
|
||||||
senderUserID := updateMsg.Message.SenderUserID
|
chatID := updateMsg.Message.ChatID
|
||||||
if senderUserID == ownUserID32 {
|
forwardInfo := updateMsg.Message.ForwardInfo
|
||||||
|
if (chatID == user_chtwrsbot ||
|
||||||
|
(chatID == chat_war && cfg.Listen.War) ||
|
||||||
|
(chatID == chat_war_mini && cfg.Listen.WarMini) ||
|
||||||
|
(chatID == chat_auction && cfg.Listen.Auctions)) &&
|
||||||
|
forwardInfo == nil {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user