mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 12:04:51 +00:00
pyrofork: Move forums methods to separate category and adapt to new layer
Signed-off-by: wulan17 <wulan17@komodos.id>
This commit is contained in:
parent
8c6bad6aa4
commit
12cf466b23
16 changed files with 64 additions and 39 deletions
|
|
@ -23,6 +23,7 @@ from .bots import Bots
|
||||||
from .chats import Chats
|
from .chats import Chats
|
||||||
from .contacts import Contacts
|
from .contacts import Contacts
|
||||||
from .decorators import Decorators
|
from .decorators import Decorators
|
||||||
|
from .forums import Forums
|
||||||
from .invite_links import InviteLinks
|
from .invite_links import InviteLinks
|
||||||
from .messages import Messages
|
from .messages import Messages
|
||||||
from .password import Password
|
from .password import Password
|
||||||
|
|
@ -45,6 +46,7 @@ class Methods(
|
||||||
Payments,
|
Payments,
|
||||||
Phone,
|
Phone,
|
||||||
Chats,
|
Chats,
|
||||||
|
Forums,
|
||||||
Stickers,
|
Stickers,
|
||||||
Users,
|
Users,
|
||||||
Messages,
|
Messages,
|
||||||
|
|
|
||||||
|
|
@ -21,24 +21,14 @@ from .add_chat_members import AddChatMembers
|
||||||
from .archive_chats import ArchiveChats
|
from .archive_chats import ArchiveChats
|
||||||
from .ban_chat_member import BanChatMember
|
from .ban_chat_member import BanChatMember
|
||||||
from .create_channel import CreateChannel
|
from .create_channel import CreateChannel
|
||||||
from .create_forum_topic import CreateForumTopic
|
|
||||||
from .create_group import CreateGroup
|
from .create_group import CreateGroup
|
||||||
from .create_supergroup import CreateSupergroup
|
from .create_supergroup import CreateSupergroup
|
||||||
from .close_forum_topic import CloseForumTopic
|
|
||||||
from .close_general_topic import CloseGeneralTopic
|
|
||||||
from .delete_channel import DeleteChannel
|
from .delete_channel import DeleteChannel
|
||||||
from .delete_chat_photo import DeleteChatPhoto
|
from .delete_chat_photo import DeleteChatPhoto
|
||||||
from .delete_folder import DeleteFolder
|
from .delete_folder import DeleteFolder
|
||||||
from .delete_forum_topic import DeleteForumTopic
|
|
||||||
from .delete_supergroup import DeleteSupergroup
|
from .delete_supergroup import DeleteSupergroup
|
||||||
from .delete_user_history import DeleteUserHistory
|
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 .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 import GetChat
|
||||||
from .get_chat_event_log import GetChatEventLog
|
from .get_chat_event_log import GetChatEventLog
|
||||||
from .get_chat_member import GetChatMember
|
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 import GetDialogs
|
||||||
from .get_dialogs_count import GetDialogsCount
|
from .get_dialogs_count import GetDialogsCount
|
||||||
from .get_folders import GetFolders
|
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 .get_send_as_chats import GetSendAsChats
|
||||||
from .join_chat import JoinChat
|
from .join_chat import JoinChat
|
||||||
from .leave_chat import LeaveChat
|
from .leave_chat import LeaveChat
|
||||||
|
|
@ -98,29 +85,16 @@ class Chats(
|
||||||
SetChatPermissions,
|
SetChatPermissions,
|
||||||
GetDialogsCount,
|
GetDialogsCount,
|
||||||
GetFolders,
|
GetFolders,
|
||||||
GetForumTopics,
|
|
||||||
GetForumTopicsByID,
|
|
||||||
GetForumTopicsCount,
|
|
||||||
ArchiveChats,
|
ArchiveChats,
|
||||||
UnarchiveChats,
|
UnarchiveChats,
|
||||||
CreateGroup,
|
CreateGroup,
|
||||||
CreateSupergroup,
|
CreateSupergroup,
|
||||||
CreateChannel,
|
CreateChannel,
|
||||||
CreateForumTopic,
|
|
||||||
CloseForumTopic,
|
|
||||||
CloseGeneralTopic,
|
|
||||||
AddChatMembers,
|
AddChatMembers,
|
||||||
DeleteChannel,
|
DeleteChannel,
|
||||||
DeleteFolder,
|
DeleteFolder,
|
||||||
DeleteForumTopic,
|
|
||||||
DeleteSupergroup,
|
DeleteSupergroup,
|
||||||
EditForumTopic,
|
|
||||||
EditGeneralTopic,
|
|
||||||
ExportFolderLink,
|
ExportFolderLink,
|
||||||
ReopenForumTopic,
|
|
||||||
ReopenGeneralTopic,
|
|
||||||
HideGeneralTopic,
|
|
||||||
UnhideGeneralTopic,
|
|
||||||
SetAdministratorTitle,
|
SetAdministratorTitle,
|
||||||
SetSlowMode,
|
SetSlowMode,
|
||||||
DeleteUserHistory,
|
DeleteUserHistory,
|
||||||
|
|
|
||||||
49
pyrogram/methods/forums/__init__.py
Normal file
49
pyrogram/methods/forums/__init__.py
Normal 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
|
||||||
|
|
@ -48,7 +48,7 @@ class CloseForumTopic:
|
||||||
await app.close_forum_topic(chat_id, topic_id)
|
await app.close_forum_topic(chat_id, topic_id)
|
||||||
"""
|
"""
|
||||||
await self.invoke(
|
await self.invoke(
|
||||||
raw.functions.channels.EditForumTopic(
|
raw.functions.messages.EditForumTopic(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
topic_id=topic_id,
|
topic_id=topic_id,
|
||||||
closed=True
|
closed=True
|
||||||
|
|
@ -44,7 +44,7 @@ class CloseGeneralTopic:
|
||||||
await app.close_general_topic(chat_id)
|
await app.close_general_topic(chat_id)
|
||||||
"""
|
"""
|
||||||
await self.invoke(
|
await self.invoke(
|
||||||
raw.functions.channels.EditForumTopic(
|
raw.functions.messages.EditForumTopic(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
topic_id=1,
|
topic_id=1,
|
||||||
closed=True
|
closed=True
|
||||||
|
|
@ -56,7 +56,7 @@ class CreateForumTopic:
|
||||||
await app.create_forum_topic("Topic Title")
|
await app.create_forum_topic("Topic Title")
|
||||||
"""
|
"""
|
||||||
r = await self.invoke(
|
r = await self.invoke(
|
||||||
raw.functions.channels.CreateForumTopic(
|
raw.functions.messages.CreateForumTopic(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
title=title,
|
title=title,
|
||||||
random_id=self.rnd_id(),
|
random_id=self.rnd_id(),
|
||||||
|
|
@ -49,7 +49,7 @@ class DeleteForumTopic:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
await self.invoke(
|
await self.invoke(
|
||||||
raw.functions.channels.DeleteTopicHistory(
|
raw.functions.messages.DeleteTopicHistory(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
top_msg_id=topic_id
|
top_msg_id=topic_id
|
||||||
)
|
)
|
||||||
|
|
@ -56,7 +56,7 @@ class EditForumTopic:
|
||||||
await app.edit_forum_topic(chat_id,topic_id,"New Topic Title")
|
await app.edit_forum_topic(chat_id,topic_id,"New Topic Title")
|
||||||
"""
|
"""
|
||||||
await self.invoke(
|
await self.invoke(
|
||||||
raw.functions.channels.EditForumTopic(
|
raw.functions.messages.EditForumTopic(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
topic_id=topic_id,
|
topic_id=topic_id,
|
||||||
title=title,
|
title=title,
|
||||||
|
|
@ -48,7 +48,7 @@ class EditGeneralTopic:
|
||||||
await app.edit_general_topic(chat_id,"New Topic Title")
|
await app.edit_general_topic(chat_id,"New Topic Title")
|
||||||
"""
|
"""
|
||||||
await self.invoke(
|
await self.invoke(
|
||||||
raw.functions.channels.EditForumTopic(
|
raw.functions.messages.EditForumTopic(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
topic_id=1,
|
topic_id=1,
|
||||||
title=title
|
title=title
|
||||||
|
|
@ -37,7 +37,7 @@ async def get_chunk(
|
||||||
peer = await client.resolve_peer(chat_id)
|
peer = await client.resolve_peer(chat_id)
|
||||||
|
|
||||||
r = await client.invoke(
|
r = await client.invoke(
|
||||||
raw.functions.channels.GetForumTopics(
|
raw.functions.messages.GetForumTopics(
|
||||||
channel=peer,
|
channel=peer,
|
||||||
offset_date=offset_date,
|
offset_date=offset_date,
|
||||||
offset_id=offset_id,
|
offset_id=offset_id,
|
||||||
|
|
@ -76,7 +76,7 @@ class GetForumTopicsByID:
|
||||||
ids = list(ids) if is_iterable else [ids]
|
ids = list(ids) if is_iterable else [ids]
|
||||||
ids = [i for i in 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)
|
r = await self.invoke(rpc, sleep_threshold=-1)
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ class GetForumTopicsCount:
|
||||||
|
|
||||||
peer = await self.resolve_peer(chat_id)
|
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)
|
r = await self.invoke(rpc, sleep_threshold=-1)
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ class HideGeneralTopic:
|
||||||
await app.hide_general_topic(chat_id)
|
await app.hide_general_topic(chat_id)
|
||||||
"""
|
"""
|
||||||
await self.invoke(
|
await self.invoke(
|
||||||
raw.functions.channels.EditForumTopic(
|
raw.functions.messages.EditForumTopic(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
topic_id=1,
|
topic_id=1,
|
||||||
hidden=True
|
hidden=True
|
||||||
|
|
@ -48,7 +48,7 @@ class ReopenForumTopic:
|
||||||
await app.reopen_forum_topic(chat_id, topic_id)
|
await app.reopen_forum_topic(chat_id, topic_id)
|
||||||
"""
|
"""
|
||||||
await self.invoke(
|
await self.invoke(
|
||||||
raw.functions.channels.EditForumTopic(
|
raw.functions.messages.EditForumTopic(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
topic_id=topic_id,
|
topic_id=topic_id,
|
||||||
closed=False
|
closed=False
|
||||||
|
|
@ -44,7 +44,7 @@ class ReopenGeneralTopic:
|
||||||
await app.reopen_general_topic(chat_id, topic_id)
|
await app.reopen_general_topic(chat_id, topic_id)
|
||||||
"""
|
"""
|
||||||
await self.invoke(
|
await self.invoke(
|
||||||
raw.functions.channels.EditForumTopic(
|
raw.functions.messages.EditForumTopic(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
topic_id=1,
|
topic_id=1,
|
||||||
closed=False
|
closed=False
|
||||||
|
|
@ -44,7 +44,7 @@ class UnhideGeneralTopic:
|
||||||
await app.unhide_general_topic(chat_id)
|
await app.unhide_general_topic(chat_id)
|
||||||
"""
|
"""
|
||||||
await self.invoke(
|
await self.invoke(
|
||||||
raw.functions.channels.EditForumTopic(
|
raw.functions.messages.EditForumTopic(
|
||||||
channel=await self.resolve_peer(chat_id),
|
channel=await self.resolve_peer(chat_id),
|
||||||
topic_id=1,
|
topic_id=1,
|
||||||
hidden=False
|
hidden=False
|
||||||
Loading…
Reference in a new issue