mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
Add delete_business_messages method
Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
parent
a8666e1f84
commit
beed137855
3 changed files with 75 additions and 0 deletions
|
|
@ -408,6 +408,7 @@ def pyrogram_api():
|
||||||
Telegram Business
|
Telegram Business
|
||||||
answer_pre_checkout_query
|
answer_pre_checkout_query
|
||||||
answer_shipping_query
|
answer_shipping_query
|
||||||
|
delete_business_messages
|
||||||
get_business_connection
|
get_business_connection
|
||||||
""",
|
""",
|
||||||
authorization="""
|
authorization="""
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
|
||||||
#
|
#
|
||||||
# This file is part of Pyrogram.
|
# This file is part of Pyrogram.
|
||||||
#
|
#
|
||||||
|
|
@ -18,12 +19,14 @@
|
||||||
|
|
||||||
from .answer_pre_checkout_query import AnswerPreCheckoutQuery
|
from .answer_pre_checkout_query import AnswerPreCheckoutQuery
|
||||||
from .answer_shipping_query import AnswerShippingQuery
|
from .answer_shipping_query import AnswerShippingQuery
|
||||||
|
from .delete_business_messages import DeleteBusinessMessages
|
||||||
from .get_business_connection import GetBusinessConnection
|
from .get_business_connection import GetBusinessConnection
|
||||||
|
|
||||||
|
|
||||||
class TelegramBusiness(
|
class TelegramBusiness(
|
||||||
AnswerPreCheckoutQuery,
|
AnswerPreCheckoutQuery,
|
||||||
AnswerShippingQuery,
|
AnswerShippingQuery,
|
||||||
|
DeleteBusinessMessages,
|
||||||
GetBusinessConnection,
|
GetBusinessConnection,
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
71
pyrogram/methods/business/delete_business_messages.py
Normal file
71
pyrogram/methods/business/delete_business_messages.py
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||||
|
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrogram is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Iterable, Union
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw
|
||||||
|
|
||||||
|
|
||||||
|
class DeleteBusinessMessages:
|
||||||
|
async def delete_business_messages(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
business_connection_id: str,
|
||||||
|
message_ids: Union[int, Iterable[int]]
|
||||||
|
) -> int:
|
||||||
|
"""Delete messages on behalf of a business account.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Requires the `can_delete_sent_messages` business bot right to delete messages sent by the bot itself,
|
||||||
|
or the `can_delete_all_messages` business bot right to delete any message.
|
||||||
|
|
||||||
|
.. include:: /_includes/usable-by/bots.rst
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
business_connection_id (``str``):
|
||||||
|
Unique identifier of business connection on behalf of which to send the request.
|
||||||
|
|
||||||
|
message_ids (``int`` | Iterable of ``int``):
|
||||||
|
An iterable of message identifiers to delete (integers) or a single message id.
|
||||||
|
All messages must be from the same chat.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
``int``: Amount of affected messages
|
||||||
|
|
||||||
|
Example:
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
# Delete one message
|
||||||
|
await app.delete_business_messages(connection_id, message_id)
|
||||||
|
|
||||||
|
# Delete multiple messages at once
|
||||||
|
await app.delete_business_messages(connection_id, list_of_message_ids)
|
||||||
|
"""
|
||||||
|
message_ids = list(message_ids) if not isinstance(message_ids, int) else [message_ids]
|
||||||
|
|
||||||
|
r = await self.invoke(
|
||||||
|
raw.functions.messages.DeleteMessages(
|
||||||
|
id=message_ids,
|
||||||
|
revoke=True
|
||||||
|
),
|
||||||
|
business_connection_id=business_connection_id
|
||||||
|
)
|
||||||
|
|
||||||
|
return r.pts_count
|
||||||
Loading…
Reference in a new issue