update Message
This commit is contained in:
parent
6755f5064d
commit
10c5e08418
6
def.go
6
def.go
@ -19,6 +19,11 @@ type TGCommand struct {
|
|||||||
Delay time.Duration `json:"delay"`
|
Delay time.Duration `json:"delay"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChatWarsCallback struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Data string `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
type ChatWarsMessage struct {
|
type ChatWarsMessage struct {
|
||||||
TGUserID64 int64 `json:"tg_user_id"`
|
TGUserID64 int64 `json:"tg_user_id"`
|
||||||
TGSenderUserID64 int64 `json:"tg_sender_user_id"`
|
TGSenderUserID64 int64 `json:"tg_sender_user_id"`
|
||||||
@ -27,6 +32,7 @@ type ChatWarsMessage struct {
|
|||||||
ChatID64 int64 `json:"chat_id"`
|
ChatID64 int64 `json:"chat_id"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
IsForwarded bool `json:"is_forwarded"`
|
IsForwarded bool `json:"is_forwarded"`
|
||||||
|
Callbacks []ChatWarsCallback `json:"callbacks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MQKeepAlive struct {
|
type MQKeepAlive struct {
|
||||||
|
1
main.go
1
main.go
@ -134,7 +134,6 @@ func main() {
|
|||||||
go ListenTG(client)
|
go ListenTG(client)
|
||||||
go ListenMQ(client, MQTGCmdQueue)
|
go ListenMQ(client, MQTGCmdQueue)
|
||||||
go ListenMe(client)
|
go ListenMe(client)
|
||||||
go ListenTest(client)
|
|
||||||
|
|
||||||
fmt.Println("Started !")
|
fmt.Println("Started !")
|
||||||
|
|
||||||
|
42
td.go
42
td.go
@ -108,48 +108,6 @@ func ListenTG(c *tdlib.Client) {
|
|||||||
fmt.Println("ForwardInfo : ", updateMsg.Message.ForwardInfo)
|
fmt.Println("ForwardInfo : ", updateMsg.Message.ForwardInfo)
|
||||||
fmt.Println("================================================================================================================")
|
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("================================================================================================================")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user