PyroFork: Add CloseGeneralTopic, EditGeneralTopic, ReopenGeneralTopic, HideGeneralTopic. UnhideGeneralTopic, and some cleanup

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-01-02 00:35:32 +07:00
parent b64d33dca0
commit 97f0ecc7c9
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
9 changed files with 293 additions and 31 deletions

View file

@ -24,13 +24,18 @@ from .create_forum_topic import CreateForumTopic
from .create_group import CreateGroup
from .create_supergroup import CreateSupergroup
from .close_forum_topic import CloseForumTopic
from .close_general_topic import CloseGeneralTopic
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 .reopen_forum_topic import ReopenForumTopic
from .reopen_general_topic import ReopenGeneralTopic
from .hide_general_topic import HideGeneralTopic
from .unhide_general_topic import UnhideGeneralTopic
from .get_chat import GetChat
from .get_chat_event_log import GetChatEventLog
from .get_chat_member import GetChatMember
@ -90,12 +95,17 @@ class Chats(
CreateChannel,
CreateForumTopic,
CloseForumTopic,
CloseGeneralTopic,
AddChatMembers,
DeleteChannel,
DeleteForumTopic,
DeleteSupergroup,
EditForumTopic,
EditGeneralTopic,
ReopenForumTopic,
ReopenGeneralTopic,
HideGeneralTopic,
UnhideGeneralTopic,
GetNearbyChats,
SetAdministratorTitle,
SetSlowMode,

View file

@ -46,15 +46,11 @@ class CloseForumTopic:
await app.close_forum_topic(chat_id, topic_id)
"""
try:
await self.invoke(
raw.functions.channels.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=topic_id,
closed=True
)
await self.invoke(
raw.functions.channels.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=topic_id,
closed=True
)
except Exception as e:
print(e)
return False
)
return True

View file

@ -0,0 +1,52 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# 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/>.
import pyrogram
from pyrogram import raw
from pyrogram import types
from typing import Union
class CloseGeneralTopic:
async def close_general_topic(
self: "pyrogram.Client",
chat_id: Union[int, str]
) -> bool:
"""Close a forum topic.
.. include:: /_includes/usable-by/users-bots.rst
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
Returns:
`bool`: On success, a Boolean is returned.
Example:
.. code-block:: python
await app.close_forum_topic(chat_id, topic_id)
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=1,
closed=True
)
)
return True

View file

@ -54,16 +54,12 @@ class EditForumTopic:
await app.edit_forum_topic(chat_id,topic_id,"New Topic Title")
"""
try:
await self.invoke(
raw.functions.channels.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=topic_id,
title=title,
icon_emoji_id=icon_emoji_id
)
await self.invoke(
raw.functions.channels.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=topic_id,
title=title,
icon_emoji_id=icon_emoji_id
)
except Exception as e:
print(e)
return False
)
return True

View file

@ -0,0 +1,56 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# 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/>.
import pyrogram
from pyrogram import raw
from pyrogram import types
from typing import Union
class EditGeneralTopic:
async def edit_general_topic(
self: "pyrogram.Client",
chat_id: Union[int, str],
title: str
) -> bool:
"""Edit a general forum topic.
.. include:: /_includes/usable-by/users-bots.rst
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
title (``str``):
The general forum topic title.
Returns:
`bool`: On success, a Boolean is returned.
Example:
.. code-block:: python
await app.edit_forum_topic(chat_id,topic_id,"New Topic Title")
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=1,
title=title
)
)
return True

View file

@ -0,0 +1,52 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# 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/>.
import pyrogram
from pyrogram import raw
from pyrogram import types
from typing import Union
class HideGeneralTopic:
async def hide_general_topic(
self: "pyrogram.Client",
chat_id: Union[int, str]
) -> bool:
"""hide a general forum topic.
.. include:: /_includes/usable-by/users-bots.rst
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
Returns:
`bool`: On success, a Boolean is returned.
Example:
.. code-block:: python
await app.close_forum_topic(chat_id, topic_id)
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=1,
hidden=True
)
)
return True

View file

@ -46,15 +46,11 @@ class ReopenForumTopic:
await app.reopen_forum_topic(chat_id, topic_id)
"""
try:
await self.invoke(
raw.functions.channels.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=topic_id,
closed=False
)
await self.invoke(
raw.functions.channels.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=topic_id,
closed=False
)
except Exception as e:
print(e)
return False
)
return True

View file

@ -0,0 +1,52 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# 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/>.
import pyrogram
from pyrogram import raw
from pyrogram import types
from typing import Union
class ReopenGeneralTopic:
async def reopen_general_topic(
self: "pyrogram.Client",
chat_id: Union[int, str]
) -> bool:
"""Reopen a forum topic.
.. include:: /_includes/usable-by/users-bots.rst
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
Returns:
`bool`: On success, a Boolean is returned.
Example:
.. code-block:: python
await app.reopen_forum_topic(chat_id, topic_id)
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=1,
closed=False
)
)
return True

View file

@ -0,0 +1,52 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# 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/>.
import pyrogram
from pyrogram import raw
from pyrogram import types
from typing import Union
class UnhideGeneralTopic:
async def unhide_general_topic(
self: "pyrogram.Client",
chat_id: Union[int, str]
) -> bool:
"""unhide a general forum topic.
.. include:: /_includes/usable-by/users-bots.rst
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
Returns:
`bool`: On success, a Boolean is returned.
Example:
.. code-block:: python
await app.close_forum_topic(chat_id, topic_id)
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=1,
hidden=False
)
)
return True