Skip to content
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

[Error] 400 Bad Request: invalid sticker emojis #1236

Open
longlin10086 opened this issue Nov 11, 2024 · 1 comment
Open

[Error] 400 Bad Request: invalid sticker emojis #1236

longlin10086 opened this issue Nov 11, 2024 · 1 comment

Comments

@longlin10086
Copy link

longlin10086 commented Nov 11, 2024

Bug Report

"node-telegram-bot-api": "^0.66.0",

Expected Behavior

When I used createNewStickerSet I got an error.(The error message is at the buttom)

await bot.createNewStickerSet(
  userId,
  stickerSetName,
  `User ${userId}'s stickers`,
  uploadedPhoto.file_id,
  "😊"
);

This is the API right now:

  /**
   * Use this method to create new sticker set owned by a user.
   *
   * The bot will be able to edit the created sticker set.
   *
   * You must use exactly one of the fields *png_sticker*, *tgs_sticker*, or *webm_sticker*
   *
   * @param  {Number} userId User identifier of created sticker set owner
   * @param  {String} name Short name of sticker set, to be used in `t.me/addstickers/` URLs (e.g.,   *"animals"*). Can contain only english letters, digits and underscores.
   *  Must begin with a letter, can't contain consecutive underscores and must end in `"_by_<bot_username>"`. `<bot_username>` is case insensitive. 1-64 characters.
   * @param  {String} title Sticker set title, 1-64 characters
   * @param  {String|stream.Stream|Buffer} pngSticker Png image with the sticker, must be up to 512 kilobytes in size,
   *  dimensions must not exceed 512px, and either width or height must be exactly 512px.
   * @param  {String} emojis One or more emoji corresponding to the sticker
   * @param  {Object} [options] Additional Telegram query options
   * @param  {Object} [fileOptions] Optional file related meta-data
   * @return {Promise}  True on success
   * @see https://core.telegram.org/bots/api#createnewstickerset
   */
  createNewStickerSet(userId, name, title, pngSticker, emojis, options = {}, fileOptions = {}) {
    const opts = {
      qs: options,
    };
    opts.qs.user_id = userId;
    opts.qs.name = name;
    opts.qs.title = title;
    opts.qs.emojis = emojis;
    opts.qs.mask_position = stringify(options.mask_position);
    try {
      const sendData = this._formatSendData('png_sticker', pngSticker, fileOptions);
      opts.formData = sendData[0];
      opts.qs.png_sticker = sendData[1];
    } catch (ex) {
      return Promise.reject(ex);
    }
    return this._request('createNewStickerSet', opts);
  }

But I found that in the newest telegram API it seems like we don't need to send the key emoji :
https://core.telegram.org/bots/api#createnewstickerset
2024-11-11 21 06 45

The cURL command can be like:

curl --location 'https://api.telegram.org/botxxxx:XXXXXXXXX/createNewStickerSet' \
--form 'user_id=""' \
--form 'name=""' \
--form 'title=""' \
--form 'stickers=""' \
--form 'sticker_format=""'

Maybe the api needs to be updated, or there is other way to get rid of this error.

Actual Behavior

Error processing sticker 1:  5 |    * @private
 6 |    * @param  {String} code Error code
 7 |    * @param  {String} message Error message
 8 |    */
 9 |   constructor(code, message) {
10 |     super(`${code}: ${message}`);
         ^
error: ETELEGRAM: 400 Bad Request: invalid sticker emojis
 code: "ETELEGRAM"
@longlin10086
Copy link
Author

Well, I have solved this problem. It doesn't happen on this function, but the other in my code.
However, I will keep this issue open for the confused API difference.

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

No branches or pull requests

1 participant