test
This commit is contained in:
parent
72cf245064
commit
02ad65b1f2
28
td.go
28
td.go
@ -9,20 +9,15 @@ import (
|
||||
"github.com/Arman92/go-tdlib"
|
||||
)
|
||||
|
||||
func ListenCW(c *tdlib.Client) {
|
||||
func ListenMe(c *tdlib.Client) {
|
||||
eventFilter := func(msg *tdlib.TdMessage) bool {
|
||||
updateMsg := (*msg).(*tdlib.UpdateNewMessage)
|
||||
chatID := updateMsg.Message.ChatID
|
||||
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 {
|
||||
senderUserID := updateMsg.Message.SenderUserID
|
||||
if senderUserID == ownUserID32 {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100)
|
||||
@ -33,7 +28,7 @@ func ListenCW(c *tdlib.Client) {
|
||||
|
||||
func ListenMQ(c *tdlib.Client, msgs <-chan ChatWarsCommand) {
|
||||
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")
|
||||
time.Sleep(time.Until(lastOwnTDMsg.Add(time.Second)))
|
||||
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 {
|
||||
updateMsg := (*msg).(*tdlib.UpdateNewMessage)
|
||||
senderUserID := updateMsg.Message.SenderUserID
|
||||
if senderUserID == ownUserID32 {
|
||||
chatID := updateMsg.Message.ChatID
|
||||
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
|
||||
} else {
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user