tucnak / telebot

Telebot is a Telegram bot framework in Go.
MIT License
4.06k stars 470 forks source link

how to get all photos of updates #573

Closed MrSong0607 closed 1 year ago

MrSong0607 commented 1 year ago

getUpdates api return a update like follow

        {
            "update_id": 665500574,
            "message": {
                "message_id": 6,
                "from": {
                },
                "chat": {
                },
                "date": 1670488911,
                "media_group_id": "133639**294744053",
                "photo": [
                    {
                        "file_id": "****",
                        "file_unique_id": "AQAD57IxG1-1kVR4",
                        "file_size": 1156,
                        "width": 90,
                        "height": 86
                    },
                    {
                        "file_id": "****",
                        "file_unique_id": "AQAD57IxG1-1kVRy",
                        "file_size": 2274,
                        "width": 117,
                        "height": 112
                    }
                ],
                "caption": "foo bar"
            }
        }

but telebot.Context.Message().Photo got only one photo, is there hava any method to get all photos?

Kohinor46 commented 1 year ago

https://pkg.go.dev/gopkg.in/tucnak/telebot.v3#section-readme:~:text=b.Handle(tele.OnPhoto%2C%20func(m%20*tele.Message)%20%7B%0A%09//%20photos%20only%0A%7D)

roreng commented 1 year ago

getUpdates api return a update like follow

        {
            "update_id": 665500574,
            "message": {
                "message_id": 6,
                "from": {
                },
                "chat": {
                },
                "date": 1670488911,
                "media_group_id": "133639**294744053",
                "photo": [
                    {
                        "file_id": "****",
                        "file_unique_id": "AQAD57IxG1-1kVR4",
                        "file_size": 1156,
                        "width": 90,
                        "height": 86
                    },
                    {
                        "file_id": "****",
                        "file_unique_id": "AQAD57IxG1-1kVRy",
                        "file_size": 2274,
                        "width": 117,
                        "height": 112
                    }
                ],
                "caption": "foo bar"
            }
        }

but telebot.Context.Message().Photo got only one photo, is there hava any method to get all photos?

The framework author designed photo processing in such a way as to eliminate the need to process thumbnails of different sizes. To do this, he created a custom unmarshaller that selects a high-resolution version and uses it. He find this approach to be the beautiful solution, so obtaining other thumbnails is currently impossible.

https://github.com/tucnak/telebot/blob/d90e8974cc13fcaf1bc2429ddb1196f6a03f858e/media.go#L79-L84