PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 12, 2022

[FIXED] How to Properly forward a message from another user's channel into a group?

 July 12, 2022     api, channel, forward, message, telegram     No comments   

Issue

i would like to know how can i forward a message from a given channel id with the message number ( like when you copy the message link from inside the telegram itself) to a given group join link using messages.forwardMessage from telegram API funtion?

i.e: this is my join link of the destination:
https://t.me/joinchat/AAAAAAlw6NYyLMlMES5hbw

and this is the message which should be forwarded to that above link: https://t.me/kjdfvbjkdfbvkj/3

Thank you ( esp to @apadana )


Solution

Here is how to forward from a group (not supergroup) to a channel. If you are looking for something else please comment.

#testChannel
source_chat_id=12345 
source_access_hash=1234567890
source_chat = InputPeerChannel(source_chat_id, source_access_hash)

#testGroup: 
dest_chat_id = 123456

# chat = InputPeerChannel(chat_id, access_hash)


total_count, messages, senders = client.get_message_history(
                        source_chat, limit=10)

msg = messages[0]    

dest_chat = InputPeerChat(dest_chat_id)
result = client.invoke(ForwardMessagesRequest(from_peer=source_chat, id=[msg.id], random_id=[generate_random_long()], to_peer=dest_chat))


Answered By - apadana
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing