-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
44 lines (32 loc) · 1.33 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from telethon import TelegramClient, events, sync, functions, types
# https://github.com/zhukov/webogram/blob/master/app/js/lib/config.js
api_id = 2496
api_hash = '8da85b0d5bfe62527e5b244c209159c3'
client = TelegramClient('session_name', api_id, api_hash)
client.start()
# https://t.me/c/1138803658/15
# https://t.me/pdcn1/237
print("If you are trying to send message to private channel linked discussion, you have to join the channel first!")
channelLink = input("Please paste any link in the channel with discussion enabled (e.g. https://t.me/pdcn1/237 | https://t.me/c/1138803658/15): ")
parts = channelLink.split("/")
peer = parts[-2]
msg_id = int(parts[-1])
print("Peer: {}, MSG: {}".format(peer, msg_id))
result = client(functions.messages.GetDiscussionMessageRequest(
peer=peer,
msg_id=msg_id
))
assoc = result.chats[0]
print("Assoc Group info: {}[{}]".format(assoc.title, assoc.id))
client(functions.messages.SendMessageRequest(
peer=assoc,
message="You don't need to join group to send message in discussion if you see this line.",
no_webpage=True,
))
client(functions.messages.SendMessageRequest(
peer=assoc,
reply_to_msg_id=msg_id,
message="You don't need to join group to replies if you see this line.",
no_webpage=True,
))
print("If you are reading this line, then the message should have sent to group.")