influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.6k stars 5.57k forks source link

How to determine the end of an album? #4258

Closed ghost closed 6 years ago

ghost commented 6 years ago

I am just starting on this telegraf stuff...

I have the following:

bot.on("message", function (ctx, next) {{ ... }

It's listening on a bot. If I send an album from the bot, the media get separated out into individual messages and get sent out. I can collect these messages and at the end do stuff. I do see that I can use sessions to keep stuff in memory to aggregate toward the end, but the question is how to determine the end of the messages for the album are? How does one determine this message is the last one and there won't be anymore messages containing information about more media (i.e. photos)?

Thnks.

danielnelson commented 6 years ago

@rodeod I'm sorry I'm not sure what you are referring to since Telegraf doesn't have albums/bots at all. Are you sure you are asking on the right project?

ghost commented 6 years ago

I believe Telegram (the client) allows album feature which directly translates to the media_group message type (in the API). It does contain a media_group_id which group collection of medias like photos, but the media group come as a series of separate messages. I want to collect all these and at the end do something with them.

There are two problems I was encountering however: 1) keeping them in memory via session (but not sure I am using session object correctly because I instantiate the session on the first message "and" add a photo to it, but it gets nulled out by the next message, and only "after" the second time it starts keeping things in memory, 2) second problem is how to determine that this message containing the photo is the last one in the series. There doesn't "SEEM" to be anything in the messages that indicates that this is the last message, or to indicate the total number of messages in the group.

Thnk you, and again this is only my initial foray into Telegraf and Telegram API. Thnks.

danielnelson commented 6 years ago

I searched around and I think maybe you are looking for this project instead: https://github.com/telegraf

alexander-mart commented 1 year ago

2. second problem is how to determine that this message containing the photo is the last one in the series.

Has anyone found a solution to this problem?

(sequence of separate messages with same media_group_id)

alexander-mart commented 1 year ago

What i found:

https://stackoverflow.com/questions/50180048/telegram-api-get-all-uploaded-photos-by-media-group-id