Skip to content

Fix paid media in media group failing to send #770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
797f683
Implement Bot API 6.3 changes.
OvyFlash Nov 5, 2022
f7e326b
Implement Bot API 6.2 changes.
OvyFlash Nov 20, 2022
a89ebae
Implement Bot API 6.1 changes
Nov 20, 2022
fbc829b
Merge pull request #2 from OvyFlash/bot-api-6.1
OvyFlash Nov 20, 2022
1451a8b
Merge branch 'master' into bot-api-6.2
OvyFlash Nov 20, 2022
6866361
Merge pull request #3 from OvyFlash/bot-api-6.2
OvyFlash Nov 20, 2022
2e912ef
Merge branch 'master' into bot-api-6.3
OvyFlash Nov 20, 2022
26b0a55
Merge pull request #1 from OvyFlash/bot-api-6.3
OvyFlash Nov 20, 2022
5e115c9
Implement Bot API 6.4 changes
OvyFlash Dec 31, 2022
8c46c34
Merge pull request #4 from OvyFlash/bot-api-6.4
OvyFlash Dec 31, 2022
16635e5
Implement Bot API 6.5 changes
OvyFlash Feb 4, 2023
05cb53e
Merge pull request #6 from OvyFlash/bot-api-6.5
OvyFlash Feb 4, 2023
3ba8237
Fix: missing json tag in UserShared and ChatShared
OvyFlash Feb 11, 2023
ef8307c
BOT API 6.6 implementation
Jul 4, 2023
a4b5cdb
add field
Jul 4, 2023
2d0a34c
Add types_tests for bot api 6.6 and replace PNGSticker and TGSSticker…
OvyFlash Jul 4, 2023
c33a1d7
Merge pull request #7 from OvyFlash/bot-api-6.6
OvyFlash Jul 4, 2023
7d82083
BOT API 6.7 implementation
Jul 5, 2023
45f5638
Add omitempty to optional fields
OvyFlash Jul 5, 2023
3c3091b
Merge pull request #8 from OvyFlash/bot-api-6.7
OvyFlash Jul 5, 2023
dcd469f
Add nil check in method '(*Update).FromChat', for type CallbackQuery.
OvyFlash Jul 11, 2023
10078d1
Fix typo in the name of config struct SetCustomEmojiStickerSetThumbna…
OvyFlash Jul 11, 2023
f4cedb2
Merge pull request #9 from OvyFlash/bot-api-6.7
OvyFlash Jul 11, 2023
32982cf
Wrong method for SetMyShortDescriptionConfig
OvyFlash Aug 13, 2023
9b085ce
Merge branch 'bot-api-6.7'
OvyFlash Aug 13, 2023
48d380a
Add 'BotName' type to available types.
OvyFlash Oct 16, 2023
371d8b6
Add const for 'chat_join_request' update type
OvyFlash Oct 30, 2023
17d3e39
BOT API 6.8 implementation
OvyFlash Dec 30, 2023
9966656
Merge pull request #10 from OvyFlash/bot-api-6.8
OvyFlash Dec 30, 2023
6d16dea
BOT API 6.9 implementation
OvyFlash Dec 30, 2023
86db600
Merge pull request #11 from OvyFlash/bot-api-6.9
OvyFlash Dec 30, 2023
bd151fc
Start implementing 7.0 Bot API changes
OvyFlash Jan 5, 2024
e06de39
giveaway implementation
zhuk-kk Jan 6, 2024
8db24a9
fix typo
zhuk-kk Jan 6, 2024
92b9f7c
other changes implementation; MaybeInaccessibleMessage not used
zhuk-kk Jan 6, 2024
678ff6f
Finish implementing Bot API 7.0 changes
OvyFlash Jan 7, 2024
9cb877e
Merge pull request #12 from OvyFlash/bot-api-7.0
OvyFlash Jan 7, 2024
a687eaf
Add helper methods
OvyFlash Jan 7, 2024
63e5c59
Fix UserIsBot and UserIsPremium fields in KeyboardButtonRequestUsers …
OvyFlash Jan 8, 2024
5198d8b
Update README.md
iamwavecut Jan 15, 2024
9fd1f7e
Added NewDeleteMessages method to batch DeleteMessage requests within…
Etherdrake Feb 14, 2024
6f966b8
Merge pull request #15 from Etherdrake/synced
OvyFlash Feb 17, 2024
8d23500
Merge pull request #13 from iamwavecut/patch-1
OvyFlash Feb 17, 2024
3beddeb
Fix Chat permissions mapping
Alexkurd Feb 18, 2024
a7a786d
fix ReplyToMessageID assignment in readme
dmekhov Mar 3, 2024
27c0c11
Merge pull request #16 from Alexkurd/cansend-patch
OvyFlash Mar 4, 2024
c88341c
Merge pull request #17 from dmekhov/fix-readme
OvyFlash Mar 4, 2024
1e94209
Add optional Chat field in MessageOrigin struct to support MessageOri…
OvyFlash Mar 5, 2024
d9d4cad
Merge branch 'master' of github.com:OvyFlash/telegram-bot-api
OvyFlash Mar 5, 2024
eced2e4
Fix API 7.0 update implementation. Add the fields chat_boost and remo…
OvyFlash Mar 10, 2024
5f42989
Add missing `getCustomEmojiStickers` method from API v6.2
iamwavecut Mar 15, 2024
def9b6b
Merge pull request #20 from iamwavecut/master
OvyFlash Mar 16, 2024
2ff78b9
BOT API 7.1 implementation
OvyFlash Apr 27, 2024
f3a5b4e
Merge pull request #21 from OvyFlash/bot-api-7.1
OvyFlash Apr 27, 2024
6a83e6e
BOT API 7.2 implementation
OvyFlash May 2, 2024
29fd5ed
Merge pull request #22 from OvyFlash/bot-api-7.2
OvyFlash May 4, 2024
1ad852c
Bot API 7.3 implementation
zhuk-kk May 7, 2024
3dfc49d
add missed omitempty tag & update comments
zhuk-kk May 10, 2024
f8ef3a5
Merge pull request #23 from OvyFlash/bot-api-7.3
OvyFlash May 11, 2024
d0fa8e9
Fix missing ParseMode in InlineQueryResultVideo
bobra May 15, 2024
9b9c5c5
Merge pull request #24 from bobra/patch-1
OvyFlash May 15, 2024
bece330
Bot API 7.4 implementation
zhuk-kk May 31, 2024
90edbbc
Merge pull request #25 from OvyFlash/bot-api-7.4
OvyFlash Jun 9, 2024
1deaa64
Bot API 7.5 implementation
zhuk-kk Jun 23, 2024
6bd5d12
add TransactionPartner to chattable
zhuk-kk Jun 23, 2024
a8238b8
Bot API 7.6 implementation
zhuk-kk Jul 2, 2024
523c355
Merge pull request #26 from OvyFlash/bot-api-7.5
OvyFlash Jul 6, 2024
8d9704f
Remove redundant pointer for PhotoSize slice in PaidMedia structure
OvyFlash Jul 6, 2024
e63f974
Merge pull request #28 from OvyFlash/bot-api-7.6
OvyFlash Jul 6, 2024
2126343
BotAPI 7.7 implementation
zhuk-kk Jul 8, 2024
9d1c899
Merge pull request #30 from OvyFlash/bot-api-7.7
OvyFlash Jul 12, 2024
ac7ff11
add required "SuggestedTipAmounts" field in NewInvoice
birabittoh Jul 21, 2024
861b023
Merge pull request #31 from BiRabittoh/master
OvyFlash Jul 22, 2024
819ceaf
BotAPI 7.8 implementation
zhuk-kk Aug 9, 2024
540e667
Move preparing of 'business_connection_id' field to BaseChatMessage s…
OvyFlash Aug 9, 2024
6c12dc9
Merge pull request #32 from OvyFlash/bot-api-7.8
OvyFlash Aug 9, 2024
11b1a66
feat: some support for context propagation
npazosmendez Aug 20, 2024
acd4170
Don't wait 3 seconds if the context was cancelled
npazosmendez Aug 20, 2024
fa8d187
Merge pull request #33 from npazosmendez/njpm/context
OvyFlash Sep 8, 2024
f9ab9c0
add NewSetMessageReaction
birabittoh Sep 18, 2024
cefbcc6
Added the ability to call the createInvoiceLink() method to generate …
monoflash Sep 19, 2024
5e3acab
Merge pull request #35 from BiRabittoh/master
OvyFlash Sep 20, 2024
9fae8ef
Merge pull request #36 from monoflash/master
OvyFlash Sep 20, 2024
807a7e7
add extra edit message media types
Oct 1, 2024
d2dc779
update edit media tests
Oct 8, 2024
333ea1e
add caption_entities to DocumentConfig params
OrIX219 Oct 11, 2024
a19253e
Merge pull request #39 from OrIX219/fix-send-document-caption-entities
OvyFlash Oct 13, 2024
560d000
BotAPI 7.9 implementation
OvyFlash Oct 13, 2024
e062c9d
Merge pull request #38 from open-ssl/new-edit-messages-extra-types
OvyFlash Oct 13, 2024
95e8308
Merge branch 'master' into bot-api-7.9
OvyFlash Oct 13, 2024
c7290a0
Merge pull request #40 from OvyFlash/bot-api-7.9
OvyFlash Oct 13, 2024
7af9c32
Add error returning from DocumentConfig.BaseFile.params() method
OvyFlash Oct 13, 2024
5fd4591
BotAPI 7.10 implementation
OvyFlash Oct 13, 2024
36756d9
Merge pull request #41 from OvyFlash/bot-api-7.10
OvyFlash Oct 13, 2024
269bc52
add animation type for inputMediaFiles
Oct 14, 2024
129367a
update go.mod for v6, update go version
umputun Oct 28, 2024
de5d7a3
update docs with refs to the new module
umputun Oct 28, 2024
e495a5a
Merge pull request #43 from umputun/master
OvyFlash Oct 29, 2024
1376e01
Add CODEOWNERS file
OvyFlash Oct 30, 2024
e79bf7d
fix: typo
iamwavecut Oct 30, 2024
383e626
breaking: rename package while switching to tags
iamwavecut Nov 7, 2024
01dd2c6
noop: create examples
iamwavecut Nov 7, 2024
0961022
Merge pull request #44 from iamwavecut/master
iamwavecut Nov 7, 2024
8afd2ac
Update README.md
iamwavecut Nov 7, 2024
e683740
Update go.mod
iamwavecut Nov 7, 2024
8a154ea
Update configs.go
iamwavecut Nov 7, 2024
41e4230
Merge pull request #42 from open-ssl/add_animation_for_input_media
iamwavecut Nov 7, 2024
020f85f
Update README.md
iamwavecut Nov 7, 2024
851f233
fix: typo
iamwavecut Nov 7, 2024
3f2ca0c
Update go.mod
iamwavecut Dec 19, 2024
4350cc4
fix: unwraps `PaidMediaConfig` to allow paid media in MediaGroupConfig
iamwavecut Mar 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
- name: Set up Go 1.23
uses: actions/setup-go@v5
with:
go-version: ^1.15
go-version: "1.23"
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Build
run: go build -v .
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
coverage.out
tmp/
book/
.vscode/
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @iamwavecut @zhuk-kk
178 changes: 87 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,121 +1,117 @@
# Golang bindings for the Telegram Bot API
# Golang Bindings for the Telegram Bot API
[![Go Reference](https://pkg.go.dev/badge/github.com/OvyFlash/telegram-bot-api.svg)](https://pkg.go.dev/github.com/OvyFlash/telegram-bot-api)
[![Test](https://github.com/OvyFlash/telegram-bot-api/actions/workflows/test.yml/badge.svg)](https://github.com/OvyFlash/telegram-bot-api/actions/workflows/test.yml)

[![Go Reference](https://pkg.go.dev/badge/github.com/go-telegram-bot-api/telegram-bot-api/v5.svg)](https://pkg.go.dev/github.com/go-telegram-bot-api/telegram-bot-api/v5)
[![Test](https://github.com/go-telegram-bot-api/telegram-bot-api/actions/workflows/test.yml/badge.svg)](https://github.com/go-telegram-bot-api/telegram-bot-api/actions/workflows/test.yml)
# Headline

All methods are fairly self-explanatory, and reading the [godoc](https://pkg.go.dev/github.com/go-telegram-bot-api/telegram-bot-api/v5) page should
explain everything. If something isn't clear, open an issue or submit
a pull request.
This is a maintained fork of go-telegram-bot-api that preserves the original design while staying current with the latest Telegram Bot API specifications. It continues the development of the original [github.com/go-telegram-bot-api](https://github.com/go-telegram-bot-api/telegram-bot-api) package.

There are more tutorials and high-level information on the website, [go-telegram-bot-api.dev](https://go-telegram-bot-api.dev).
## Features

The scope of this project is just to provide a wrapper around the API
without any additional features. There are other projects for creating
something with plugins and command handlers without having to design
all that yourself.
- Complete coverage of the Telegram Bot API
- Simple and intuitive interface
- Minimal dependencies
- Production-ready and actively maintained
- Preserves original API structure for easy migration

Join [the development group](https://telegram.me/go_telegram_bot_api) if
you want to ask questions or discuss development.
## Installation

## Example

First, ensure the library is installed and up to date by running
`go get -u github.com/go-telegram-bot-api/telegram-bot-api/v5`.

This is a very simple bot that just displays any gotten updates,
then replies it to that chat.

```go
package main

import (
"log"

tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)

func main() {
bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken")
if err != nil {
log.Panic(err)
}

bot.Debug = true

log.Printf("Authorized on account %s", bot.Self.UserName)

u := tgbotapi.NewUpdate(0)
u.Timeout = 60

updates := bot.GetUpdatesChan(u)
Install the latest version:
```bash
go get -u github.com/OvyFlash/telegram-bot-api
```

for update := range updates {
if update.Message != nil { // If we got a message
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)

msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text)
msg.ReplyToMessageID = update.Message.MessageID
> ❗ Tag versioning is discouraged due to the unstable nature of the Telegram Bot API, and it might break at any time after the API changes.
> ~~`go get -u github.com/OvyFlash/telegram-bot-api/v7`~~

bot.Send(msg)
}
}
}
```
## Quick Start

If you need to use webhooks (if you wish to run on Google App Engine),
you may use a slightly different method.
Here's a simple echo bot using polling:

```go
package main

import (
"log"
"net/http"

"github.com/go-telegram-bot-api/telegram-bot-api/v5"
"log"
"time"
api "github.com/OvyFlash/telegram-bot-api"
)

func main() {
bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken")
if err != nil {
log.Fatal(err)
}
bot, err := api.NewBotAPI("BOT_TOKEN")
if err != nil {
panic(err)
}

bot.Debug = true
log.Printf("Authorized on account %s", bot.Self.UserName)

log.Printf("Authorized on account %s", bot.Self.UserName)
updateConfig := api.NewUpdate(0)
updateConfig.Timeout = 60
updatesChannel := bot.GetUpdatesChan(updateConfig)

wh, _ := tgbotapi.NewWebhookWithCert("https://www.example.com:8443/"+bot.Token, "cert.pem")
// Optional: Clear initial updates
time.Sleep(time.Millisecond * 500)
updatesChannel.Clear()

_, err = bot.Request(wh)
if err != nil {
log.Fatal(err)
}
for update := range updatesChannel {
if update.Message == nil {
continue
}

info, err := bot.GetWebhookInfo()
if err != nil {
log.Fatal(err)
}
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)

if info.LastErrorDate != 0 {
log.Printf("Telegram callback failed: %s", info.LastErrorMessage)
}
msg := api.NewMessage(update.Message.Chat.ID, update.Message.Text)
msg.ReplyParameters.MessageID = update.Message.MessageID

updates := bot.ListenForWebhook("/" + bot.Token)
go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil)

for update := range updates {
log.Printf("%+v\n", update)
}
bot.Send(msg)
}
}
```

If you need, you may generate a self-signed certificate, as this requires
HTTPS / TLS. The above example tells Telegram that this is your
certificate and that it should be trusted, even though it is not
properly signed.
## Webhook Setup

For webhook implementation:
1. Check the [examples](./examples) folder for examples of webhook implementations
2. Use HTTPS (required by Telegram)
- Generate SSL certificate:
```bash
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3560 -subj "//O=Org\CN=Test" -nodes

Now that [Let's Encrypt](https://letsencrypt.org) is available,
you may wish to generate your free TLS certificate there.
```
- Bring your own SSL certificate. [Let's Encrypt](https://letsencrypt.org) is recommended for free TLS certificates in production.

## Documentation

- [GoDoc](https://pkg.go.dev/github.com/OvyFlash/telegram-bot-api)
- Check the [examples](./examples) directory for more use cases


## Contributing

- Issues and feature requests are welcome
- Pull requests should maintain the existing design philosophy
- The focus is on providing a clean API wrapper without additional features

## License

>The [MIT License](./LICENSE.txt)
>
>Copyright (c) 2015 Syfaro
>
>Permission is hereby granted, free of charge, to any person obtaining a copy
>of this software and associated documentation files (the "Software"), to deal
>in the Software without restriction, including without limitation the rights
>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
>copies of the Software, and to permit persons to whom the Software is
>furnished to do so, subject to the following conditions:
>
>The above copyright notice and this permission notice shall be included in all
>copies or substantial portions of the Software.
>
>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
>SOFTWARE.
Loading
Loading