Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions hydrogram/methods/bots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
from .answer_inline_query import AnswerInlineQuery
from .answer_web_app_query import AnswerWebAppQuery
from .delete_bot_commands import DeleteBotCommands
from .delete_my_commands import DeleteMyCommands
from .get_bot_commands import GetBotCommands
from .get_my_commands import GetMyCommands
from .get_bot_default_privileges import GetBotDefaultPrivileges
from .get_chat_menu_button import GetChatMenuButton
from .get_game_high_scores import GetGameHighScores
Expand All @@ -30,6 +32,7 @@
from .send_game import SendGame
from .send_inline_bot_result import SendInlineBotResult
from .set_bot_commands import SetBotCommands
from .set_my_commands import SetMyCommands
from .set_bot_default_privileges import SetBotDefaultPrivileges
from .set_chat_menu_button import SetChatMenuButton
from .set_game_score import SetGameScore
Expand All @@ -46,11 +49,14 @@ class Bots(
GetGameHighScores,
SetBotCommands,
GetBotCommands,
GetMyCommands,
DeleteBotCommands,
DeleteMyCommands,
SetBotDefaultPrivileges,
GetBotDefaultPrivileges,
SetChatMenuButton,
GetChatMenuButton,
AnswerWebAppQuery,
SetMyCommands,
):
pass
36 changes: 36 additions & 0 deletions hydrogram/methods/bots/delete_my_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Hydrogram - Telegram MTProto API Client for Python
# Copyright (C) 2017-2023 Dan <https://github.com/delivrance>
# Copyright (C) 2023-present Hydrogram <https://hydrogram.org>
#
# This file is part of Hydrogram.
#
# Hydrogram 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.
#
# Hydrogram 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 Hydrogram. If not, see <http://www.gnu.org/licenses/>.

from __future__ import annotations

import hydrogram
from hydrogram import types


class DeleteMyCommands:
async def delete_my_commands(
self: "hydrogram.Client",
scope: "types.BotCommandScope" = types.BotCommandScopeDefault(),
language_code: str = "",
) -> bool:
"""Delete bot commands.

This is an alias of :meth:`~Client.delete_bot_commands` for Bot API compatibility.
"""
return await self.delete_bot_commands(scope=scope, language_code=language_code)
36 changes: 36 additions & 0 deletions hydrogram/methods/bots/get_my_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Hydrogram - Telegram MTProto API Client for Python
# Copyright (C) 2017-2023 Dan <https://github.com/delivrance>
# Copyright (C) 2023-present Hydrogram <https://hydrogram.org>
#
# This file is part of Hydrogram.
#
# Hydrogram 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.
#
# Hydrogram 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 Hydrogram. If not, see <http://www.gnu.org/licenses/>.

from __future__ import annotations

import hydrogram
from hydrogram import types


class GetMyCommands:
async def get_my_commands(
self: "hydrogram.Client",
scope: "types.BotCommandScope" = types.BotCommandScopeDefault(),
language_code: str = "",
) -> list["types.BotCommand"]:
"""Get the current list of bot commands.

This is an alias of :meth:`~Client.get_bot_commands` for Bot API compatibility.
"""
return await self.get_bot_commands(scope=scope, language_code=language_code)
37 changes: 37 additions & 0 deletions hydrogram/methods/bots/set_my_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Hydrogram - Telegram MTProto API Client for Python
# Copyright (C) 2017-2023 Dan <https://github.com/delivrance>
# Copyright (C) 2023-present Hydrogram <https://hydrogram.org>
#
# This file is part of Hydrogram.
#
# Hydrogram 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.
#
# Hydrogram 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 Hydrogram. If not, see <http://www.gnu.org/licenses/>.

from __future__ import annotations

import hydrogram
from hydrogram import types


