File tree Expand file tree Collapse file tree 1 file changed +11
-15
lines changed Expand file tree Collapse file tree 1 file changed +11
-15
lines changed Original file line number Diff line number Diff line change 1
1
from telethon import TelegramClient , events
2
2
from telethon .tl .functions .messages import ForwardMessagesRequest
3
-
4
-
5
-
6
-
7
-
8
- api_id = < Your Telegram API ID >
3
+ api_id = 111111
4
+ # Replace 111111 with Your Telegram API ID
9
5
api_hash = 'Your Telegram Hash ID'
10
6
client = TelegramClient ('anon' , api_id , api_hash )
7
+
8
+
11
9
@client .on (events . NewMessage (outgoing = False ))
12
- async def handler (event ):
10
+ async def handler (event ):
13
11
chat_id = event .chat_id
14
- # Let's print all the chat ids you are incoming messages from
12
+ # Let's print all the chat ids you are incoming messages from
15
13
print (chat_id )
16
- #If you just want to get messages from 1 chat just remove the or statement after the 1st one
17
- if chat_id == < Chat Id of the origin message Here > or chat_id == < Chat Id of the origin message Here > or chat_id == < Chat Id of the origin message Here > :
14
+ if chat_id == 22222 :
15
+ # Replace 22222 with the Chat Id of the origin message Here
18
16
msg = event .raw_text
19
- await client . send_message (< Chat Id of of the Chat Where To Send > ,msg )
20
-
21
-
22
-
17
+ await client . send_message (44444 , msg )
18
+ # Replace 44444 with the Chat Id of of the Chat Where To Send
23
19
client .start ()
24
- client .run_until_disconnected ()
20
+ client .run_until_disconnected ()
You can’t perform that action at this time.
0 commit comments