I wanted to send a message to Forum Topic:
from pyrogram import Client, filters
from pyrogram.raw import functions,types
app = Client("my_account", api_id="12345678", api_hash="g8u4h894urgh09eurhiugfdgfrgrg")
async def get_chat_themes(client):
result = await app.invoke(
functions.messages.SendMessage(peer =types.InputPeerChannel(channel_id=12345,access_hash=-1234),message ="Test",random_id =-1)
)
print(result)
with app:
app.loop.run_until_complete(get_chat_themes(app))
This code sends a message to topic #General, how can I send it to another topic? GetForumTopics outputs this:
{
"_": "types.messages.ForumTopics",
"count": 1,
"topics": [
{
"_": "types.ForumTopic",
"id": 12,
"date": 1688764942,
"title": "1",
"icon_color": 16766590,
"top_message": 12,
"read_inbox_max_id": 13,
"read_outbox_max_id": 0,
"unread_count": 0,
"unread_mentions_count": 0,
"unread_reactions_count": 0,
"from_id": {
"_": "types.PeerUser",
"user_id":
},
"notify_settings": {
"_": "types.PeerNotifySettings"
},
"my": true,
"closed": false,
"pinned": false,
"short": false,
"hidden": false
},
{
"_": "types.ForumTopic",
"id": 1,
"date": 1688762115,
"title": "General",
"icon_color": 7322096,
"top_message": 3,
"read_inbox_max_id": 9,
"read_outbox_max_id": 9,
"unread_count": 0,
"unread_mentions_count": 0,
"unread_reactions_count": 0,
"from_id": {
"_": "types.PeerChannel",
"channel_id":
},
"notify_settings": {
"_": "types.PeerNotifySettings"
},
"my": true,
"closed": false,
"pinned": false,
"short": false,
"hidden": false
}
],
"messages": [
{
"_": "types.MessageService",
"id": 12,
"peer_id": {
"_": "types.PeerChannel",
"channel_id":
},
"date": 1688764942,
"action": {
"_": "types.MessageActionTopicCreate",
"title": "1",
"icon_color": 16766590
},
"out": true,
"mentioned": false,
"media_unread": false,
"silent": false,
"post": false,
"legacy": false,
"from_id": {
"_": "types.PeerUser",
"user_id":
}
},
{
"_": "types.MessageService",
"id": 3,
"peer_id": {
"_": "types.PeerChannel",
"channel_id":
},
"date": 1688762477,
"action": {
"_": "types.MessageActionChatAddUser",
"users": [
]
},
"out": true,
"mentioned": false,
"media_unread": false,
"silent": false,
"post": false,
"legacy": false,
"from_id": {
"_": "types.PeerUser",
"user_id":
}
}
],
"chats": [
{
"_": "types.Channel",
"id": ,
"title": "",
"photo": {
"_": "types.ChatPhotoEmpty"
},
"date": 1688762115,
"creator": true,
"left": false,
"broadcast": false,
"verified": false,
"megagroup": true,
"restricted": false,
"signatures": false,
"min": false,
"scam": false,
"has_link": false,
"has_geo": false,
"slowmode_enabled": false,
"call_active": false,
"call_not_empty": false,
"fake": false,
"gigagroup": false,
"noforwards": false,
"join_to_send": false,
"join_request": false,
"forum": true,
"access_hash": -,
"restriction_reason": [],
"admin_rights": {
"_": "types.ChatAdminRights",
"change_info": true,
"post_messages": true,
"edit_messages": true,
"delete_messages": true,
"ban_users": true,
"invite_users": true,
"pin_messages": true,
"add_admins": true,
"anonymous": false,
"manage_call": true,
"other": true,
"manage_topics": true
},
"default_banned_rights": {
"_": "types.ChatBannedRights",
"until_date": 2147483647,
"view_messages": false,
"send_messages": false,
"send_media": false,
"send_stickers": false,
"send_gifs": false,
"send_games": false,
"send_inline": false,
"embed_links": false,
"send_polls": false,
"change_info": false,
"invite_users": false,
"pin_messages": false,
"manage_topics": false,
"send_photos": false,
"send_videos": false,
"send_roundvideos": false,
"send_audios": false,
"send_voices": false,
"send_docs": false,
"send_plain": false
},
"usernames": []
}
],
"users": [
{
"_": "types.User",
"id": ,
"is_self": true,
"contact": false,
"mutual_contact": false,
"deleted": false,
"bot": false,
"bot_chat_history": false,
"bot_nochats": false,
"verified": false,
"restricted": false,
"min": false,
"bot_inline_geo": false,
"support": false,
"scam": false,
"apply_min_photo": true,
"fake": false,
"bot_attach_menu": false,
"premium": false,
"attach_menu_enabled": false,
"bot_can_edit": false,
"access_hash": ,
"first_name": "",
"username": "",
"phone": "",
"status": {
"_": "types.UserStatusOffline",
"was_online":
},
"restriction_reason": [],
"usernames": []
},
{
"_": "types.User",
"id": ,
"is_self": false,
"contact": false,
"mutual_contact": false,
"deleted": false,
"bot": true,
"bot_chat_history": false,
"bot_nochats": false,
"verified": false,
"restricted": false,
"min": false,
"bot_inline_geo": false,
"support": false,
"scam": false,
"apply_min_photo": true,
"fake": false,
"bot_attach_menu": false,
"premium": false,
"attach_menu_enabled": false,
"bot_can_edit": true,
"access_hash": ,
"first_name": "Test",
"username": "Testrobot123_robot",
"bot_info_version": 1,
"restriction_reason": [],
"usernames": []
}
],
"pts": 26,
"order_by_create_date": false
}
I tried to find in the documentation how to send a message to the forum and found only functions.messages.SendMessage. Maybe there is a solution to my problem using another library.