Skip to content

Commit

Permalink
Add demote_chat_member method
Browse files Browse the repository at this point in the history
  • Loading branch information
z44d committed Jan 13, 2025
1 parent 9881e7b commit c69b4ff
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tgram/methods/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from .delete_sticker_from_set import DeleteStickerFromSet
from .delete_sticker_set import DeleteStickerSet
from .delete_webhook import DeleteWebhook
from .demote_chat_member import DemoteChatMember
from .download_file import DownloadFile
from .edit_chat_invite_link import EditChatInviteLink
from .edit_chat_subscription_invite_link import EditChatSubscriptionInviteLink
Expand Down Expand Up @@ -169,6 +170,7 @@ class TelegramBotMethods(
DeleteStickerFromSet,
DeleteStickerSet,
DeleteWebhook,
DemoteChatMember,
DownloadFile,
EditChatInviteLink,
EditChatSubscriptionInviteLink,
Expand Down
45 changes: 45 additions & 0 deletions tgram/methods/demote_chat_member.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import tgram
from typing import Union


class DemoteChatMember:
async def demote_chat_member(
self: "tgram.TgBot", chat_id: Union[int, str], user_id: int
) -> bool:
"""
Use this method to demote a user in a supergroup or a channel. The bot must be an administrator
Telegram documentation: null
:param chat_id: Unique identifier for the target chat or username of the target channel (
in the format @channelusername)
:type chat_id: :obj:`int` or :obj:`str`
:param user_id: Unique identifier of the target user
:type user_id: :obj:`int`
:return: True on success.
:rtype: :obj:`bool`
"""

result = await self._send_request(
"promoteChatMember",
chat_id=chat_id,
user_id=user_id,
is_anonymous=False,
can_manage_chat=False,
can_delete_messages=False,
can_manage_video_chats=False,
can_restrict_members=False,
can_promote_members=False,
can_change_info=False,
can_invite_users=False,
can_post_stories=False,
can_edit_stories=False,
can_delete_stories=False,
can_post_messages=False,
can_edit_messages=False,
can_pin_messages=False,
can_manage_topics=False,
)
return result["result"]

0 comments on commit c69b4ff

Please sign in to comment.