{"action":"created","issue":{"url":"https://api.github.com/repos/botman/botman/issues/782","repository_url":"https://api.github.com/repos/botman/botman","labels_url":"https://api.github.com/repos/botman/botman/issues/782/labels{/name}","comments_url":"https://api.github.com/repos/botman/botman/issues/782/comments","events_url":"https://api.github.com/repos/botman/botman/issues/782/events","html_url":"https://github.com/botman/botman/issues/782","id":315822937,"number":782,"title":"Does BotMan provide a way to delay messages (e.g. to conform to API rate limits)","user":{"login":"Coksnuss","id":3457747,"avatar_url":"https://avatars2.githubusercontent.com/u/3457747?v=4","gravatar_id":"","url":"https://api.github.com/users/Coksnuss","html_url":"https://github.com/Coksnuss","followers_url":"https://api.github.com/users/Coksnuss/followers","following_url":"https://api.github.com/users/Coksnuss/following{/other_user}","gists_url":"https://api.github.com/users/Coksnuss/gists{/gist_id}","starred_url":"https://api.github.com/users/Coksnuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Coksnuss/subscriptions","organizations_url":"https://api.github.com/users/Coksnuss/orgs","repos_url":"https://api.github.com/users/Coksnuss/repos","events_url":"https://api.github.com/users/Coksnuss/events{/privacy}","received_events_url":"https://api.github.com/users/Coksnuss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-19T10:43:07Z","updated_at":"2018-04-19T15:37:23Z","closed_at":null,"author_association":"NONE","body":"- BotMan Version: 2.3.2\r\n- PHP Version: 7.2.4\r\n- Messaging Service(s): Telegram\r\n- Cache Driver: FilesystemCache\r\n\r\n### Description:\r\nJust yesterday I found this framework and I am now considering to migrate my existing Telegram bot using this framework. My bot sometimes requires to deliver notifications to a lot of users in the least time possible. Because the Telegram API imposes a limit on how many messsages are allowed to be send at any time (1 msg/sec and 20 msg/min within a particular chat, 30 msg/sec to different chats)\\[1\\], the bot would very quickly start seeing 429 errors. In order to avoid hitting these limits I implemented a Guzzle middleware that transparently keeps track of the requests that are targeted to the 'sendMessage' endpoint of the Telegram API and, if necessary, delays requests to avoid hitting the limits.\r\n\r\n**TL;DR;**\r\nSo my question is: **Is it possible to delay messages sent by the bot by BotMan (e.g. via reply()) a specified amount of time?**.\r\n\r\nIt goes without saying that I am searching for a non-blocking mechanism in order to continue code execution while delaying specific requests. However, As far as I can tell, the Interfaces that the bot uses for HTTP communication (e.g. \\BotMan\\BotMan\\Interfaces\\HttpInterface) are not supposed to work with asynchronous requests (i.e. they do not support the returning of promises). Thus, I am a bit puzzled on how to implement a throttling middleware (if, at all, possible).\r\n\r\n\\[1\\](https://core.telegram.org/bots/faq#my-bot-is-hitting-limits-how-do-i-avoid-this)"},"comment":{"url":"https://api.github.com/repos/botman/botman/issues/comments/382782000","html_url":"https://github.com/botman/botman/issues/782#issuecomment-382782000","issue_url":"https://api.github.com/repos/botman/botman/issues/782","id":382782000,"user":{"login":"Coksnuss","id":3457747,"avatar_url":"https://avatars2.githubusercontent.com/u/3457747?v=4","gravatar_id":"","url":"https://api.github.com/users/Coksnuss","html_url":"https://github.com/Coksnuss","followers_url":"https://api.github.com/users/Coksnuss/followers","following_url":"https://api.github.com/users/Coksnuss/following{/other_user}","gists_url":"https://api.github.com/users/Coksnuss/gists{/gist_id}","starred_url":"https://api.github.com/users/Coksnuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Coksnuss/subscriptions","organizations_url":"https://api.github.com/users/Coksnuss/orgs","repos_url":"https://api.github.com/users/Coksnuss/repos","events_url":"https://api.github.com/users/Coksnuss/events{/privacy}","received_events_url":"https://api.github.com/users/Coksnuss/received_events","type":"User","site_admin":false},"created_at":"2018-04-19T15:37:23Z","updated_at":"2018-04-19T15:37:23Z","author_association":"NONE","body":"> I think the most useful solution would be to create a sending middleware\r\n\r\nAny suggestions on implementing it in an asynchronous way (i.e. without `sleep`)\r\n"}}
{"actor":{"display_login":"Coksnuss"}}