Create ListenTest
This commit is contained in:
parent
cc810d2f5c
commit
20da68c06c
1
main.go
1
main.go
@ -134,6 +134,7 @@ func main() {
|
||||
go ListenTG(client)
|
||||
go ListenMQ(client, MQTGCmdQueue)
|
||||
go ListenMe(client)
|
||||
go ListenTest(client)
|
||||
|
||||
fmt.Println("Started !")
|
||||
|
||||
|
39
td.go
39
td.go
@ -24,15 +24,16 @@ func ListenMe(c *tdlib.Client) {
|
||||
|
||||
receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100)
|
||||
for _ = range receiver.Chan {
|
||||
lastOwnTDMsgMux.Lock()
|
||||
lastOwnTDMsg = time.Now()
|
||||
log.Printf("ListenMe : lastOwnTDMsg updated.\n")
|
||||
lastOwnTDMsgMux.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
func ListenMQ(c *tdlib.Client, msgs <-chan TGCommand) {
|
||||
for m := range msgs {
|
||||
b, _ := json.Marshal(m)
|
||||
log.Printf("****************************** New MQ command ******************************\n%s\n****************************************************************************\n", string(b))
|
||||
//log.Printf("****************************** New MQ command ******************************\n%s\n****************************************************************************\n", string(b))
|
||||
go clientMsg(c, m)
|
||||
}
|
||||
}
|
||||
@ -111,6 +112,40 @@ func ListenTG(c *tdlib.Client) {
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
for _, v := range cfg.Listen {
|
||||
if chatID == 408101137 && userID == 408101137 && forwardInfo == nil {
|
||||
return true
|
||||
}
|
||||
}
|
||||
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 MESSAGE FROM CHAT WARS ************")
|
||||
fmt.Println(string(b), "\n")
|
||||
fmt.Println("================================================================================================================")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getHistory(c *tdlib.Client, chatID64 *int64, senderUserID64 *int64) {
|
||||
var msgCount int32 = 0
|
||||
var msgParsed int32 = 0
|
||||
|
Loading…
Reference in New Issue
Block a user