class SetMyCommands:
async def set_my_commands(
self: "hydrogram.Client",
commands: list["types.BotCommand"],
scope: "types.BotCommandScope" = types.BotCommandScopeDefault(),
language_code: str = "",
) -> bool:
"""Set list of bot commands.

This is an alias of :meth:`~Client.set_bot_commands` for Bot API compatibility.
"""
return await self.set_bot_commands(commands, scope=scope, language_code=language_code)
20 changes: 20 additions & 0 deletions hydrogram/methods/chats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,26 @@
from .create_forum_topic import CreateForumTopic
from .create_group import CreateGroup
from .create_supergroup import CreateSupergroup
from .edit_general_forum_topic import EditGeneralForumTopic
from .delete_channel import DeleteChannel
from .delete_chat_photo import DeleteChatPhoto
from .delete_forum_topic import DeleteForumTopic
from .delete_supergroup import DeleteSupergroup
from .delete_user_history import DeleteUserHistory
from .edit_forum_topic import EditForumTopic
from .edit_general_topic import EditGeneralTopic
from .close_general_forum_topic import CloseGeneralForumTopic
from .reopen_general_forum_topic import ReopenGeneralForumTopic
from .hide_general_forum_topic import HideGeneralForumTopic
from .unhide_general_forum_topic import UnhideGeneralForumTopic
from .unpin_all_forum_topic_messages import UnpinAllForumTopicMessages
from .unpin_all_general_forum_topic_messages import UnpinAllGeneralForumTopicMessages
from .get_chat import GetChat
from .get_chat_administrators import GetChatAdministrators
from .get_chat_event_log import GetChatEventLog
from .get_chat_member import GetChatMember
from .get_chat_members import GetChatMembers
from .get_chat_member_count import GetChatMemberCount
from .get_chat_members_count import GetChatMembersCount
from .get_chat_online_count import GetChatOnlineCount
from .get_dialogs import GetDialogs
Expand All @@ -55,6 +64,7 @@
from .reopen_general_topic import ReopenGeneralTopic
from .restrict_chat_member import RestrictChatMember
from .set_administrator_title import SetAdministratorTitle
from .set_chat_administrator_custom_title import SetChatAdministratorCustomTitle
from .set_chat_description import SetChatDescription
from .set_chat_permissions import SetChatPermissions
from .set_chat_photo import SetChatPhoto
Expand All @@ -81,6 +91,7 @@ class Chats(
PromoteChatMember,
GetChatMembers,
GetChatMember,
GetChatMemberCount,
SetChatPhoto,
DeleteChatPhoto,
SetChatTitle,
Expand All @@ -100,6 +111,14 @@ class Chats(
CreateSupergroup,
CreateChannel,
CreateForumTopic,
GetChatAdministrators,
CloseGeneralForumTopic,
ReopenGeneralForumTopic,
HideGeneralForumTopic,
UnhideGeneralForumTopic,
EditGeneralForumTopic,
UnpinAllForumTopicMessages,
UnpinAllGeneralForumTopicMessages,
CloseForumTopic,
CloseGeneralTopic,
AddChatMembers,
Expand All @@ -113,6 +132,7 @@ class Chats(
HideGeneralTopic,
UnhideGeneralTopic,
GetNearbyChats,
SetChatAdministratorCustomTitle,
SetAdministratorTitle,
SetSlowMode,
DeleteUserHistory,
Expand Down
29 changes: 29 additions & 0 deletions hydrogram/methods/chats/close_general_forum_topic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Hydrogram - Telegram MTProto API Client for Python
# Copyright (C) 2017-2023 Dan <https://github.com/delivrance>
# Copyright (C) 2023-present Hydrogram <https://hydrogram.org>
#
# This file is part of Hydrogram.
#
# Hydrogram 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.
#
# Hydrogram 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 Hydrogram. If not, see <http://www.gnu.org/licenses/>.

import hydrogram


class CloseGeneralForumTopic:
async def close_general_forum_topic(self: hydrogram.Client, chat_id: int | str) -> bool:
"""Close a general forum topic.

This is an alias of :meth:`~Client.close_general_topic` for Bot API compatibility.
"""
return await self.close_general_topic(chat_id)
32 changes: 32 additions & 0 deletions hydrogram/methods/chats/edit_general_forum_topic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Hydrogram - Telegram MTProto API Client for Python
# Copyright (C) 2017-2023 Dan <https://github.com/delivrance>
# Copyright (C) 2023-present Hydrogram <https://hydrogram.org>
#
# This file is part of Hydrogram.
#
#
# Hydrogram 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.
#
# Hydrogram 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 Hydrogram. If not, see <http://www.gnu.org/licenses/>.

import hydrogram


class EditGeneralForumTopic:
async def edit_general_forum_topic(
self: hydrogram.Client, chat_id: int | str, title: str
) -> bool:
"""Edit a general forum topic.

This is an alias of :meth:`~Client.edit_general_topic` for Bot API compatibility.
"""
return await self.edit_general_topic(chat_id, title)
37 changes: 37 additions & 0 deletions hydrogram/methods/chats/get_chat_administrators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Hydrogram - Telegram MTProto API Client for Python
# Copyright (C) 2017-2023 Dan <https://github.com/delivrance>
# Copyright (C) 2023-present Hydrogram <https://hydrogram.org>
#
# This file is part of Hydrogram.
#
# Hydrogram 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.
#
# Hydrogram 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.
#
from __future__ import annotations

import hydrogram
from hydrogram import enums, types



class GetChatAdministrators:
async def get_chat_administrators(
self: hydrogram.Client, chat_id: int | str
) -> list[types.ChatMember]:
"""Get administrators of a chat.

This is an alias of :meth:`~Client.get_chat_members` for Bot API compatibility.
"""
return [
member
async for member in self.get_chat_members(
chat_id=chat_id, filter=enums.ChatMembersFilter.ADMINISTRATORS
)
]
31 changes: 31 additions & 0 deletions hydrogram/methods/chats/get_chat_member_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Hydrogram - Telegram MTProto API Client for Python
# Copyright (C) 2017-2023 Dan <https://github.com/delivrance>
# Copyright (C) 2023-present Hydrogram <https://hydrogram.org>
#
# This file is part of Hydrogram.
#
# Hydrogram 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.
#
# Hydrogram 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 Hydrogram. If not, see <http://www.gnu.org/licenses/>.

from __future__ import annotations

import hydrogram


class GetChatMemberCount:
async def get_chat_member_count(self: hydrogram.Client, chat_id: int | str) -> int:
"""Get the number of members in a chat.

This is an alias of :meth:`~Client.get_chat_members_count` for Bot API compatibility.
"""
return await self.get_chat_members_count(chat_id)
29 changes: 29 additions & 0 deletions hydrogram/methods/chats/hide_general_forum_topic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Hydrogram - Telegram MTProto API Client for Python
# Copyright (C) 2017-2023 Dan <https://github.com/delivrance>
# Copyright (C) 2023-present Hydrogram <https://hydrogram.org>
#
# This file is part of Hydrogram.
#
# Hydrogram 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.
#
# Hydrogram 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 Hydrogram. If not, see <http://www.gnu.org/licenses/>.

import hydrogram


class HideGeneralForumTopic:
async def hide_general_forum_topic(self: hydrogram.Client, chat_id: int | str) -> bool:
"""Hide the general forum topic.

This is an alias of :meth:`~Client.hide_general_topic` for Bot API compatibility.
"""
return await self.hide_general_topic(chat_id)
Loading