update Message

This commit is contained in:
shoopea 2019-12-12 11:06:07 +08:00
parent 6755f5064d
commit 10c5e08418
3 changed files with 13 additions and 50 deletions

6
def.go
View File

@ -19,6 +19,11 @@ 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"`
@ -27,6 +32,7 @@ type ChatWarsMessage struct {
ChatID64 int64 `json:"chat_id"`
Text string `json:"text"`
IsForwarded bool `json:"is_forwarded"`
Callbacks []ChatWarsCallback `json:"callbacks"`
}
type MQKeepAlive struct {

View File

@ -134,7 +134,6 @@ func main() {
go ListenTG(client)
go ListenMQ(client, MQTGCmdQueue)
go ListenMe(client)
go ListenTest(client)
fmt.Println("Started !")

42
td.go
View File

@ -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("================================================================================================================")
}
}
}