Tgbot1:getupdates、setwebhookWebhookInfo方法

api 7.1更新字段

FieldTypeDescription
update_idIntegerThe update’s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This identifier becomes especially handy if you’re using webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.
messageMessageOptional. New incoming message of any kind – text, photo, sticker, etc.
edited_messageMessageOptional. New version of a message that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.
channel_postMessageOptional. New incoming channel post of any kind – text, photo, sticker, etc.
edited_channel_postMessageOptional. New version of a channel post that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.
message_reactionMessageReactionUpdatedOptional. A reaction to a message was changed by a user. The bot must be an administrator in the chat and must explicitly specify “message_reaction” in the list of allowed_updates to receive these updates. The update isn’t received for reactions set by bots.
message_reaction_countMessageReactionCountUpdatedOptional. Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat and must explicitly specify “message_reaction_count” in the list of allowed_updates to receive these updates. The updates are grouped and can be sent with delay up to a few minutes.
inline_queryInlineQueryOptional. New incoming inline query
chosen_inline_resultChosenInlineResultOptional. The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot.
callback_queryCallbackQueryOptional. New incoming callback query
shipping_queryShippingQueryOptional. New incoming shipping query. Only for invoices with flexible price
pre_checkout_queryPreCheckoutQueryOptional. New incoming pre-checkout query. Contains full information about checkout
pollPollOptional. New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot
poll_answerPollAnswerOptional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.
my_chat_memberChatMemberUpdatedOptional. The bot’s chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.
chat_memberChatMemberUpdatedOptional. A chat member’s status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify “chat_member” in the list of allowed_updates to receive these updates.
chat_join_requestChatJoinRequestOptional. A request to join the chat has been sent. The bot must have the can_invite_users administrator right in the chat to receive these updates.
chat_boostChatBoostUpdatedOptional. A chat boost was added or changed. The bot must be an administrator in the chat to receive these updates.
removed_chat_boostChatBoostRemovedOptional. A boost was removed from a chat. The bot must be an administrator in the chat to receive these updates.

getupdates方法

ParameterTypeRequiredDescription
offsetIntegerOptionalIdentifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten.
limitIntegerOptionalLimits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.
timeoutIntegerOptionalTimeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.
allowed_updatesArray of StringOptionalA JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.
Please note that this parameter doesn’t affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time.
1.如果设置了传出的Webhook,此方法将无法使用。
2.为了避免重复更新,请在每个服务器响应后重新计算偏移。

setwebhook方法

ParameterTypeRequiredDescription
urlStringYesHTTPS URL to send updates to. Use an empty string to remove webhook integration
certificateInputFileOptionalUpload your public key certificate so that the root certificate in use can be checked. See our self-signed guide for details.
ip_addressStringOptionalThe fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS
max_connectionsIntegerOptionalThe 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.
allowed_updatesArray of StringOptionalA JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.
Please note that this parameter doesn’t affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time.
drop_pending_updatesBooleanOptionalPass True to drop all pending updates
secret_tokenStringOptionalA secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and – are allowed. The header is useful to ensure that the request comes from a webhook set by you.
drop_pending_updatesBooleanOptionalPass True to drop all pending updates
1.只要设置一个传出的Webhook,您就无法使用getupdates接收更新。
2.要使用自签名证书,您需要使用证书参数上传公共密钥证书。 请上传为InputFile,发送一个字符串将无效。
3.当前支持Webhooks的端口:443、80、88、8443。

getwebhookinfo:
使用此方法获取当前的Webhook状态。 不需要参数。 成功,返回Webhookinfo对象。 如果机器人使用getupdates,将返回带有URL字段空的对象。

WebhookInfo方法

FieldTypeDescription
urlStringWebhook URL, may be empty if webhook is not set up
has_custom_certificateBooleanTrue, if a custom certificate was provided for webhook certificate checks
pending_update_countIntegerNumber of updates awaiting delivery
ip_addressStringOptional. Currently used webhook IP address
last_error_dateIntegerOptional. Unix time for the most recent error that happened when trying to deliver an update via webhook
last_error_messageStringOptional. Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook
last_synchronization_error_dateIntegerOptional. Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters
max_connectionsIntegerOptional. The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery
allowed_updatesArray of StringOptional. A list of update types the bot is subscribed to. Defaults to all update types except chat_member
机器人API响应中使用的所有类型均表示为JSON-Objects



评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

zh_CN简体中文