Class TelegramBot
Represents an interface to the telegram bot api.
Inheritance
Inherited Members
Namespace: TelegramBotApi
Assembly: TelegramBotApi.dll
Syntax
public class TelegramBot
Constructors
| Improve this Doc View SourceTelegramBot(String)
Initializes a new interface to the telegram bot api.
Declaration
public TelegramBot(string token)
Parameters
Type | Name | Description |
---|---|---|
System.String | token | The token you can obtain from @BotFather |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Throws if the |
Properties
| Improve this Doc View SourceIsMessageQueueing
Whether the message queue is enabled.
Declaration
public bool IsMessageQueueing { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsReceiving
Whether the bot is currently trying to recieve messages
Declaration
public bool IsReceiving { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
LongPollingTimeout
Timeout in seconds for long polling. Defaults to 100. Set this to 0 if you want to use short polling.
Declaration
public int LongPollingTimeout { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceAddStickerToSet(Int32, String, SendFile, String, MaskPosition)
Use this method to add a new sticker to a set created by the bot. Returns True on success.
Declaration
public bool AddStickerToSet(int userId, string name, SendFile pngSticker, string emojis, MaskPosition maskPosition = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | User identifier of sticker set owner |
System.String | name | Sticker set name |
SendFile | 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. One of either SendFileId, SendFileUrl or SendFileMultipart |
System.String | emojis | One or more emoji corresponding to the sticker |
MaskPosition | maskPosition | An object for where the mask should be placed on faces, if the sticker is one |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
AddStickerToSetAsync(Int32, String, SendFile, String, MaskPosition)
Use this method to add a new sticker to a set created by the bot. Returns True on success.
Declaration
public Task<bool> AddStickerToSetAsync(int userId, string name, SendFile pngSticker, string emojis, MaskPosition maskPosition = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | User identifier of sticker set owner |
System.String | name | Sticker set name |
SendFile | 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. One of either SendFileId, SendFileUrl or SendFileMultipart |
System.String | emojis | One or more emoji corresponding to the sticker |
MaskPosition | maskPosition | An object for where the mask should be placed on faces, if the sticker is one |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
AnswerCallbackQuery(String, String, Boolean, String, Int32)
Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
Declaration
public bool AnswerCallbackQuery(string callbackQueryId, string text = null, bool showAlert = false, string url = null, int cacheTime = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | callbackQueryId | Unique identifier for the query to be answered |
System.String | text | Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters |
System.Boolean | showAlert | If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. |
System.String | url | URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @Botfather, specify the URL that opens your game – note that this will only work if the query comes from a callback_game button. Otherwise, you may use links like t.me/your_bot? start = XXXX that open your bot with a parameter. |
System.Int32 | cacheTime | The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0. |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
AnswerCallbackQueryAsync(String, String, Boolean, String, Int32)
Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
Declaration
public Task<bool> AnswerCallbackQueryAsync(string callbackQueryId, string text = null, bool showAlert = false, string url = null, int cacheTime = 0)
Parameters
Type | Name | Description |
---|---|---|
System.String | callbackQueryId | Unique identifier for the query to be answered |
System.String | text | Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters |
System.Boolean | showAlert | If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. |
System.String | url | URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @Botfather, specify the URL that opens your game – note that this will only work if the query comes from a callback_game button. Otherwise, you may use links like t.me/your_bot? start = XXXX that open your bot with a parameter. |
System.Int32 | cacheTime | The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
AnswerInlineQuery(String, InlineQueryResult[], Int32, Boolean, String, String, String)
Use this method to send answers to an inline query. On success, True is returned. No more than 50 results per query are allowed.
Declaration
public bool AnswerInlineQuery(string inlineQueryId, InlineQueryResult[] results, int cacheTime = 300, bool isPersonal = false, string nextOffset = null, string switchPmText = null, string switchPmParameter = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineQueryId | Unique identifier for the answered query |
InlineQueryResult[] | results | The results for the inline query |
System.Int32 | cacheTime | The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300. |
System.Boolean | isPersonal | Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query |
System.String | nextOffset | Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes. |
System.String | switchPmText | If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter |
System.String | switchPmParameter | Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed. |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
AnswerInlineQueryAsync(String, InlineQueryResult[], Int32, Boolean, String, String, String)
Use this method to send answers to an inline query. On success, True is returned. No more than 50 results per query are allowed.
Declaration
public Task<bool> AnswerInlineQueryAsync(string inlineQueryId, InlineQueryResult[] results, int cacheTime = 300, bool isPersonal = false, string nextOffset = null, string switchPmText = null, string switchPmParameter = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineQueryId | Unique identifier for the answered query |
InlineQueryResult[] | results | The results for the inline query |
System.Int32 | cacheTime | The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300. |
System.Boolean | isPersonal | Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query |
System.String | nextOffset | Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes. |
System.String | switchPmText | If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter |
System.String | switchPmParameter | Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
AnswerPreCheckoutQuery(String, Boolean, String)
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
Declaration
public bool AnswerPreCheckoutQuery(string preCheckoutQueryId, bool ok, string errorMessage = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | preCheckoutQueryId | Unique identifier for the query to be answered |
System.Boolean | ok | Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. |
System.String | errorMessage | Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user. |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
AnswerPreCheckoutQueryAsync(String, Boolean, String)
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
Declaration
public Task<bool> AnswerPreCheckoutQueryAsync(string preCheckoutQueryId, bool ok, string errorMessage = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | preCheckoutQueryId | Unique identifier for the query to be answered |
System.Boolean | ok | Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems. |
System.String | errorMessage | Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
AnswerShippingQuery(String, Boolean, ShippingOption[], String)
If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
Declaration
public bool AnswerShippingQuery(string shippingQueryId, bool ok, ShippingOption[] shippingOptions = null, string errorMessage = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | shippingQueryId | Unique identifier for the query to be answered |
System.Boolean | ok | Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) |
ShippingOption[] | shippingOptions | Required if ok is True. An array of available shipping options. |
System.String | errorMessage | Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user. |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
AnswerShippingQueryAsync(String, Boolean, ShippingOption[], String)
If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
Declaration
public Task<bool> AnswerShippingQueryAsync(string shippingQueryId, bool ok, ShippingOption[] shippingOptions = null, string errorMessage = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | shippingQueryId | Unique identifier for the query to be answered |
System.Boolean | ok | Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) |
ShippingOption[] | shippingOptions | Required if ok is True. An array of available shipping options. |
System.String | errorMessage | Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
ApiMethod<T>(String, Dictionary<String, Object>, Int32)
Executes a call to the telegram bot API. Mainly used by the other methods, but you can use it for non-implemented methods as well.
Declaration
public T ApiMethod<T>(string method, Dictionary<string, object> args = null, int timeout = 100)
Parameters
Type | Name | Description |
---|---|---|
System.String | method | The name of the telegram bot API method to call |
System.Collections.Generic.Dictionary<System.String, System.Object> | args | The args for the method, their names as keys and their values as values |
System.Int32 | timeout | The timeout of the http request |
Returns
Type | Description |
---|---|
T | The response object |
Type Parameters
Name | Description |
---|---|
T | Type of object being returned |
ApiMethodAsync<T>(String, Dictionary<String, Object>, Int32)
Executes a call to the telegram bot API. Mainly used by the other methods, but you can use it for non-implemented methods as well.
Declaration
public Task<T> ApiMethodAsync<T>(string method, Dictionary<string, object> args = null, int timeout = 100)
Parameters
Type | Name | Description |
---|---|---|
System.String | method | The name of the telegram bot API method to call |
System.Collections.Generic.Dictionary<System.String, System.Object> | args | The args for the method, their names as keys and their values as values |
System.Int32 | timeout | The timeout of the http request |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | The response object |
Type Parameters
Name | Description |
---|---|
T | Type of object being returned |
BanChatMember(ChatId, Int32, DateTime)
Kicks a member from a chat. If the chat is a channel or a supergroup, the kicked user can't return without being unbanned by an admin first. Admins can re-add banned users.
Declaration
public bool BanChatMember(ChatId chatId, int userId, DateTime untilDate = default(DateTime))
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | The chat id or the channel username of the chat to kick the user from |
System.Int32 | userId | The Id of the user to be kicked |
System.DateTime | untilDate | Date when the user will be automatically unbanned. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
BanChatMemberAsync(ChatId, Int32, DateTime)
Kicks a member from a chat. If the chat is a channel or a supergroup, the kicked user can't return without being unbanned by an admin first. Admins can re-add banned users.
Declaration
public Task<bool> BanChatMemberAsync(ChatId chatId, int userId, DateTime untilDate = default(DateTime))
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | The chat id or the channel username of the chat to kick the user from |
System.Int32 | userId | The Id of the user to be kicked |
System.DateTime | untilDate | Date when the user will be automatically unbanned. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
ClearUpdates()
Marks all pending updates as read. Don't use this while the bot is receiving.
Declaration
public void ClearUpdates()
ClearUpdatesAsync()
Marks all pending updates as read. Don't use this while the bot is receiving.
Declaration
public Task ClearUpdatesAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
CreateNewStickerSet(Int32, String, String, SendFile, String, Boolean, MaskPosition)
Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success.
Declaration
public bool CreateNewStickerSet(int userId, string name, string title, SendFile pngSticker, string emojis, bool containsMasks = false, MaskPosition maskPosition = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | User identifier of created sticker set owner |
System.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. |
System.String | title | Sticker set title, 1-64 characters |
SendFile | 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. One of either SendFileId, SendFileUrl or SendFileMultipart |
System.String | emojis | One or more emoji corresponding to the sticker |
System.Boolean | containsMasks | Pass True, if a set of mask stickers should be created |
MaskPosition | maskPosition | An object for position where the mask should be placed on faces |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
CreateNewStickerSetAsync(Int32, String, String, SendFile, String, Boolean, MaskPosition)
Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success.
Declaration
public Task<bool> CreateNewStickerSetAsync(int userId, string name, string title, SendFile pngSticker, string emojis, bool containsMasks = false, MaskPosition maskPosition = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | User identifier of created sticker set owner |
System.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. |
System.String | title | Sticker set title, 1-64 characters |
SendFile | 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. One of either SendFileId, SendFileUrl or SendFileMultipart |
System.String | emojis | One or more emoji corresponding to the sticker |
System.Boolean | containsMasks | Pass True, if a set of mask stickers should be created |
MaskPosition | maskPosition | An object for position where the mask should be placed on faces |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
DeleteChatPhoto(ChatId)
Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Declaration
public bool DeleteChatPhoto(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
DeleteChatPhotoAsync(ChatId)
Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Declaration
public Task<bool> DeleteChatPhotoAsync(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
DeleteChatStickerSet(ChatId)
Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
Declaration
public bool DeleteChatStickerSet(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
DeleteChatStickerSetAsync(ChatId)
Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
Declaration
public Task<bool> DeleteChatStickerSetAsync(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
DeleteMessage(ChatId, Int32)
Use this method to delete a message, including service messages, with the following limitations:
- A message can only be deleted if it was sent less than 48 hours ago.
- Bots can delete outgoing messages in groups and supergroups.
- Bots granted can_post_messages permissions can delete outgoing messages in channels.
- If the bot is an administrator of a group, it can delete any message there.
- If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
Returns True on success.
Declaration
public bool DeleteMessage(ChatId chatId, int messageId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the message to delete |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
DeleteMessageAsync(ChatId, Int32)
Use this method to delete a message, including service messages, with the following limitations:
- A message can only be deleted if it was sent less than 48 hours ago.
- Bots can delete outgoing messages in groups and supergroups.
- Bots granted can_post_messages permissions can delete outgoing messages in channels.
- If the bot is an administrator of a group, it can delete any message there.
- If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
Returns True on success.
Declaration
public Task<bool> DeleteMessageAsync(ChatId chatId, int messageId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the message to delete |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
DeleteStickerFromSet(String)
Use this method to delete a sticker from a set created by the bot. Returns True on success.
Declaration
public bool DeleteStickerFromSet(string sticker)
Parameters
Type | Name | Description |
---|---|---|
System.String | sticker | File identifier of the sticker |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
DeleteStickerFromSetAsync(String)
Use this method to delete a sticker from a set created by the bot. Returns True on success.
Declaration
public Task<bool> DeleteStickerFromSetAsync(string sticker)
Parameters
Type | Name | Description |
---|---|---|
System.String | sticker | File identifier of the sticker |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
DeleteWebhook()
Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. Requires no parameters.
Declaration
public bool DeleteWebhook()
Returns
Type | Description |
---|---|
System.Boolean | True on success |
DeleteWebhookAsync()
Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success. Requires no parameters.
Declaration
public Task<bool> DeleteWebhookAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
DownloadFile(String)
Downloads a file and returns its stream
Declaration
public Stream DownloadFile(string fileId)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileId | The telegram file id |
Returns
Type | Description |
---|---|
System.IO.Stream | A stream containing the file |
DownloadFile(String, String)
Downloads a file to a given path
Declaration
public void DownloadFile(string fileId, string destinationPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileId | The telegram identifier of the file |
System.String | destinationPath | The path to save the file to |
DownloadFile(File)
Downloads a file and returns its stream
Declaration
public Stream DownloadFile(File file)
Parameters
Type | Name | Description |
---|---|---|
File | file | The File object obtained by GetFileAsync(String) |
Returns
Type | Description |
---|---|
System.IO.Stream | A stream containing the file |
DownloadFile(File, String)
Downloads a file to a given path
Declaration
public void DownloadFile(File file, string destinationPath)
Parameters
Type | Name | Description |
---|---|---|
File | file | The file object obtained by GetFileAsync(String) |
System.String | destinationPath | The path to send the file to |
DownloadFileAsync(String)
Downloads a file and returns its stream
Declaration
public Task<Stream> DownloadFileAsync(string fileId)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileId | The telegram file id |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.IO.Stream> | A stream containing the file |
DownloadFileAsync(String, String)
Downloads a file to a given path
Declaration
public Task DownloadFileAsync(string fileId, string destinationPath)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileId | The telegram identifier of the file |
System.String | destinationPath | The path to save the file to |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
DownloadFileAsync(File)
Downloads a file and returns its stream
Declaration
public Task<Stream> DownloadFileAsync(File file)
Parameters
Type | Name | Description |
---|---|---|
File | file | The File object obtained by GetFileAsync(String) |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.IO.Stream> | A stream containing the file |
DownloadFileAsync(File, String)
Downloads a file to a given path
Declaration
public Task DownloadFileAsync(File file, string destinationPath)
Parameters
Type | Name | Description |
---|---|---|
File | file | The file object obtained by GetFileAsync(String) |
System.String | destinationPath | The path to send the file to |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
EditMessageCaption(String, String, ParseMode, InlineKeyboardMarkup)
Use this method to edit captions of messages sent via the bot (for inline bots). On success, True is returned.
Declaration
public bool EditMessageCaption(string inlineMessageId, string caption, ParseMode parseMode = ParseMode.None, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineMessageId | Identifier of the inline message |
System.String | caption | New caption of the message |
ParseMode | parseMode | Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
InlineKeyboardMarkup | replyMarkup | An inline keyboard, if you want any |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
EditMessageCaption(ChatId, Int32, String, ParseMode, InlineKeyboardMarkup)
Use this method to edit captions of messages sent by the bot. On success, the edited Message is returned.
Declaration
public Message EditMessageCaption(ChatId chatId, int messageId, string caption, ParseMode parseMode = ParseMode.None, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the message sent by the bot |
System.String | caption | New caption of the message |
ParseMode | parseMode | Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
InlineKeyboardMarkup | replyMarkup | An inline keyboard. |
Returns
Type | Description |
---|---|
Message | The edited message |
EditMessageCaptionAsync(String, String, ParseMode, InlineKeyboardMarkup)
Use this method to edit captions of messages sent via the bot (for inline bots). On success, True is returned.
Declaration
public Task<bool> EditMessageCaptionAsync(string inlineMessageId, string caption, ParseMode parseMode = ParseMode.None, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineMessageId | Identifier of the inline message |
System.String | caption | New caption of the message |
ParseMode | parseMode | Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
InlineKeyboardMarkup | replyMarkup | An inline keyboard, if you want any |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
EditMessageCaptionAsync(ChatId, Int32, String, ParseMode, InlineKeyboardMarkup)
Use this method to edit captions of messages sent by the bot. On success, the edited Message is returned.
Declaration
public Task<Message> EditMessageCaptionAsync(ChatId chatId, int messageId, string caption, ParseMode parseMode = ParseMode.None, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the message sent by the bot |
System.String | caption | New caption of the message |
ParseMode | parseMode | Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
InlineKeyboardMarkup | replyMarkup | An inline keyboard. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The edited message |
EditMessageLiveLocation(String, Double, Double, InlineKeyboardMarkup)
Use this method to edit live location messages sent via the bot (for inline bots). A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, True is returned.
Declaration
public bool EditMessageLiveLocation(string inlineMessageId, double latitude, double longitude, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineMessageId | Identifier of the inline message |
System.Double | latitude | New latitude of the location |
System.Double | longitude | New longitude of the location |
InlineKeyboardMarkup | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
EditMessageLiveLocation(ChatId, Int32, Double, Double, InlineKeyboardMarkup)
Use this method to edit live location messages sent by the bot. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, the edited Message is returned.
Declaration
public Message EditMessageLiveLocation(ChatId chatId, int messageId, double latitude, double longitude, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the sent message |
System.Double | latitude | New latitude of the location |
System.Double | longitude | New longitude of the location |
InlineKeyboardMarkup | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
Message | The edited message |
EditMessageLiveLocationAsync(String, Double, Double, InlineKeyboardMarkup)
Use this method to edit live location messages sent via the bot (for inline bots). A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, True is returned.
Declaration
public Task<bool> EditMessageLiveLocationAsync(string inlineMessageId, double latitude, double longitude, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineMessageId | Identifier of the inline message |
System.Double | latitude | New latitude of the location |
System.Double | longitude | New longitude of the location |
InlineKeyboardMarkup | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
EditMessageLiveLocationAsync(ChatId, Int32, Double, Double, InlineKeyboardMarkup)
Use this method to edit live location messages sent by the bot. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, the edited Message is returned.
Declaration
public Task<Message> EditMessageLiveLocationAsync(ChatId chatId, int messageId, double latitude, double longitude, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the sent message |
System.Double | latitude | New latitude of the location |
System.Double | longitude | New longitude of the location |
InlineKeyboardMarkup | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The edited message |
EditMessageMedia(String, SendFile, InlineKeyboardMarkup)
Use this method to replace a media the bot sent with another one (for inline bots). On success, the edited Message is returned.
Declaration
public Message EditMessageMedia(string inlineMessageId, SendFile media, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineMessageId | Identifier of the inline message |
SendFile | media | The new media of the message |
InlineKeyboardMarkup | replyMarkup | An inline keyboard, if you want any |
Returns
Type | Description |
---|---|
Message | The edited message |
EditMessageMedia(ChatId, Int32, SendFile, InlineKeyboardMarkup)
Use this method to replace a media the bot sent with another one. On success, the edited Message is returned.
Declaration
public Message EditMessageMedia(ChatId chatId, int messageId, SendFile media, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the message sent by the bot |
SendFile | media | The new media of the message |
InlineKeyboardMarkup | replyMarkup | An inline keyboard, if you want any |
Returns
Type | Description |
---|---|
Message | The edited message |
EditMessageMediaAsync(String, SendFile, InlineKeyboardMarkup)
Use this method to replace a media the bot sent with another one (for inline bots). On success, the edited Message is returned.
Declaration
public Task<Message> EditMessageMediaAsync(string inlineMessageId, SendFile media, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineMessageId | Identifier of the inline message |
SendFile | media | The new media of the message |
InlineKeyboardMarkup | replyMarkup | An inline keyboard, if you want any |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The edited message |
EditMessageMediaAsync(ChatId, Int32, SendFile, InlineKeyboardMarkup)
Use this method to replace a media the bot sent with another one. On success, the edited Message is returned.
Declaration
public Task<Message> EditMessageMediaAsync(ChatId chatId, int messageId, SendFile media, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the message sent by the bot |
SendFile | media | The new media of the message |
InlineKeyboardMarkup | replyMarkup | An inline keyboard, if you want any |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The edited message |
EditMessageReplyMarkup(String, InlineKeyboardMarkup)
Use this method to edit only the reply markups of messages sent via the bot (for inline bots). On success, True is returned.
Declaration
public bool EditMessageReplyMarkup(string inlineMessageId, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineMessageId | Identifier of the inline message |
InlineKeyboardMarkup | replyMarkup | An inline keyboard, if you want any |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
EditMessageReplyMarkup(ChatId, Int32, InlineKeyboardMarkup)
Use this method to edit only the reply markups of messages sent by the bot. On success, the edited Message is returned.
Declaration
public Message EditMessageReplyMarkup(ChatId chatId, int messageId, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the message sent by the bot |
InlineKeyboardMarkup | replyMarkup | An inline keyboard. |
Returns
Type | Description |
---|---|
Message | The edited message |
EditMessageReplyMarkupAsync(String, InlineKeyboardMarkup)
Use this method to edit only the reply markups of messages sent via the bot (for inline bots). On success, True is returned.
Declaration
public Task<bool> EditMessageReplyMarkupAsync(string inlineMessageId, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineMessageId | Identifier of the inline message |
InlineKeyboardMarkup | replyMarkup | An inline keyboard, if you want any |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
EditMessageReplyMarkupAsync(ChatId, Int32, InlineKeyboardMarkup)
Use this method to edit only the reply markups of messages sent by the bot. On success, the edited Message is returned.
Declaration
public Task<Message> EditMessageReplyMarkupAsync(ChatId chatId, int messageId, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the message sent by the bot |
InlineKeyboardMarkup | replyMarkup | An inline keyboard. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The edited message |
EditMessageText(String, String, ParseMode, Boolean, InlineKeyboardMarkup)
Use this method to edit text and game messages sent via the bot (for inline bots). On success, True is returned.
Declaration
public bool EditMessageText(string inlineMessageId, string text, ParseMode parseMode = ParseMode.None, bool disableWebPagePreview = false, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineMessageId | Identifier of the inline message |
System.String | text | New text of the message |
ParseMode | parseMode | Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
System.Boolean | disableWebPagePreview | Disables link previews for links in this message |
InlineKeyboardMarkup | replyMarkup | An inline keyboard, if you want any |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
EditMessageText(ChatId, Int32, String, ParseMode, Boolean, InlineKeyboardMarkup)
Use this method to edit text and game messages sent by the bot. On success, the edited Message is returned.
Declaration
public Message EditMessageText(ChatId chatId, int messageId, string text, ParseMode parseMode = ParseMode.None, bool disableWebPagePreview = false, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the message sent by the bot |
System.String | text | New text of the message |
ParseMode | parseMode | Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
System.Boolean | disableWebPagePreview | Disables link previews for links in this message |
InlineKeyboardMarkup | replyMarkup | An inline keyboard. |
Returns
Type | Description |
---|---|
Message | The edited message |
EditMessageTextAsync(String, String, ParseMode, Boolean, InlineKeyboardMarkup)
Use this method to edit text and game messages sent via the bot (for inline bots). On success, True is returned.
Declaration
public Task<bool> EditMessageTextAsync(string inlineMessageId, string text, ParseMode parseMode = ParseMode.None, bool disableWebPagePreview = false, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineMessageId | Identifier of the inline message |
System.String | text | New text of the message |
ParseMode | parseMode | Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
System.Boolean | disableWebPagePreview | Disables link previews for links in this message |
InlineKeyboardMarkup | replyMarkup | An inline keyboard, if you want any |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
EditMessageTextAsync(ChatId, Int32, String, ParseMode, Boolean, InlineKeyboardMarkup)
Use this method to edit text and game messages sent by the bot. On success, the edited Message is returned.
Declaration
public Task<Message> EditMessageTextAsync(ChatId chatId, int messageId, string text, ParseMode parseMode = ParseMode.None, bool disableWebPagePreview = false, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the message sent by the bot |
System.String | text | New text of the message |
ParseMode | parseMode | Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. |
System.Boolean | disableWebPagePreview | Disables link previews for links in this message |
InlineKeyboardMarkup | replyMarkup | An inline keyboard. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The edited message |
ExportChatInviteLink(ChatId)
Use this method to generate a new invite link for a chat; any previously generated link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as String on success.
Declaration
public string ExportChatInviteLink(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.String | The invite link |
ExportChatInviteLinkAsync(ChatId)
Use this method to generate a new invite link for a chat; any previously generated link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as String on success.
Declaration
public Task<string> ExportChatInviteLinkAsync(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | The invite link |
ForwardMessage(ChatId, ChatId, Int32, Boolean)
Use this method to forward messages of any kind. On success, the sent Message is returned.
Declaration
public Message ForwardMessage(ChatId chatId, ChatId fromChatId, int messageId, bool disableNotification = false)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
ChatId | fromChatId | Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) |
System.Int32 | messageId | Message identifier in the chat specified in |
System.Boolean | disableNotification | Sends the message silently. Users will receive a notification with no sound. |
Returns
Type | Description |
---|---|
Message | The sent message |
ForwardMessageAsync(ChatId, ChatId, Int32, Boolean)
Use this method to forward messages of any kind. On success, the sent Message is returned.
Declaration
public Task<Message> ForwardMessageAsync(ChatId chatId, ChatId fromChatId, int messageId, bool disableNotification = false)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
ChatId | fromChatId | Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) |
System.Int32 | messageId | Message identifier in the chat specified in |
System.Boolean | disableNotification | Sends the message silently. Users will receive a notification with no sound. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message |
GetChat(ChatId)
Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.).
Declaration
public Chat GetChat(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
Chat | The specified chat as a Chat object |
GetChatAdministrators(ChatId)
Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
Declaration
public ChatMember[] GetChatAdministrators(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
ChatMember[] | The chat administrators |
GetChatAdministratorsAsync(ChatId)
Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
Declaration
public Task<ChatMember[]> GetChatAdministratorsAsync(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ChatMember[]> | The chat administrators |
GetChatAsync(ChatId)
Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.).
Declaration
public Task<Chat> GetChatAsync(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Chat> | The specified chat as a Chat object |
GetChatMember(ChatId, Int32)
Use this method to get information about a member of a chat.
Declaration
public ChatMember GetChatMember(ChatId chatId, int userId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
System.Int32 | userId | Telegram identifier of target user |
Returns
Type | Description |
---|---|
ChatMember | The specified chat member |
GetChatMemberAsync(ChatId, Int32)
Use this method to get information about a member of a chat.
Declaration
public Task<ChatMember> GetChatMemberAsync(ChatId chatId, int userId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
System.Int32 | userId | Telegram identifier of target user |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ChatMember> | The specified chat member |
GetChatMembersCount(ChatId)
Use this method to get the number of members in a chat.
Declaration
public int GetChatMembersCount(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Int32 | The number of chat members |
GetChatMembersCountAsync(ChatId)
Use this method to get the number of members in a chat.
Declaration
public Task<int> GetChatMembersCountAsync(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | The number of chat members |
GetFile(String)
Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again. Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
Declaration
public File GetFile(string fileId)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileId | File identifier to get info about |
Returns
Type | Description |
---|---|
File | The file object |
GetFileAsync(String)
Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again. Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
Declaration
public Task<File> GetFileAsync(string fileId)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileId | File identifier to get info about |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<File> | The file object |
GetGameHighScores(Int32, Int64, Int32)
Use this method to get data for high score tables. Will return the score of the specified user and several of his neighbors in a game. On success, returns an Array of GameHighScore objects.
Declaration
public GameHighScore[] GetGameHighScores(int userId, long chatId, int messageId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | Target user id |
System.Int64 | chatId | Unique identifier for the target chat |
System.Int32 | messageId | Identifier of the sent message |
Returns
Type | Description |
---|---|
GameHighScore[] | An array of GameHighScore |
GetGameHighScores(Int32, String)
Use this method to get data for high score tables. Will return the score of the specified user and several of his neighbors in a game. On success, returns an Array of GameHighScore objects.
Declaration
public GameHighScore[] GetGameHighScores(int userId, string inlineMessageId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | Target user id |
System.String | inlineMessageId | Identifier of the inline message |
Returns
Type | Description |
---|---|
GameHighScore[] | An array of GameHighScore |
GetGameHighScoresAsync(Int32, Int64, Int32)
Use this method to get data for high score tables. Will return the score of the specified user and several of his neighbors in a game. On success, returns an Array of GameHighScore objects.
Declaration
public Task<GameHighScore[]> GetGameHighScoresAsync(int userId, long chatId, int messageId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | Target user id |
System.Int64 | chatId | Unique identifier for the target chat |
System.Int32 | messageId | Identifier of the sent message |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<GameHighScore[]> | An array of GameHighScore |
GetGameHighScoresAsync(Int32, String)
Use this method to get data for high score tables. Will return the score of the specified user and several of his neighbors in a game. On success, returns an Array of GameHighScore objects.
Declaration
public Task<GameHighScore[]> GetGameHighScoresAsync(int userId, string inlineMessageId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | Target user id |
System.String | inlineMessageId | Identifier of the inline message |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<GameHighScore[]> | An array of GameHighScore |
GetMe()
A simple method for testing your bot's auth token. Requires no parameters. Returns basic information about the bot in form of a User object.
Declaration
public User GetMe()
Returns
Type | Description |
---|---|
User | Returns basic information about the bot in form of a User object. |
GetMeAsync()
A simple method for testing your bot's auth token. Requires no parameters. Returns basic information about the bot in form of a User object.
Declaration
public Task<User> GetMeAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<User> | Returns basic information about the bot in form of a User object. |
GetStickerSet(String)
Use this method to get a sticker set. On success, a StickerSet object is returned.
Declaration
public StickerSet GetStickerSet(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the sticker set |
Returns
Type | Description |
---|---|
StickerSet | The sticker set, of course |
GetStickerSetAsync(String)
Use this method to get a sticker set. On success, a StickerSet object is returned.
Declaration
public Task<StickerSet> GetStickerSetAsync(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the sticker set |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<StickerSet> | The sticker set, of course |
GetUpdates(UpdateType[], Int32, Int32, Int32)
Use this method to receive incoming updates
Declaration
public Update[] GetUpdates(UpdateType[] allowedUpdates = null, int timeout = 0, int offset = 0, int limit = 100)
Parameters
Type | Name | Description |
---|---|---|
UpdateType[] | allowedUpdates | Types of allowed updates |
System.Int32 | timeout | The timeout in seconds. To use short polling, set this to 0. |
System.Int32 | offset | |
System.Int32 | limit |
Returns
Type | Description |
---|---|
Update[] | The new updates |
GetUpdatesAsync(UpdateType[], Int32, Int32, Int32)
Use this method to receive incoming updates
Declaration
public Task<Update[]> GetUpdatesAsync(UpdateType[] allowedUpdates = null, int timeout = 0, int offset = 0, int limit = 100)
Parameters
Type | Name | Description |
---|---|---|
UpdateType[] | allowedUpdates | Types of allowed updates |
System.Int32 | timeout | The timeout in seconds. To use short polling, set this to 0. |
System.Int32 | offset | |
System.Int32 | limit |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Update[]> | The new updates |
GetUserProfilePhotos(Int32, Int32, Int32)
Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
Declaration
public UserProfilePictures GetUserProfilePhotos(int userId, int offset = 0, int limit = 100)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | Unique identifier of the target user |
System.Int32 | offset | Sequential number of the first photo to be returned. By default, all photos are returned. |
System.Int32 | limit | Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100. |
Returns
Type | Description |
---|---|
UserProfilePictures | The users profile photos |
GetUserProfilePhotosAsync(Int32, Int32, Int32)
Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
Declaration
public Task<UserProfilePictures> GetUserProfilePhotosAsync(int userId, int offset = 0, int limit = 100)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | Unique identifier of the target user |
System.Int32 | offset | Sequential number of the first photo to be returned. By default, all photos are returned. |
System.Int32 | limit | Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<UserProfilePictures> | The users profile photos |
GetWebhookInfo()
Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.
Declaration
public WebhookInfo GetWebhookInfo()
Returns
Type | Description |
---|---|
WebhookInfo | A WebhookInfo object |
GetWebhookInfoAsync()
Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.
Declaration
public Task<WebhookInfo> GetWebhookInfoAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<WebhookInfo> | A WebhookInfo object |
IsChatAdministrator(ChatId, Int32)
Whether an user is an admin of the specified group.
Declaration
public bool IsChatAdministrator(ChatId chatId, int userId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
System.Int32 | userId | Telegram identifier of target user |
Returns
Type | Description |
---|---|
System.Boolean | True if the user is an admin |
IsChatAdministratorAsync(ChatId, Int32)
Whether an user is an admin of the specified group.
Declaration
public Task<bool> IsChatAdministratorAsync(ChatId chatId, int userId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
System.Int32 | userId | Telegram identifier of target user |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True if the user is an admin |
KickChatMember(ChatId, Int32)
Kicks a member from a chat so that they can instantly rejoin.
Declaration
public bool KickChatMember(ChatId chatId, int userId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | The chats id or the channels username to kick the user from |
System.Int32 | userId | The user id of the user to kick |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
KickChatMemberAsync(ChatId, Int32)
Kicks a member from a chat so that they can instantly rejoin.
Declaration
public Task<bool> KickChatMemberAsync(ChatId chatId, int userId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | The chats id or the channels username to kick the user from |
System.Int32 | userId | The user id of the user to kick |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
LeaveChat(ChatId)
Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
Declaration
public bool LeaveChat(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
LeaveChatAsync(ChatId)
Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
Declaration
public Task<bool> LeaveChatAsync(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
PinChatMessage(ChatId, Int32, Boolean)
Use this method to pin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel. Returns True on success.
Declaration
public bool PinChatMessage(ChatId chatId, int messageId, bool disableNotification = false)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of a message to pin |
System.Boolean | disableNotification | Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels. |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
PinChatMessageAsync(ChatId, Int32, Boolean)
Use this method to pin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel. Returns True on success.
Declaration
public Task<bool> PinChatMessageAsync(ChatId chatId, int messageId, bool disableNotification = false)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of a message to pin |
System.Boolean | disableNotification | Pass True, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
PromoteChatMember(ChatId, Int32, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean)
Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass noting for all boolean parameters to demote a user. Returns True on success.
Declaration
public bool PromoteChatMember(ChatId chatId, int userId, bool canChangeInfo = false, bool canPostMessages = false, bool canEditMessages = false, bool canDeleteMessages = false, bool canInviteUsers = false, bool canRestrictMembers = false, bool canPinMessages = false, bool canPromoteMembers = false)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | userId | Unique identifier of target user |
System.Boolean | canChangeInfo | Pass True, if the administrator can change chat title, photo and other settings |
System.Boolean | canPostMessages | Pass True, if the administrator can create channel posts, channels only |
System.Boolean | canEditMessages | Pass True, if the administrator can edit messages of other users and can pin messages, channels only |
System.Boolean | canDeleteMessages | Pass True, if the administrator can delete messages of other users |
System.Boolean | canInviteUsers | Pass True, if the administrator can invite new users to the chat |
System.Boolean | canRestrictMembers | Pass True, if the administrator can restrict, ban or unban chat members |
System.Boolean | canPinMessages | Pass True, if the administrator can pin messages, supergroups only |
System.Boolean | canPromoteMembers | Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him) |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
PromoteChatMemberAsync(ChatId, Int32, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean)
Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass noting for all boolean parameters to demote a user. Returns True on success.
Declaration
public Task<bool> PromoteChatMemberAsync(ChatId chatId, int userId, bool canChangeInfo = false, bool canPostMessages = false, bool canEditMessages = false, bool canDeleteMessages = false, bool canInviteUsers = false, bool canRestrictMembers = false, bool canPinMessages = false, bool canPromoteMembers = false)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | userId | Unique identifier of target user |
System.Boolean | canChangeInfo | Pass True, if the administrator can change chat title, photo and other settings |
System.Boolean | canPostMessages | Pass True, if the administrator can create channel posts, channels only |
System.Boolean | canEditMessages | Pass True, if the administrator can edit messages of other users and can pin messages, channels only |
System.Boolean | canDeleteMessages | Pass True, if the administrator can delete messages of other users |
System.Boolean | canInviteUsers | Pass True, if the administrator can invite new users to the chat |
System.Boolean | canRestrictMembers | Pass True, if the administrator can restrict, ban or unban chat members |
System.Boolean | canPinMessages | Pass True, if the administrator can pin messages, supergroups only |
System.Boolean | canPromoteMembers | Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him) |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
RestrictChatMember(ChatId, Int32, DateTime, Boolean, Boolean, Boolean, Boolean)
Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. Returns True on success.
Declaration
public bool RestrictChatMember(ChatId chatId, int userId, DateTime untilDate = default(DateTime), bool canSendMessages = false, bool canSendMediaMessages = false, bool canSendOtherMessages = false, bool canSendWebPagePreviews = false)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) |
System.Int32 | userId | Unique identifier of the target user |
System.DateTime | untilDate | Date when restrictions will be lifted for the user. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever |
System.Boolean | canSendMessages | Pass True, if the user can send text messages, contacts, locations and venues |
System.Boolean | canSendMediaMessages | Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies canSendMessages |
System.Boolean | canSendOtherMessages | Pass True, if the user can send animations, games, stickers and use inline bots, implies canSendMediaMessages |
System.Boolean | canSendWebPagePreviews | Pass True, if the user may add web page previews to their messages, implies canSendMediaMessages |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
RestrictChatMemberAsync(ChatId, Int32, DateTime, Boolean, Boolean, Boolean, Boolean)
Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. Returns True on success.
Declaration
public Task<bool> RestrictChatMemberAsync(ChatId chatId, int userId, DateTime untilDate = default(DateTime), bool canSendMessages = false, bool canSendMediaMessages = false, bool canSendOtherMessages = false, bool canSendWebPagePreviews = false)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) |
System.Int32 | userId | Unique identifier of the target user |
System.DateTime | untilDate | Date when restrictions will be lifted for the user. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever |
System.Boolean | canSendMessages | Pass True, if the user can send text messages, contacts, locations and venues |
System.Boolean | canSendMediaMessages | Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies canSendMessages |
System.Boolean | canSendOtherMessages | Pass True, if the user can send animations, games, stickers and use inline bots, implies canSendMediaMessages |
System.Boolean | canSendWebPagePreviews | Pass True, if the user may add web page previews to their messages, implies canSendMediaMessages |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
SendAnimation(ChatId, SendFile, Int32, Int32, Int32, SendFile, String, ParseMode, Boolean, Int32, ReplyMarkupBase)
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
Declaration
public Message SendAnimation(ChatId chatId, SendFile animation, int duration = 0, int width = 0, int height = 0, SendFile thumb = null, string caption = null, ParseMode parseMode = ParseMode.None, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
SendFile | animation | The animation to send. One of SendFileId, SendFileUrl or SendFileMultipart |
System.Int32 | duration | Optional. The duration of the animation in seconds |
System.Int32 | width | Optional. Width of the animation |
System.Int32 | height | Optional. Height of the animation |
SendFile | thumb | Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
System.String | caption | Optional. Caption for the animation message |
ParseMode | parseMode | Optional. Parse mode for the animation caption |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
Message | The sent message on success |
SendAnimationAsync(ChatId, SendFile, Int32, Int32, Int32, SendFile, String, ParseMode, Boolean, Int32, ReplyMarkupBase)
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.
Declaration
public Task<Message> SendAnimationAsync(ChatId chatId, SendFile animation, int duration = 0, int width = 0, int height = 0, SendFile thumb = null, string caption = null, ParseMode parseMode = ParseMode.None, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
SendFile | animation | The animation to send. One of SendFileId, SendFileUrl or SendFileMultipart |
System.Int32 | duration | Optional. The duration of the animation in seconds |
System.Int32 | width | Optional. Width of the animation |
System.Int32 | height | Optional. Height of the animation |
SendFile | thumb | Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
System.String | caption | Optional. Caption for the animation message |
ParseMode | parseMode | Optional. Parse mode for the animation caption |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message on success |
SendAudio(ChatId, SendFile, String, ParseMode, Int32, String, String, SendFile, Boolean, Int32, ReplyMarkupBase)
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. On success, the sent Message is returned.
Declaration
public Message SendAudio(ChatId chatId, SendFile audio, string caption = null, ParseMode parseMode = ParseMode.None, int duration = 0, string performer = null, string title = null, SendFile thumb = null, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | The chat id or channel username of the chat to send the message to |
SendFile | audio | The audio file. Either one of SendFileId, SendFileUrl or SendFileMultipart |
System.String | caption | The caption of the audio file, if any |
ParseMode | parseMode | The parse mode of the caption, if any |
System.Int32 | duration | Duration of the audio in seconds |
System.String | performer | Performer |
System.String | title | Track name |
SendFile | thumb | Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
System.Boolean | disableNotification | Sends the message silently. Users will receive a notification with no sound. |
System.Int32 | replyToMessageId | The messageId of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
Message | The sent message on success |
SendAudioAsync(ChatId, SendFile, String, ParseMode, Int32, String, String, SendFile, Boolean, Int32, ReplyMarkupBase)
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. On success, the sent Message is returned.
Declaration
public Task<Message> SendAudioAsync(ChatId chatId, SendFile audio, string caption = null, ParseMode parseMode = ParseMode.None, int duration = 0, string performer = null, string title = null, SendFile thumb = null, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | The chat id or channel username of the chat to send the message to |
SendFile | audio | The audio file. Either one of SendFileId, SendFileUrl or SendFileMultipart |
System.String | caption | The caption of the audio file, if any |
ParseMode | parseMode | The parse mode of the caption, if any |
System.Int32 | duration | Duration of the audio in seconds |
System.String | performer | Performer |
System.String | title | Track name |
SendFile | thumb | Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
System.Boolean | disableNotification | Sends the message silently. Users will receive a notification with no sound. |
System.Int32 | replyToMessageId | The messageId of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message on success |
SendChatAction(ChatId, ChatAction)
Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot.
We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
Declaration
public bool SendChatAction(ChatId chatId, ChatAction action)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
ChatAction | action | Type of action to broadcast. Choose one, depending on what the user is about to receive: Typing for text messages, UploadPhoto for photos, RecordVideo or UploadVideo for videos, RecordAudio or UploadAudio for audio files, UploadDocument for general files, FindLocation for location data, RecordVideoNote or UploadVideoNote for video notes. |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
SendChatActionAsync(ChatId, ChatAction)
Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot.
We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
Declaration
public Task<bool> SendChatActionAsync(ChatId chatId, ChatAction action)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
ChatAction | action | Type of action to broadcast. Choose one, depending on what the user is about to receive: Typing for text messages, UploadPhoto for photos, RecordVideo or UploadVideo for videos, RecordAudio or UploadAudio for audio files, UploadDocument for general files, FindLocation for location data, RecordVideoNote or UploadVideoNote for video notes. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
SendContact(ChatId, String, String, String, String, Boolean, Int32, ReplyMarkupBase)
Use this method to send phone contacts. On success, the sent Message is returned.
Declaration
public Message SendContact(ChatId chatId, string phoneNumber, string firstName, string lastName = null, string vCard = null, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.String | phoneNumber | Contact's phone number |
System.String | firstName | Contact's first name |
System.String | lastName | Contact's last name |
System.String | vCard | Additional data about the contact in the form of a vCard, 0-2048 bytes |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
Message | The sent message on success |
SendContactAsync(ChatId, String, String, String, String, Boolean, Int32, ReplyMarkupBase)
Use this method to send phone contacts. On success, the sent Message is returned.
Declaration
public Task<Message> SendContactAsync(ChatId chatId, string phoneNumber, string firstName, string lastName = null, string vCard = null, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.String | phoneNumber | Contact's phone number |
System.String | firstName | Contact's first name |
System.String | lastName | Contact's last name |
System.String | vCard | Additional data about the contact in the form of a vCard, 0-2048 bytes |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message on success |
SendDocument(ChatId, SendFile, String, ParseMode, Boolean, Int32, ReplyMarkupBase, SendFile)
Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
Declaration
public Message SendDocument(ChatId chatId, SendFile document, string caption = null, ParseMode parseMode = ParseMode.None, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null, SendFile thumb = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | The chat id or channel username of the chat to send the message to |
SendFile | document | The document to send. One of SendFileId, SendFileUrl or SendFileMultipart |
System.String | caption | The caption of the document, if any |
ParseMode | parseMode | The parse mode of the message, if any |
System.Boolean | disableNotification | If this is true, the user will receive a notification without sound |
System.Int32 | replyToMessageId | The message id of the message to reply to in the target chat, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
SendFile | thumb | Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
Returns
Type | Description |
---|---|
Message | The sent message on success |
SendDocumentAsync(ChatId, SendFile, String, ParseMode, Boolean, Int32, ReplyMarkupBase, SendFile)
Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
Declaration
public Task<Message> SendDocumentAsync(ChatId chatId, SendFile document, string caption = null, ParseMode parseMode = ParseMode.None, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null, SendFile thumb = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | The chat id or channel username of the chat to send the message to |
SendFile | document | The document to send. One of SendFileId, SendFileUrl or SendFileMultipart |
System.String | caption | The caption of the document, if any |
ParseMode | parseMode | The parse mode of the message, if any |
System.Boolean | disableNotification | If this is true, the user will receive a notification without sound |
System.Int32 | replyToMessageId | The message id of the message to reply to in the target chat, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
SendFile | thumb | Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message on success |
SendGame(Int64, String, Boolean, Int32, InlineKeyboardMarkup)
Use this method to send a game. On success, the sent Message is returned.
Declaration
public Message SendGame(long chatId, string gameShortName, bool disableNotification = false, int replyToMessageId = -1, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | chatId | Unique identifier for the target chat |
System.String | gameShortName | Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather. |
System.Boolean | disableNotification | Sends the message silently. Users will receive a notification with no sound. |
System.Int32 | replyToMessageId | If the message is a reply, ID of the original message |
InlineKeyboardMarkup | replyMarkup | An object for an inline keyboard. If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game. |
Returns
Type | Description |
---|---|
Message | The sent Message |
SendGameAsync(Int64, String, Boolean, Int32, InlineKeyboardMarkup)
Use this method to send a game. On success, the sent Message is returned.
Declaration
public Task<Message> SendGameAsync(long chatId, string gameShortName, bool disableNotification = false, int replyToMessageId = -1, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | chatId | Unique identifier for the target chat |
System.String | gameShortName | Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather. |
System.Boolean | disableNotification | Sends the message silently. Users will receive a notification with no sound. |
System.Int32 | replyToMessageId | If the message is a reply, ID of the original message |
InlineKeyboardMarkup | replyMarkup | An object for an inline keyboard. If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent Message |
SendInvoice(Int32, String, String, String, String, String, String, LabeledPrice[], String, String, Int32, Int32, Int32, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Int32, InlineKeyboardMarkup)
Use this method to send invoices. On success, the sent Message is returned.
Declaration
public Message SendInvoice(int chatId, string title, string description, string payload, string providerToken, string startParameter, string currency, LabeledPrice[] prices, string providerData = null, string photoUrl = null, int photoSize = 0, int photoWidth = 0, int photoHeight = 0, bool needName = false, bool needPhoneNumber = false, bool needEmail = false, bool needShippingAddress = false, bool sendPhoneNumberToProvider = false, bool sendEmailToProvider = false, bool isFlexible = false, bool disableNotification = false, int replyToMessageId = -1, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | chatId | Unique identifier for the target private chat |
System.String | title | Product name, 1-32 characters |
System.String | description | Product description, 1-255 characters |
System.String | payload | Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. |
System.String | providerToken | Payments provider token, obtained via Botfather |
System.String | startParameter | Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter |
System.String | currency | Three-letter ISO 4217 currency code |
LabeledPrice[] | prices | Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) |
System.String | providerData | JSON-encoded data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. |
System.String | photoUrl | URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for. |
System.Int32 | photoSize | Photo size |
System.Int32 | photoWidth | Photo width |
System.Int32 | photoHeight | Photo height |
System.Boolean | needName | Pass True, if you require the user's full name to complete the order |
System.Boolean | needPhoneNumber | Pass True, if you require the user's phone number to complete the order |
System.Boolean | needEmail | Pass True, if you require the user's email address to complete the order |
System.Boolean | needShippingAddress | Pass True, if you require the user's shipping address to complete the order |
System.Boolean | sendPhoneNumberToProvider | Pass True, if user's phone number should be sent to provider |
System.Boolean | sendEmailToProvider | Pass True, if user's email address should be sent to provider |
System.Boolean | isFlexible | Pass True, if the final price depends on the shipping method |
System.Boolean | disableNotification | Sends the message silently. Users will receive a notification with no sound. |
System.Int32 | replyToMessageId | If the message is a reply, ID of the original message |
InlineKeyboardMarkup | replyMarkup | An object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button. |
Returns
Type | Description |
---|---|
Message | The sent message |
SendInvoiceAsync(Int32, String, String, String, String, String, String, LabeledPrice[], String, String, Int32, Int32, Int32, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Boolean, Int32, InlineKeyboardMarkup)
Use this method to send invoices. On success, the sent Message is returned.
Declaration
public Task<Message> SendInvoiceAsync(int chatId, string title, string description, string payload, string providerToken, string startParameter, string currency, LabeledPrice[] prices, string providerData = null, string photoUrl = null, int photoSize = 0, int photoWidth = 0, int photoHeight = 0, bool needName = false, bool needPhoneNumber = false, bool needEmail = false, bool needShippingAddress = false, bool sendPhoneNumberToProvider = false, bool sendEmailToProvider = false, bool isFlexible = false, bool disableNotification = false, int replyToMessageId = -1, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | chatId | Unique identifier for the target private chat |
System.String | title | Product name, 1-32 characters |
System.String | description | Product description, 1-255 characters |
System.String | payload | Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. |
System.String | providerToken | Payments provider token, obtained via Botfather |
System.String | startParameter | Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter |
System.String | currency | Three-letter ISO 4217 currency code |
LabeledPrice[] | prices | Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) |
System.String | providerData | JSON-encoded data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. |
System.String | photoUrl | URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for. |
System.Int32 | photoSize | Photo size |
System.Int32 | photoWidth | Photo width |
System.Int32 | photoHeight | Photo height |
System.Boolean | needName | Pass True, if you require the user's full name to complete the order |
System.Boolean | needPhoneNumber | Pass True, if you require the user's phone number to complete the order |
System.Boolean | needEmail | Pass True, if you require the user's email address to complete the order |
System.Boolean | needShippingAddress | Pass True, if you require the user's shipping address to complete the order |
System.Boolean | sendPhoneNumberToProvider | Pass True, if user's phone number should be sent to provider |
System.Boolean | sendEmailToProvider | Pass True, if user's email address should be sent to provider |
System.Boolean | isFlexible | Pass True, if the final price depends on the shipping method |
System.Boolean | disableNotification | Sends the message silently. Users will receive a notification with no sound. |
System.Int32 | replyToMessageId | If the message is a reply, ID of the original message |
InlineKeyboardMarkup | replyMarkup | An object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message |
SendLocation(ChatId, Double, Double, Int32, Boolean, Int32, ReplyMarkupBase)
Use this method to send point on the map. On success, the sent Message is returned.
Declaration
public Message SendLocation(ChatId chatId, double latitude, double longitude, int livePeriod = 0, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Double | latitude | Latitude for the location |
System.Double | longitude | Longitude for the location |
System.Int32 | livePeriod | Period in seconds for which the location will be updated (should be between 60 and 86400). |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
Message | The sent message on success |
SendLocationAsync(ChatId, Double, Double, Int32, Boolean, Int32, ReplyMarkupBase)
Use this method to send point on the map. On success, the sent Message is returned.
Declaration
public Task<Message> SendLocationAsync(ChatId chatId, double latitude, double longitude, int livePeriod = 0, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Double | latitude | Latitude for the location |
System.Double | longitude | Longitude for the location |
System.Int32 | livePeriod | Period in seconds for which the location will be updated (should be between 60 and 86400). |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message on success |
SendMediaGroup(ChatId, InputMedia[], Boolean, Int32)
Use this method to send a group of photos or videos as an album. On success, an array of the sent Messages is returned.
Declaration
public Message[] SendMediaGroup(ChatId chatId, InputMedia[] media, bool disableNotification = false, int replyToMessageId = -1)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
InputMedia[] | media | Array of InputMediaPhoto and InputMediaVideo. Must contain 2-10 elements. |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
Returns
Type | Description |
---|---|
Message[] | The sent messages on success |
SendMediaGroupAsync(ChatId, InputMedia[], Boolean, Int32)
Use this method to send a group of photos or videos as an album. On success, an array of the sent Messages is returned.
Declaration
public Task<Message[]> SendMediaGroupAsync(ChatId chatId, InputMedia[] media, bool disableNotification = false, int replyToMessageId = -1)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
InputMedia[] | media | Array of InputMediaPhoto and InputMediaVideo. Must contain 2-10 elements. |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message[]> | The sent messages on success |
SendMessage(ChatId, String, ParseMode, Boolean, Boolean, Int32, ReplyMarkupBase)
Use this method to send text messages. On success, the sent Message is returned.
Declaration
public Message SendMessage(ChatId chatId, string text, ParseMode parseMode = ParseMode.None, bool disableWebPagePreview = false, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | The id or channel username of the chat to send the message to |
System.String | text | The text of the message |
ParseMode | parseMode | The parse mode of the message (see ParseMode) |
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 |
Returns
Type | Description |
---|---|
Message | The sent message |
SendMessageAsync(ChatId, String, ParseMode, Boolean, Boolean, Int32, ReplyMarkupBase)
Use this method to send text messages. On success, the sent Message is returned.
Declaration
public Task<Message> SendMessageAsync(ChatId chatId, string text, ParseMode parseMode = ParseMode.None, bool disableWebPagePreview = false, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | The id or channel username of the chat to send the message to |
System.String | text | The text of the message |
ParseMode | parseMode | The parse mode of the message (see ParseMode) |
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 |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message |
SendPhoto(ChatId, SendFile, String, ParseMode, Boolean, Int32, ReplyMarkupBase)
Use this method to send photos. On success, the sent Message is returned.
Declaration
public Message SendPhoto(ChatId chatId, SendFile photo, string caption = null, ParseMode parseMode = ParseMode.None, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | The chat id or channel username of the chat to send the photo to |
SendFile | photo | The photo to send. Either one of SendFileId, SendFileUrl or SendFileMultipart. An implicit operator from string exists. |
System.String | caption | The caption of the photo, if any |
ParseMode | parseMode | The parse mode of the caption, if any |
System.Boolean | disableNotification | If this is true, the user will receive a notification with no sound |
System.Int32 | replyToMessageId | The messageId of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
Message | The sent message on success |
SendPhotoAsync(ChatId, SendFile, String, ParseMode, Boolean, Int32, ReplyMarkupBase)
Use this method to send photos. On success, the sent Message is returned.
Declaration
public Task<Message> SendPhotoAsync(ChatId chatId, SendFile photo, string caption = null, ParseMode parseMode = ParseMode.None, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | The chat id or channel username of the chat to send the photo to |
SendFile | photo | The photo to send. Either one of SendFileId, SendFileUrl or SendFileMultipart. An implicit operator from string exists. |
System.String | caption | The caption of the photo, if any |
ParseMode | parseMode | The parse mode of the caption, if any |
System.Boolean | disableNotification | If this is true, the user will receive a notification with no sound |
System.Int32 | replyToMessageId | The messageId of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message on success |
SendSticker(ChatId, SendFile, Boolean, Int32, ReplyMarkupBase)
Use this method to send .webp stickers. On success, the sent Message is returned.
Declaration
public Message SendSticker(ChatId chatId, SendFile sticker, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
SendFile | sticker | Sticker to send. A .webp file an one of either SendFileId, SendFileUrl or SendFileMultipart |
System.Boolean | disableNotification | Sends the message silently. Users will receive a notification with no sound. |
System.Int32 | replyToMessageId | If the message is a reply, ID of the original message |
ReplyMarkupBase | replyMarkup | Additional interface options. |
Returns
Type | Description |
---|---|
Message | The sent message |
SendStickerAsync(ChatId, SendFile, Boolean, Int32, ReplyMarkupBase)
Use this method to send .webp stickers. On success, the sent Message is returned.
Declaration
public Task<Message> SendStickerAsync(ChatId chatId, SendFile sticker, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
SendFile | sticker | Sticker to send. A .webp file an one of either SendFileId, SendFileUrl or SendFileMultipart |
System.Boolean | disableNotification | Sends the message silently. Users will receive a notification with no sound. |
System.Int32 | replyToMessageId | If the message is a reply, ID of the original message |
ReplyMarkupBase | replyMarkup | Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message |
SendTextMessage(ChatId, String, ParseMode, Boolean, Boolean, Int32, ReplyMarkupBase)
Obsolete Method, please use SendMessage(ChatId, String, ParseMode, Boolean, Boolean, Int32, ReplyMarkupBase)
Declaration
[Obsolete("Please use the SendMessage() method instead", true)]
public Message SendTextMessage(ChatId chatId, string text, ParseMode parseMode = ParseMode.None, bool disableWebPagePreview = false, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | |
System.String | text | |
ParseMode | parseMode | |
System.Boolean | disableWebPagePreview | |
System.Boolean | disableNotification | |
System.Int32 | replyToMessageId | |
ReplyMarkupBase | replyMarkup |
Returns
Type | Description |
---|---|
Message |
SendTextMessageAsync(ChatId, String, ParseMode, Boolean, Boolean, Int32, ReplyMarkupBase)
Obsolete Method, please use SendMessageAsync(ChatId, String, ParseMode, Boolean, Boolean, Int32, ReplyMarkupBase)
Declaration
[Obsolete("Please use the SendMessageAsync() method instead", true)]
public Task<Message> SendTextMessageAsync(ChatId chatId, string text, ParseMode parseMode = ParseMode.None, bool disableWebPagePreview = false, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | |
System.String | text | |
ParseMode | parseMode | |
System.Boolean | disableWebPagePreview | |
System.Boolean | disableNotification | |
System.Int32 | replyToMessageId | |
ReplyMarkupBase | replyMarkup |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> |
SendVenue(ChatId, Double, Double, String, String, String, String, Boolean, Int32, ReplyMarkupBase)
Use this method to send information about a venue. On success, the sent Message is returned.
Declaration
public Message SendVenue(ChatId chatId, double latitude, double longitude, string title, string address, string foursquareId = null, string foursquareType = null, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Double | latitude | Latitude of the venue |
System.Double | longitude | Longitude of the venue |
System.String | title | Name of the venue |
System.String | address | Address of the venue |
System.String | foursquareId | Foursquare identifier of the venue |
System.String | foursquareType | Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
Message | The sent message on success |
SendVenueAsync(ChatId, Double, Double, String, String, String, String, Boolean, Int32, ReplyMarkupBase)
Use this method to send information about a venue. On success, the sent Message is returned.
Declaration
public Task<Message> SendVenueAsync(ChatId chatId, double latitude, double longitude, string title, string address, string foursquareId = null, string foursquareType = null, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Double | latitude | Latitude of the venue |
System.Double | longitude | Longitude of the venue |
System.String | title | Name of the venue |
System.String | address | Address of the venue |
System.String | foursquareId | Foursquare identifier of the venue |
System.String | foursquareType | Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message on success |
SendVideo(ChatId, SendFile, Int32, Int32, Int32, SendFileMultipart, String, ParseMode, Boolean, Boolean, Int32, ReplyMarkupBase)
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
Declaration
public Message SendVideo(ChatId chatId, SendFile video, int duration = 0, int width = 0, int height = 0, SendFileMultipart thumb = null, string caption = null, ParseMode parseMode = ParseMode.None, bool supportsStreaming = false, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
SendFile | video | The video to send. One of SendFileId, SendFileUrl or SendFileMultipart |
System.Int32 | duration | Optional. The duration of the video in seconds |
System.Int32 | width | Optional. Width of the video |
System.Int32 | height | Optional. Height of the video |
SendFileMultipart | thumb | Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
System.String | caption | Optional. Caption for the video message |
ParseMode | parseMode | Optional. Parse mode for the message caption |
System.Boolean | supportsStreaming | Pass true if the uploaded video is suitable for streaming |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
Message | The sent message on success |
SendVideoAsync(ChatId, SendFile, Int32, Int32, Int32, SendFileMultipart, String, ParseMode, Boolean, Boolean, Int32, ReplyMarkupBase)
Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
Declaration
public Task<Message> SendVideoAsync(ChatId chatId, SendFile video, int duration = 0, int width = 0, int height = 0, SendFileMultipart thumb = null, string caption = null, ParseMode parseMode = ParseMode.None, bool supportsStreaming = false, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
SendFile | video | The video to send. One of SendFileId, SendFileUrl or SendFileMultipart |
System.Int32 | duration | Optional. The duration of the video in seconds |
System.Int32 | width | Optional. Width of the video |
System.Int32 | height | Optional. Height of the video |
SendFileMultipart | thumb | Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. |
System.String | caption | Optional. Caption for the video message |
ParseMode | parseMode | Optional. Parse mode for the message caption |
System.Boolean | supportsStreaming | Pass true if the uploaded video is suitable for streaming |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message on success |
SendVideoNote(ChatId, SendFile, Int32, Int32, SendFile, Boolean, Int32, ReplyMarkupBase)
As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.
Declaration
public Message SendVideoNote(ChatId chatId, SendFile videoNote, int duration = 0, int length = 0, SendFile thumb = null, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
SendFile | videoNote | The video note to send. One of SendFileId or SendFileMultipart. SendFileUrl is currently unsupported for video notes. |
System.Int32 | duration | Optional. Duration of the video note in seconds |
System.Int32 | length | Optional. Height and width of the video |
SendFile | thumb | Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
Message | The sent message on success |
SendVideoNoteAsync(ChatId, SendFile, Int32, Int32, SendFile, Boolean, Int32, ReplyMarkupBase)
As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.
Declaration
public Task<Message> SendVideoNoteAsync(ChatId chatId, SendFile videoNote, int duration = 0, int length = 0, SendFile thumb = null, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
SendFile | videoNote | The video note to send. One of SendFileId or SendFileMultipart. SendFileUrl is currently unsupported for video notes. |
System.Int32 | duration | Optional. Duration of the video note in seconds |
System.Int32 | length | Optional. Height and width of the video |
SendFile | thumb | Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message on success |
SendVoice(ChatId, SendFile, String, ParseMode, Int32, Boolean, Int32, ReplyMarkupBase)
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
Declaration
public Message SendVoice(ChatId chatId, SendFile voice, string caption = null, ParseMode parseMode = ParseMode.None, int duration = 0, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
SendFile | voice | The voice message to send. One of SendFileId, SendFileUrl or SendFileMultipart |
System.String | caption | Optional. Caption for the video message |
ParseMode | parseMode | Optional. Parse mode for the message caption |
System.Int32 | duration | Optional. Duration of the voice message in seconds. |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
Message | The sent message on success |
SendVoiceAsync(ChatId, SendFile, String, ParseMode, Int32, Boolean, Int32, ReplyMarkupBase)
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
Declaration
public Task<Message> SendVoiceAsync(ChatId chatId, SendFile voice, string caption = null, ParseMode parseMode = ParseMode.None, int duration = 0, bool disableNotification = false, int replyToMessageId = -1, ReplyMarkupBase replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
SendFile | voice | The voice message to send. One of SendFileId, SendFileUrl or SendFileMultipart |
System.String | caption | Optional. Caption for the video message |
ParseMode | parseMode | Optional. Parse mode for the message caption |
System.Int32 | duration | Optional. Duration of the voice message in seconds. |
System.Boolean | disableNotification | If this is true, users will receive a silent notification |
System.Int32 | replyToMessageId | The message id of the message to reply to, if any |
ReplyMarkupBase | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The sent message on success |
SetChatDescription(ChatId, String)
Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Declaration
public bool SetChatDescription(ChatId chatId, string description)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.String | description | New chat description, 0-255 characters |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
SetChatDescriptionAsync(ChatId, String)
Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Declaration
public Task<bool> SetChatDescriptionAsync(ChatId chatId, string description)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.String | description | New chat description, 0-255 characters |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
SetChatPhoto(ChatId, SendFileMultipart)
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Declaration
public bool SetChatPhoto(ChatId chatId, SendFileMultipart photo)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
SendFileMultipart | photo | New chat photo, uploaded using multipart/form-data |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
SetChatPhotoAsync(ChatId, SendFileMultipart)
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Declaration
public Task<bool> SetChatPhotoAsync(ChatId chatId, SendFileMultipart photo)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
SendFileMultipart | photo | New chat photo, uploaded using multipart/form-data |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
SetChatStickerSet(ChatId, String)
Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
Declaration
public bool SetChatStickerSet(ChatId chatId, string stickerSetName)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
System.String | stickerSetName | Name of the sticker set to be set as the group sticker set |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
SetChatStickerSetAsync(ChatId, String)
Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
Declaration
public Task<bool> SetChatStickerSetAsync(ChatId chatId, string stickerSetName)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername) |
System.String | stickerSetName | Name of the sticker set to be set as the group sticker set |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
SetChatTitle(ChatId, String)
Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Declaration
public bool SetChatTitle(ChatId chatId, string title)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.String | title | New chat title, 1-255 characters |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
SetChatTitleAsync(ChatId, String)
Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
Declaration
public Task<bool> SetChatTitleAsync(ChatId chatId, string title)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.String | title | New chat title, 1-255 characters |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
SetGameScore(Int32, Int32, Int64, Int32, Boolean, Boolean)
Use this method to set the score of the specified user in a game. On success, returns the edited Message. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
Declaration
public Message SetGameScore(int userId, int score, long chatId, int messageId, bool force = false, bool disableEditMessage = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | User identifier |
System.Int32 | score | New score, must be non-negative |
System.Int64 | chatId | Unique identifier for the target chat |
System.Int32 | messageId | Identifier of the sent message |
System.Boolean | force | Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters |
System.Boolean | disableEditMessage | Pass True, if the game message should not be automatically edited to include the current scoreboard |
Returns
Type | Description |
---|---|
Message | The edited message |
SetGameScore(Int32, Int32, String, Boolean, Boolean)
Use this method to set the score of the specified user in a game. On success, returns True. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
Declaration
public bool SetGameScore(int userId, int score, string inlineMessageId, bool force = false, bool disableEditMessage = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | User identifier |
System.Int32 | score | New score, must be non-negative |
System.String | inlineMessageId | Identifier of the inline message |
System.Boolean | force | Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters |
System.Boolean | disableEditMessage | Pass True, if the game message should not be automatically edited to include the current scoreboard |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
SetGameScoreAsync(Int32, Int32, Int64, Int32, Boolean, Boolean)
Use this method to set the score of the specified user in a game. On success, returns the edited Message. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
Declaration
public Task<Message> SetGameScoreAsync(int userId, int score, long chatId, int messageId, bool force = false, bool disableEditMessage = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | User identifier |
System.Int32 | score | New score, must be non-negative |
System.Int64 | chatId | Unique identifier for the target chat |
System.Int32 | messageId | Identifier of the sent message |
System.Boolean | force | Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters |
System.Boolean | disableEditMessage | Pass True, if the game message should not be automatically edited to include the current scoreboard |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The edited message |
SetGameScoreAsync(Int32, Int32, String, Boolean, Boolean)
Use this method to set the score of the specified user in a game. On success, returns True. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
Declaration
public Task<bool> SetGameScoreAsync(int userId, int score, string inlineMessageId, bool force = false, bool disableEditMessage = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | User identifier |
System.Int32 | score | New score, must be non-negative |
System.String | inlineMessageId | Identifier of the inline message |
System.Boolean | force | Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters |
System.Boolean | disableEditMessage | Pass True, if the game message should not be automatically edited to include the current scoreboard |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
SetPassportDataErrors(Int32, PassportElementError[])
Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.
Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.
Declaration
public bool SetPassportDataErrors(int userId, PassportElementError[] errors)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | User identifier |
PassportElementError[] | errors | A JSON-serialized array describing the errors |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
SetPassportDataErrorsAsync(Int32, PassportElementError[])
Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.
Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.
Declaration
public Task<bool> SetPassportDataErrorsAsync(int userId, PassportElementError[] errors)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | User identifier |
PassportElementError[] | errors | A JSON-serialized array describing the errors |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
SetStickerPositionInSet(String, Int32)
Use this method to move a sticker in a set created by the bot to a specific position . Returns True on success.
Declaration
public bool SetStickerPositionInSet(string sticker, int position)
Parameters
Type | Name | Description |
---|---|---|
System.String | sticker | File identifier of the sticker |
System.Int32 | position | New position in the set, zero-based |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
SetStickerPositionInSetAsync(String, Int32)
Use this method to move a sticker in a set created by the bot to a specific position . Returns True on success.
Declaration
public Task<bool> SetStickerPositionInSetAsync(string sticker, int position)
Parameters
Type | Name | Description |
---|---|---|
System.String | sticker | File identifier of the sticker |
System.Int32 | position | New position in the set, zero-based |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
SetWebhook(String, SendFileMultipart, Int32, UpdateType[])
Use this method to specify a url and receive incoming updates via an outgoing webhook.
Declaration
public bool SetWebhook(string url, SendFileMultipart certificate = null, int maxConnections = 40, UpdateType[] allowedUpdates = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | HTTPS url to send updates to. Use an empty string to remove webhook integration |
SendFileMultipart | certificate | Upload your public key certificate so that the root certificate in use can be checked. |
System.Int32 | maxConnections | Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot‘s server, and higher values to increase your bot’s throughput. |
UpdateType[] | allowedUpdates | The types of updates you want your bot to receive |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
SetWebhookAsync(String, SendFileMultipart, Int32, UpdateType[])
Use this method to specify a url and receive incoming updates via an outgoing webhook.
Declaration
public Task<bool> SetWebhookAsync(string url, SendFileMultipart certificate = null, int maxConnections = 40, UpdateType[] allowedUpdates = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | HTTPS url to send updates to. Use an empty string to remove webhook integration |
SendFileMultipart | certificate | Upload your public key certificate so that the root certificate in use can be checked. |
System.Int32 | maxConnections | Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot‘s server, and higher values to increase your bot’s throughput. |
UpdateType[] | allowedUpdates | The types of updates you want your bot to receive |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
StartReceiving(UpdateType[])
Starts polling to get updates. Updates will be sent to OnUpdate and their respective events
Declaration
public void StartReceiving(UpdateType[] allowedUpdates = null)
Parameters
Type | Name | Description |
---|---|---|
UpdateType[] | allowedUpdates |
StopMessageLiveLocation(String, InlineKeyboardMarkup)
Use this method to stop updating a live location message sent via the bot (for inline bots) before live_period expires. On success, True is returned.
Declaration
public bool StopMessageLiveLocation(string inlineMessageId, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineMessageId | Identifier of the inline message |
InlineKeyboardMarkup | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
StopMessageLiveLocation(ChatId, Int32, InlineKeyboardMarkup)
Use this method to stop updating a live location message sent by the bot before live_period expires. On success, the sent Message is returned.
Declaration
public Message StopMessageLiveLocation(ChatId chatId, int messageId, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the sent message |
InlineKeyboardMarkup | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
Message | The edited message |
StopMessageLiveLocationAsync(String, InlineKeyboardMarkup)
Use this method to stop updating a live location message sent via the bot (for inline bots) before live_period expires. On success, True is returned.
Declaration
public Task<bool> StopMessageLiveLocationAsync(string inlineMessageId, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | inlineMessageId | Identifier of the inline message |
InlineKeyboardMarkup | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
StopMessageLiveLocationAsync(ChatId, Int32, InlineKeyboardMarkup)
Use this method to stop updating a live location message sent by the bot before live_period expires. On success, the sent Message is returned.
Declaration
public Task<Message> StopMessageLiveLocationAsync(ChatId chatId, int messageId, InlineKeyboardMarkup replyMarkup = null)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
System.Int32 | messageId | Identifier of the sent message |
InlineKeyboardMarkup | replyMarkup | The reply markup. Additional interface options. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Message> | The edited message |
StopReceiving()
Stops polling to get updates.
Declaration
public void StopReceiving()
UnbanChatMember(ChatId, Int32)
Unbans a user from a chat
Declaration
public bool UnbanChatMember(ChatId chatId, int userId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target group or username of the target supergroup or channel (in the format @username) |
System.Int32 | userId | The id of the user to unban |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
UnbanChatMemberAsync(ChatId, Int32)
Unbans a user from a chat
Declaration
public Task<bool> UnbanChatMemberAsync(ChatId chatId, int userId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target group or username of the target supergroup or channel (in the format @username) |
System.Int32 | userId | The id of the user to unban |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
UnpinChatMessage(ChatId)
Use this method to unpin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel. Returns True on success.
Declaration
public bool UnpinChatMessage(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Boolean | True on success |
UnpinChatMessageAsync(ChatId)
Use this method to unpin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel. Returns True on success.
Declaration
public Task<bool> UnpinChatMessageAsync(ChatId chatId)
Parameters
Type | Name | Description |
---|---|---|
ChatId | chatId | Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True on success |
UploadStickerFile(Int32, SendFile)
Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success.
Declaration
public File UploadStickerFile(int userId, SendFile pngSticker)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | User identifier of sticker file owner |
SendFile | 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. |
Returns
Type | Description |
---|---|
File | The uploaded file (containing only the fileId) |
UploadStickerFileAsync(Int32, SendFile)
Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success.
Declaration
public Task<File> UploadStickerFileAsync(int userId, SendFile pngSticker)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | userId | User identifier of sticker file owner |
SendFile | 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. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<File> | The uploaded file (containing only the fileId) |
Events
| Improve this Doc View SourceOnCallbackQuery
This event will be fired on every callback query after StartReceiving(UpdateType[]) has been called
Declaration
public event EventHandler<CallbackQueryEventArgs> OnCallbackQuery
Event Type
Type | Description |
---|---|
System.EventHandler<CallbackQueryEventArgs> |
OnChannelPost
This event will be fired on every channel post after StartReceiving(UpdateType[]) has been called
Declaration
public event EventHandler<ChannelPostEventArgs> OnChannelPost
Event Type
Type | Description |
---|---|
System.EventHandler<ChannelPostEventArgs> |
OnChannelPostEdited
This event will be fired on every edited channel post after StartReceiving(UpdateType[]) has been called
Declaration
public event EventHandler<EditedChannelPostEventArgs> OnChannelPostEdited
Event Type
Type | Description |
---|---|
System.EventHandler<EditedChannelPostEventArgs> |
OnChosenInlineResult
This event will be fired on every inline query after StartReceiving(UpdateType[]) has been called
Declaration
public event EventHandler<ChosenInlineResultEventArgs> OnChosenInlineResult
Event Type
Type | Description |
---|---|
System.EventHandler<ChosenInlineResultEventArgs> |
OnInlineQuery
This event will be fired on every inline query after StartReceiving(UpdateType[]) has been called
Declaration
public event EventHandler<InlineQueryEventArgs> OnInlineQuery
Event Type
Type | Description |
---|---|
System.EventHandler<InlineQueryEventArgs> |
OnMessage
This event will be fired on every incoming message after StartReceiving(UpdateType[]) has been called
Declaration
public event EventHandler<MessageEventArgs> OnMessage
Event Type
Type | Description |
---|---|
System.EventHandler<MessageEventArgs> |
OnMessageEdited
This event will be fired on every edited message after StartReceiving(UpdateType[]) has been called
Declaration
public event EventHandler<EditedMessageEventArgs> OnMessageEdited
Event Type
Type | Description |
---|---|
System.EventHandler<EditedMessageEventArgs> |
OnPollingError
This event will be fired if an exception occurs while waiting for updates with StartReceiving(UpdateType[])
Declaration
public event EventHandler<Exception> OnPollingError
Event Type
Type | Description |
---|---|
System.EventHandler<System.Exception> |
OnPreCheckoutQuery
This event will be fired on every pre-checkout query after StartReceiving(UpdateType[]) has been called
Declaration
public event EventHandler<PreCheckoutQueryEventArgs> OnPreCheckoutQuery
Event Type
Type | Description |
---|---|
System.EventHandler<PreCheckoutQueryEventArgs> |
OnShippingQuery
This event will be fired on every shipping query after StartReceiving(UpdateType[]) has been called
Declaration
public event EventHandler<ShippingQueryEventArgs> OnShippingQuery
Event Type
Type | Description |
---|---|
System.EventHandler<ShippingQueryEventArgs> |
OnUpdate
This event will be fired on every new update after StartReceiving(UpdateType[]) has been called
Declaration
public event EventHandler<UpdateEventArgs> OnUpdate
Event Type
Type | Description |
---|---|
System.EventHandler<UpdateEventArgs> |