diff --git a/def.go b/def.go index 5776253..51c9c69 100644 --- a/def.go +++ b/def.go @@ -19,14 +19,20 @@ type TGCommand struct { Delay time.Duration `json:"delay"` } +type ChatWarsCallback struct { + Name string `json:"name"` + Data string `json:"data"` +} + type ChatWarsMessage struct { - TGUserID64 int64 `json:"tg_user_id"` - TGSenderUserID64 int64 `json:"tg_sender_user_id"` - Date time.Time `json:"date"` - ID64 int64 `json:"id"` - ChatID64 int64 `json:"chat_id"` - Text string `json:"text"` - IsForwarded bool `json:"is_forwarded"` + TGUserID64 int64 `json:"tg_user_id"` + TGSenderUserID64 int64 `json:"tg_sender_user_id"` + Date time.Time `json:"date"` + ID64 int64 `json:"id"` + ChatID64 int64 `json:"chat_id"` + Text string `json:"text"` + IsForwarded bool `json:"is_forwarded"` + Callbacks []ChatWarsCallback `json:"callbacks"` } type MQKeepAlive struct { diff --git a/main.go b/main.go index a16857e..8db58cb 100644 --- a/main.go +++ b/main.go @@ -134,7 +134,6 @@ func main() { go ListenTG(client) go ListenMQ(client, MQTGCmdQueue) go ListenMe(client) - go ListenTest(client) fmt.Println("Started !") diff --git a/td.go b/td.go index 2b43449..5dd482d 100644 --- a/td.go +++ b/td.go @@ -108,48 +108,6 @@ func ListenTG(c *tdlib.Client) { fmt.Println("ForwardInfo : ", updateMsg.Message.ForwardInfo) fmt.Println("================================================================================================================") - b, err := json.Marshal(updateMsg) - if err != nil { - logOnError(err, "ListenTG : Marshaling message.") - } - - fmt.Println("************ RAW TEXT MESSAGE FROM CHAT WARS ************") - fmt.Println(string(b), "\n") - fmt.Println("================================================================================================================") - - } - } -} - -func ListenTest(c *tdlib.Client) { - eventFilter := func(msg *tdlib.TdMessage) bool { - updateMsg := (*msg).(*tdlib.UpdateNewMessage) - chatID := int64(updateMsg.Message.ChatID) - userID := int64(updateMsg.Message.SenderUserID) - forwardInfo := updateMsg.Message.ForwardInfo - if chatID == 408101137 && userID == 408101137 && forwardInfo == nil { - return true - } else { - return false - } - } - - receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100) - for newMsg := range receiver.Chan { - updateMsg := (newMsg).(*tdlib.UpdateNewMessage) - if updateMsg.Message.Content.GetMessageContentEnum() != tdlib.MessageTextType { - t := time.Now() - - b, err := json.Marshal(updateMsg) - if err != nil { - logOnError(err, "ListenTest : Marshaling message.") - } - - fmt.Printf("[%d-%02d-%02d %02d:%02d:%02d-00:00]", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second()) - fmt.Println("************ RAW NON TEXT MESSAGE FROM CHAT WARS ************") - fmt.Println(string(b), "\n") - fmt.Println("================================================================================================================") - } } }