Skip to content

🛠️ fix: models.InputSticker model handling/usage #201

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

Merged
merged 3 commits into from
Aug 11, 2025

Conversation

fregin
Copy link
Contributor

@fregin fregin commented Jul 29, 2025

Current version of go-telegram/bot does not support createNewStickerSet operation

Because of models.InputSticker struct and its handling in build_request_form.go

If we are trying to create new sticker with such code:

_, err = b.CreateNewStickerSet(
	ctx,
	&bot.CreateNewStickerSetParams{
		...
		Stickers: []models.InputSticker{
	              {
		              Sticker: &models.InputFileUpload{
			              Filename: "myresource.webm",
			              Data: ...,
		              },
		              Format: "video",
		              ...,
	              },
	},
)

You will get next error: Bad Request: video stickers can't be uploaded by URL

But we are uploading file, not URL, are we?

This pull request contains two things:

  1. Proper handling models.InputSticker in build_request_form.go
  2. Correct struct signature referenced to Telegram API Docs, where models.InputSticker model contains sticker: String field (not sticker: InputFile)

And now we can do this without error:

_, err = b.CreateNewStickerSet(
	ctx,
	&bot.CreateNewStickerSetParams{
		...
		Stickers: []models.InputSticker{
	              {
		              Sticker: "attach://myresources.webm",
		              Format: "video",
		              ...,
		              StickerAttachment: ...
	              },
	},
)

@fregin fregin changed the title fix: models.InputSticker model processing 🛠️🔩🔧 fix: models.InputSticker model handling/usage Jul 29, 2025
@fregin fregin changed the title 🛠️🔩🔧 fix: models.InputSticker model handling/usage 🛠️ fix: models.InputSticker model handling/usage Jul 29, 2025
@negasus
Copy link
Contributor

negasus commented Aug 1, 2025

Can you add documentation to readme.md about this method?

@negasus negasus self-assigned this Aug 1, 2025
@fregin
Copy link
Contributor Author

fregin commented Aug 1, 2025

Can you add documentation to readme.md about this method?

Sure

fileContent, _ := images.ReadFile("images/telegram.png")

inputSticker1 := models.InputSticker{
Sticker: "https://github.com/go-telegram/bot/blob/main/examples/create_new_sticker_set/images/telegram.png?raw=true",
Copy link
Contributor Author

@fregin fregin Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some restrictions for input sticker files, so I could not find any Telegram logo or Golang logo with .PNG extension and with sizes 512x512 (one size can be less)

Such link will be available after merge

// you should handle this error properly in your code.
panic(err)
}
botUsername = user.Username
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like bot.Bot can store such info, do not you think so?

Maybe create an issue?
But what to do with skip-get-me option? No get me, no info.

@fregin
Copy link
Contributor Author

fregin commented Aug 2, 2025

Done!

@negasus negasus merged commit 24c36eb into go-telegram:main Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants