Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Forum Topic and update to layer 160 #1157

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

wulan17
Copy link

@wulan17 wulan17 commented Dec 9, 2022

Changes:

  • Add message_thread_id and is_topic_message field to Message
  • Add topics field to Message (only returned using get_messages())
  • Add is_forum field to Chat
  • Add can_manage_topics field to ChatPrivileges and ChatPermissions
  • Add message_thread_id parameter to send_animation, send_audio, send_cached_media, send_chat_action, send_contact, send_dice, send_document, send_game, send_location, send_media_group, send_message, send_photo, send_poll, send_sticker, send_venue, send_video, send_video_note, and send_voice methods
  • Add message_thread_id parameter to forward_message(), and copy_message() methods
  • Add message_thread_id parameter to forward(), and copy() bound methods
  • Add ForumTopic, ForumTopicCreated, ForumTopicEdited, ForumTopicClosed, ForumTopicReopened, GeneralTopicHidden, GeneralTopicUnhidden Class
  • Add PeerChannel and PeerUser Class
  • Add CREATED_FORUM_TOPIC,EDITED_FORUM_TOPIC,DELETED_FORUM_TOPIC ChatEventType
  • Add create_forum_topic, edit_forum_topic, close_forum_topic, and reopen_forum_topic methods
  • Add close_general_topic, edit_general_topic, reopen_general_topic, hide_general_topic, unhide_general_topic methods
  • Update API SCHEMA to layer 160
  • Add TOPIC_CLOSED and TOPIC_DELETED to known errors
  • Update some methods to support layer 160

Example:

Topic Management

with Client(app_id,app_hash) as app:
    app.create_forum_topic("Topic Title")
    app.edit_forum_topic(chat_id,topic_id,"New Topic Title")
    app.close_forum_topic(chat_id,topic_id)
    app.reopen_forum_topic(chat_id,topic_id)
    app.delete_forum_topic(chat_id,topic_id)
    app.edit_general_topic(chat_id, "New General Topic Name")
    app.close_general_topic(chat_id)
    app.reopen_general_topic(chat_id)
    app.hide_general_topic(chat_id)
    app.unhide_general_topic(chat_id)

Send message to spesific topic

@app.on_message()
async def func(client,message):
    chat_id = message.chat.id
    message_thread_id = message.message_thread_id
    app.send_message(chat_id=chat_id, text="text", message_thread_id=message_thread_id)

Check if chat is forum

@app.on_message()
async def check_forum(client, message):
    if message.chat.is_forum:
        ...

Or

@app.on_message()
async def check_forum(client, message):
    if message.is_topic_message: (not work for message from general topic)
        ...

@wulan17 wulan17 force-pushed the dev/topics-1 branch 5 times, most recently from 86883a3 to 5793862 Compare December 14, 2022 06:42
@wulan17 wulan17 force-pushed the dev/topics-1 branch 8 times, most recently from 7b67a6e to 67d63bd Compare January 4, 2023 03:39
@aas73000
Copy link

When this feature will be added in pyrogram official update?

@BrandoDev
Copy link

When this feature will be added in pyrogram official update?

It would be nice... I need it

@avdosev
Copy link

avdosev commented Mar 15, 2023

@delivrance This is an important pull request and my work depends on it. It would be great if this gets included in the future release.

@avdosev
Copy link

avdosev commented May 4, 2023

Any progress?

@alekssamos
Copy link

Yes, I'm also surprised, so many versions (2.x) have already been released, and PRs has been stuck without any reaction

…e class, and is_forum fields to Chat class

Signed-off-by: wulan17 <wulan17@nusantararom.org>
…, ForumTopicEdited service message types

Signed-off-by: wulan17 <wulan17@nusantararom.org>
…issions class

Signed-off-by: wulan17 <wulan17@nusantararom.org>
…t_chat_member, and set_chat_permissions methods

Signed-off-by: wulan17 <wulan17@nusantararom.org>
…ched_media,contact,dice,document,location,media_group,message,photo,poll,sticker,venue,video,video_note,voice} methods

Signed-off-by: wulan17 <wulan17@nusantararom.org>
… and forward() bound method

Signed-off-by: wulan17 <wulan17@nusantararom.org>
…opy() bound method

Signed-off-by: wulan17 <wulan17@nusantararom.org>
Signed-off-by: wulan17 <wulan17@nusantararom.org>
Signed-off-by: wulan17 <wulan17@nusantararom.org>
Signed-off-by: wulan17 <wulan17@nusantararom.org>
Signed-off-by: wulan17 <wulan17@nusantararom.org>
Signed-off-by: wulan17 <wulan17@nusantararom.org>
wulan17 and others added 13 commits July 23, 2023 16:57
Signed-off-by: wulan17 <wulan17@nusantararom.org>
Signed-off-by: wulan17 <wulan17@nusantararom.org>
Signed-off-by: wulan17 <wulan17@nusantararom.org>
…sages types

Signed-off-by: wulan17 <wulan17@nusantararom.org>
Signed-off-by: wulan17 <wulan17@nusantararom.org>
…, HideGeneralTopic. UnhideGeneralTopic, and some cleanup

Signed-off-by: wulan17 <wulan17@nusantararom.org>
Signed-off-by: wulan17 <galihgustip@gmail.com>
Signed-off-by: wulan17 <galihgustip@gmail.com>
Signed-off-by: wulan17 <galihgustip@gmail.com>
Signed-off-by: wulan17 <galihgustip@gmail.com>
Signed-off-by: wulan17 <wulan17@nusantararom.org>
Signed-off-by: wulan17 <wulan17@nusantararom.org>
Signed-off-by: wulan17 <wulan17@nusantararom.org>
@wulan17 wulan17 changed the title Add support for Forum Topic Add support for Forum Topic and update to layer 160 Jul 23, 2023
Signed-off-by: wulan17 <wulan17@nusantararom.org>
@yshalsager
Copy link

Any update on this? I find it's weird that such important change is not added yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants