Memehub-GmbH-Co-KG / MemeHub-Bot

MIT License
0 stars 1 forks source link

Updating the username often surpasses the Telegram API rate limit #2

Open leifb opened 4 years ago

leifb commented 4 years ago

This has to be fixed, otherwise the username will not be updated for all memes.

Error messages look somesthing like this:

{
  "error": {
    "code": 429,
    "response": {
      "ok": false,
      "error_code": 429,
      "description": "Too Many Requests: retry after 5",
      "parameters": {
        "retry_after": 5
      }
    },
    "description": "Too Many Requests: retry after 5",
    "parameters": {
      "retry_after": 5
    },
    "on": {
      "method": "editMessageCaption",
      "payload": {
        "caption": "@xxx | #TV ยท #lotr",
        "chat_id": -x,
        "message_id": 10073,
        "reply_markup": {
          "inline_keyboard": [
            [
              {
                "text": "๐Ÿ‘ - 10",
                "callback_data": "vote:like"
              },
              {
                "text": "๐Ÿ™",
                "callback_data": "vote:weeb"
              },
              {
                "text": "โ—๏ธ",
                "callback_data": "vote:condemn"
              }
            ]
          ]
        }
      }
    }
  },
  "meme": {
    "_id": "x",
    "file_unique_id": null,
    "type": "photo",
    "poster_id": x,
    "private_message_id": 19190,
    "group_message_id": 10073,
    "categories": [
      "TV",
      "lotr"
    ],
    "votes": {
      "like": [
        x
      ]
    },
    "post_date": "x"
  }
}
leifb commented 4 years ago

I would suggest doing the update much slower, so that other requests will not be affected by the rate limits. If you feel good you might want to store in the db that the username has to be changed until all messages have been updated. This would allow the bot to crash during the process.