(I wrote this question on go forum and have not received reply yet.)
I’m working on a telegram Golang program using TDlib,
everytime that I run the program it will bring about 20 messages from about an hour or more before,
I want to refrain from getting them, I would be thankful for your comments.
Usually, I receive all messages missed while the instance wasn’t active. If there were a lot of missed messages, I will receive a lot of updateNewMessage updates soon after start.
I want to skip all updates about messages, which were sent before instance launch, by examining their send date.
my program is something like this:
// Send “/start” text every 5 seconds to Foursquare bot chat
go func() {
// Should get chatID somehow, check out “getChats” example
chatID := int64(198529620) // Foursquare bot chat id
// rawUpdates gets all updates comming from tdlib
rawUpdates := client.GetRawUpdatesChannel(100)
for update := range rawUpdates {
// Show all updates
fmt.Println(update.Data)
fmt.Print(“\n\n”)
}
I don’t know anything about this library, but is there something in the update that contains a date? Could you check that date in your for update := range rawUpdates loop and skip printing all the ones you receive from times you don’t want?
I would be thankful for an example to apply the time on the messages and skipping the messages before that time.
Also, how can I define the start of run time to the program.
The NewMessage function in the package that I found (right under Message’s documentation) describes the date and editDate parameters as a “Unix timestamp.” You should be able to use time.Unix and pass that int32 value as the Unix function’s sec parameter (that function expects the parameter to be int64, so you’ll have to convert it). You can then do the date check that Jeff mentioned to see if it’s before the date you want.
If you want to get the date the program starts, you can have a global variable hold that date:
Thanks for your help and suggestions, I could compile the program to avoid prior run-time updates.
And I think it works now.
In case I had problem, I will ask again.