Skip to content

Commit c50d366

Browse files
committed
Added Telegram Forward bot
1 parent 102454a commit c50d366

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

telegram_forward_bot/ReadMe.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### Telegram_Quotefancy
2+
- Script to forward message from one/multiple chat to another.
3+
- Telegram Bot API is used to Connect to Telegram. (`https://api.telegram.org`)
4+
5+
6+
#### Install Requirements
7+
```
8+
pip3 install telethon
9+
10+
```
11+
12+
#### Running Script
13+
```
14+
python3 bot.py
15+
```

telegram_forward_bot/bot.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from telethon import TelegramClient, events
2+
from telethon.tl.functions.messages import ForwardMessagesRequest
3+
4+
5+
6+
7+
8+
api_id = <Your Telegram API ID>
9+
api_hash = 'Your Telegram Hash ID'
10+
client = TelegramClient('anon', api_id, api_hash)
11+
@client.on(events. NewMessage(outgoing=False))
12+
async def handler(event):
13+
chat_id = event.chat_id
14+
# Let's print all the chat ids you are incoming messages from
15+
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>:
18+
msg = event.raw_text
19+
await client. send_message(<Chat Id of of the Chat Where To Send>,msg)
20+
21+
22+
23+
client.start()
24+
client.run_until_disconnected()

0 commit comments

Comments
 (0)