Class MessageQueueing
Custom extension class, implements a basic message queue to avoid hitting 429-Errors (Too many requests)
Inheritance
Inherited Members
Namespace: TelegramBotApi.Extensions.MessageQueueing
Assembly: TelegramBotApi.dll
Syntax
public static class MessageQueueing
Methods
| Improve this Doc View SourceSendMessageWithQueue(TelegramBot, ChatId, String, Boolean, Boolean, Int32, ReplyMarkupBase)
Sends a text message with a queue. Using this method you should never hit 429-Errors (Too many requests).
If you do, please open a GitHub issue.
Note that the parameters disableWebPagePreview
and disableNotification
will be overridden by the last merged message, if you enable message merging. If you want to use this method to send messages,
you need to call the StartQueue(TelegramBot, ParseMode, Boolean) method to start it.
Declaration
public static void SendMessageWithQueue(this TelegramBot Bot, ChatId chatId, string text, bool disableWebPagePreview = false, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
TelegramBot | Bot | The Telegram Bot object for which a message is enqueued |
ChatId | chatId | The id or channel username of the chat to send the message to |
System.String | text | The text of the message |
System.Boolean | disableWebPagePreview | If this is true, no website preview will be shown |
System.Boolean | disableNotification | If this is true, users will not receive a notification or a silent one for this message |
System.Int32 | replyToMessageId | The message id of the message to reply to in this chat, if any |
ReplyMarkupBase | replyMarkup |
StartQueue(TelegramBot, ParseMode, Boolean)
Start the message queue. Messages enqueued by SendMessageWithQueue(TelegramBot, ChatId, String, Boolean, Boolean, Int32, ReplyMarkupBase) will only be sent after this method was called.
Declaration
public static void StartQueue(this TelegramBot Bot, ParseMode parseMode, bool mergeMessages = true)
Parameters
Type | Name | Description |
---|---|---|
TelegramBot | Bot | The Telegram Bot object for which the message queue is started |
ParseMode | parseMode | All messages that are enqueued with SendMessageWithQueue(TelegramBot, ChatId, String, Boolean, Boolean, Int32, ReplyMarkupBase) will use this ParseMode. |
System.Boolean | mergeMessages | If this is true, multiple queued messages can be merged into one, seperated by two newlines, for more efficient message sending. Note that messages having a replyToMessageId or replyMarkup will never be merged. |
StopQueue(TelegramBot)
Stop the message queue. Messages enqueued by SendMessageWithQueue(TelegramBot, ChatId, String, Boolean, Boolean, Int32, ReplyMarkupBase) will no longer be sent. The current queue will be emptied.
Declaration
public static void StopQueue(this TelegramBot Bot)
Parameters
Type | Name | Description |
---|---|---|
TelegramBot | Bot | The Telegram Bot object for which the message queue is stopped |