mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Add setMebhook, deleteWebhook, GetWebhookInfo
This commit is contained in:
parent
56c6cf6839
commit
51ac1a9d6c
2 changed files with 24 additions and 3 deletions
|
|
@ -86,9 +86,9 @@ async def request(session, token, method, data=None, files=None):
|
|||
class ApiMethods:
|
||||
GET_ME = 'getMe'
|
||||
GET_UPDATES = 'getUpdates'
|
||||
SET_WEBHOOK = 'setWebhook' # TODO
|
||||
DELETE_WEBHOOK = 'deleteWebhook' # TODO
|
||||
GET_WEBHOOK_INFO = 'getWebhookInfo' # TODO
|
||||
SET_WEBHOOK = 'setWebhook'
|
||||
DELETE_WEBHOOK = 'deleteWebhook'
|
||||
GET_WEBHOOK_INFO = 'getWebhookInfo'
|
||||
SEND_MESSAGE = 'sendMessage'
|
||||
FORWARD_MESSAGE = 'forwardMessage'
|
||||
SEND_PHOTO = 'sendPhoto'
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import aiohttp
|
|||
|
||||
from aiogram.types.file import File
|
||||
from aiogram.types.user_profile_photos import UserProfilePhotos
|
||||
from aiogram.types.webhook_info import WebhookInfo
|
||||
from . import api
|
||||
from .api import ApiMethods
|
||||
from .types.chat import Chat
|
||||
|
|
@ -95,6 +96,26 @@ class AIOGramBot:
|
|||
raw = await self.request(ApiMethods.GET_UPDATES, payload)
|
||||
return [self.prepare_object(Update.de_json(raw_update)) for raw_update in raw]
|
||||
|
||||
async def set_webhook(self, url, certificate=None, max_connections=None, allowed_updates=None):
|
||||
payload = generate_payload(**locals(), exclude='certificate')
|
||||
if certificate:
|
||||
cert = {'certificate': certificate}
|
||||
req = self.request(ApiMethods.SET_WEBHOOK, payload, cert)
|
||||
else:
|
||||
req = self.request(ApiMethods.SET_WEBHOOK, payload)
|
||||
|
||||
return self.prepare_object(WebhookInfo.de_json(await req))
|
||||
|
||||
async def delete_webhook(self):
|
||||
payload = {}
|
||||
await self.request(ApiMethods.DELETE_WEBHOOK, payload)
|
||||
return True
|
||||
|
||||
async def get_webhook_info(self):
|
||||
payload = {}
|
||||
webhook_info = await self.request(ApiMethods.GET_WEBHOOK_INFO, payload)
|
||||
return self.prepare_object(webhook_info)
|
||||
|
||||
async def send_message(self, chat_id, text, parse_mode=None, disable_web_page_preview=None,
|
||||
disable_notification=None, reply_to_message_id=None, reply_markup=None):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue