Skip to content

Commit 8c8bafc

Browse files
authored
Merge pull request #784 from Hastech77/telegram-bot
Telegram bot
2 parents b086be4 + 8c52d3a commit 8c8bafc

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

telegram_forward_bot/ReadMe.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Telegram Forward Bot
2+
3+
Short description of package/script
4+
5+
- Script to forward message from one/multiple chat to another.
6+
- Telegram Bot API is used to Connect to Telegram. (`https://api.telegram.org`)
7+
8+
9+
10+
#### Install Requirements
11+
```
12+
pip3 install telethon
13+
14+
```
15+
16+
#### Running Script
17+
```
18+
python3 bot.py
19+
```
20+
21+
## Author(s)
22+
23+
By Hastech77

telegram_forward_bot/bot.py

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

telegram_forward_bot/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
telethon

0 commit comments

Comments
 (0)