test
This commit is contained in:
parent
af92bcfc50
commit
753440b3c6
25
main.go
25
main.go
@ -13,7 +13,7 @@ import (
|
||||
var (
|
||||
ownUserID64 = int64(0)
|
||||
ownUserID32 = int32(0)
|
||||
chtwrsID64 = int64(-1001179598662)
|
||||
chtwrsID64 = int64()
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -68,9 +68,11 @@ func main() {
|
||||
ownUserID32 = OwnUserID(client)
|
||||
ownUserID64 = int64(OwnUserID(client))
|
||||
|
||||
fmt.Println("Sleep 1sec..")
|
||||
go ListenMe(client)
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
fmt.Println("Sleep 10sec..")
|
||||
|
||||
time.Sleep(10 * time.Second)
|
||||
|
||||
fmt.Println("Getting history...")
|
||||
|
||||
@ -181,3 +183,20 @@ func OwnUserID(c *tdlib.Client) int32 {
|
||||
user, _ := c.GetMe()
|
||||
return user.ID
|
||||
}
|
||||
|
||||
func ListenMe(c *tdlib.Client) {
|
||||
eventFilter := func(msg *tdlib.TdMessage) bool {
|
||||
updateMsg := (*msg).(*tdlib.UpdateNewMessage)
|
||||
senderUserID := updateMsg.Message.SenderUserID
|
||||
if senderUserID == ownUserID32 {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
receiver := c.AddEventReceiver(&tdlib.UpdateNewMessage{}, eventFilter, 100)
|
||||
for _ = range receiver.Chan {
|
||||
log.Printf("ListenMe : updated.\n")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user