MCPcopy Create free account
hub / github.com/eternnoir/pyTelegramBotAPI / set_webhook

Method set_webhook

telebot/async_telebot.py:2899–2953  ·  view source on GitHub ↗

Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up a

(self, url: Optional[str]=None, certificate: Optional[Union[str, Any]]=None, max_connections: Optional[int]=None,
                allowed_updates: Optional[List[str]]=None, ip_address: Optional[str]=None,
                drop_pending_updates: Optional[bool] = None, timeout: Optional[int]=None,
                secret_token: Optional[str]=None)

Source from the content-addressed store, hash-verified

2897 self.current_states = StatePickleStorage(file_path=filename)
2898
2899 async def set_webhook(self, url: Optional[str]=None, certificate: Optional[Union[str, Any]]=None, max_connections: Optional[int]=None,
2900 allowed_updates: Optional[List[str]]=None, ip_address: Optional[str]=None,
2901 drop_pending_updates: Optional[bool] = None, timeout: Optional[int]=None,
2902 secret_token: Optional[str]=None) -> bool:
2903 """
2904 Use this method to specify a URL and receive incoming updates via an outgoing webhook.
2905 Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL,
2906 containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after
2907 a reasonable amount of attempts. Returns True on success.
2908
2909 If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token.
2910 If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.
2911
2912 Telegram Documentation: https://core.telegram.org/bots/api#setwebhook
2913
2914 :param url: HTTPS URL to send updates to. Use an empty string to remove webhook integration, defaults to None
2915 :type url: :obj:`str`, optional
2916
2917 :param certificate: Upload your public key certificate so that the root certificate in use can be checked, defaults to None
2918 :type certificate: :class:`str`, optional
2919
2920 :param max_connections: The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100.
2921 Defaults to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput,
2922 defaults to None
2923 :type max_connections: :obj:`int`, optional
2924
2925 :param allowed_updates: A JSON-serialized list of the update types you want your bot to receive. For example,
2926 specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update
2927 for a complete list of available update types. Specify an empty list to receive all update types except chat_member (default).
2928 If not specified, the previous setting will be used.
2929
2930 Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received
2931 for a short period of time. Defaults to None
2932
2933 :type allowed_updates: :obj:`list`, optional
2934
2935 :param ip_address: The fixed IP address which will be used to send webhook requests instead of the IP address
2936 resolved through DNS, defaults to None
2937 :type ip_address: :obj:`str`, optional
2938
2939 :param drop_pending_updates: Pass True to drop all pending updates, defaults to None
2940 :type drop_pending_updates: :obj:`bool`, optional
2941
2942 :param timeout: Timeout of a request, defaults to None
2943 :type timeout: :obj:`int`, optional
2944
2945 :param secret_token: A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters.
2946 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. Defaults to None
2947 :type secret_token: :obj:`str`, optional
2948
2949 :return: True on success.
2950 :rtype: :obj:`bool` if the request was successful.
2951 """
2952 return await asyncio_helper.set_webhook(self.token, url, certificate, max_connections, allowed_updates, ip_address,
2953 drop_pending_updates, timeout, secret_token)
2954
2955
2956 async def run_webhooks(self,

Callers 3

add_botFunction · 0.95
run_webhooksMethod · 0.95
remove_webhookMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected