pyrofork: Move forums methods to separate category and adapt to new layer

Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
wulan17 2025-10-24 15:34:38 +07:00
parent 8c6bad6aa4
commit 12cf466b23
No known key found for this signature in database
GPG key ID: 737814D4B5FF0420
16 changed files with 64 additions and 39 deletions

View file

@ -23,6 +23,7 @@ from .bots import Bots
from .chats import Chats
from .contacts import Contacts
from .decorators import Decorators
from .forums import Forums
from .invite_links import InviteLinks
from .messages import Messages
from .password import Password
@ -45,6 +46,7 @@ class Methods(
Payments,
Phone,
Chats,
Forums,
Stickers,
Users,
Messages,

View file

@ -21,24 +21,14 @@ from .add_chat_members import AddChatMembers
from .archive_chats import ArchiveChats
from .ban_chat_member import BanChatMember
from .create_channel import CreateChannel
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_folder import DeleteFolder
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 .export_folder_link import ExportFolderLink
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
@ -48,9 +38,6 @@ from .get_chat_online_count import GetChatOnlineCount
from .get_dialogs import GetDialogs
from .get_dialogs_count import GetDialogsCount
from .get_folders import GetFolders
from .get_forum_topics import GetForumTopics
from .get_forum_topics_by_id import GetForumTopicsByID
from .get_forum_topics_count import GetForumTopicsCount
from .get_send_as_chats import GetSendAsChats
from .join_chat import JoinChat
from .leave_chat import LeaveChat
@ -98,29 +85,16 @@ class Chats(
SetChatPermissions,
GetDialogsCount,
GetFolders,
GetForumTopics,
GetForumTopicsByID,
GetForumTopicsCount,
ArchiveChats,
UnarchiveChats,
CreateGroup,
CreateSupergroup,
CreateChannel,
CreateForumTopic,
CloseForumTopic,
CloseGeneralTopic,
AddChatMembers,
DeleteChannel,
DeleteFolder,
DeleteForumTopic,
DeleteSupergroup,
EditForumTopic,
EditGeneralTopic,
ExportFolderLink,
ReopenForumTopic,
ReopenGeneralTopic,
HideGeneralTopic,
UnhideGeneralTopic,
SetAdministratorTitle,
SetSlowMode,
DeleteUserHistory,

View file

@ -0,0 +1,49 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork 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.
#
# Pyrofork 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 Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from .create_forum_topic import CreateForumTopic
from .close_forum_topic import CloseForumTopic
from .close_general_topic import CloseGeneralTopic
from .delete_forum_topic import DeleteForumTopic
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_forum_topics import GetForumTopics
from .get_forum_topics_by_id import GetForumTopicsByID
from .get_forum_topics_count import GetForumTopicsCount
class Forums(
GetForumTopics,
GetForumTopicsByID,
GetForumTopicsCount,
CreateForumTopic,
CloseForumTopic,
CloseGeneralTopic,
DeleteForumTopic,
EditForumTopic,
EditGeneralTopic,
ReopenForumTopic,
ReopenGeneralTopic,
HideGeneralTopic,
UnhideGeneralTopic,
):
pass

View file

@ -48,7 +48,7 @@ class CloseForumTopic:
await app.close_forum_topic(chat_id, topic_id)
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
raw.functions.messages.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=topic_id,
closed=True

View file

@ -44,7 +44,7 @@ class CloseGeneralTopic:
await app.close_general_topic(chat_id)
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
raw.functions.messages.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=1,
closed=True

View file

@ -56,7 +56,7 @@ class CreateForumTopic:
await app.create_forum_topic("Topic Title")
"""
r = await self.invoke(
raw.functions.channels.CreateForumTopic(
raw.functions.messages.CreateForumTopic(
channel=await self.resolve_peer(chat_id),
title=title,
random_id=self.rnd_id(),

View file

@ -49,7 +49,7 @@ class DeleteForumTopic:
"""
try:
await self.invoke(
raw.functions.channels.DeleteTopicHistory(
raw.functions.messages.DeleteTopicHistory(
channel=await self.resolve_peer(chat_id),
top_msg_id=topic_id
)

View file

@ -56,7 +56,7 @@ class EditForumTopic:
await app.edit_forum_topic(chat_id,topic_id,"New Topic Title")
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
raw.functions.messages.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=topic_id,
title=title,

View file

@ -48,7 +48,7 @@ class EditGeneralTopic:
await app.edit_general_topic(chat_id,"New Topic Title")
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
raw.functions.messages.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=1,
title=title

View file

@ -37,7 +37,7 @@ async def get_chunk(
peer = await client.resolve_peer(chat_id)
r = await client.invoke(
raw.functions.channels.GetForumTopics(
raw.functions.messages.GetForumTopics(
channel=peer,
offset_date=offset_date,
offset_id=offset_id,

View file

@ -76,7 +76,7 @@ class GetForumTopicsByID:
ids = list(ids) if is_iterable else [ids]
ids = [i for i in ids]
rpc = raw.functions.channels.GetForumTopicsByID(channel=peer, topics=ids)
rpc = raw.functions.messages.GetForumTopicsByID(channel=peer, topics=ids)
r = await self.invoke(rpc, sleep_threshold=-1)

View file

@ -56,7 +56,7 @@ class GetForumTopicsCount:
peer = await self.resolve_peer(chat_id)
rpc = raw.functions.channels.GetForumTopics(channel=peer, offset_date=0, offset_id=0, offset_topic=0, limit=0)
rpc = raw.functions.messages.GetForumTopics(channel=peer, offset_date=0, offset_id=0, offset_topic=0, limit=0)
r = await self.invoke(rpc, sleep_threshold=-1)

View file

@ -43,7 +43,7 @@ class HideGeneralTopic:
await app.hide_general_topic(chat_id)
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
raw.functions.messages.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=1,
hidden=True

View file

@ -48,7 +48,7 @@ class ReopenForumTopic:
await app.reopen_forum_topic(chat_id, topic_id)
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
raw.functions.messages.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=topic_id,
closed=False

View file

@ -44,7 +44,7 @@ class ReopenGeneralTopic:
await app.reopen_general_topic(chat_id, topic_id)
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
raw.functions.messages.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=1,
closed=False

View file

@ -44,7 +44,7 @@ class UnhideGeneralTopic:
await app.unhide_general_topic(chat_id)
"""
await self.invoke(
raw.functions.channels.EditForumTopic(
raw.functions.messages.EditForumTopic(
channel=await self.resolve_peer(chat_id),
topic_id=1,
hidden=False