-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtg.py
37 lines (31 loc) · 1015 Bytes
/
tg.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
#!/usr/bin/env python3
from pyrogram import Client
from pyrogram import filters
# ~~~~~~ CONFIG ~~~~~~~~ #
ACCOUNT = "@{your username}"
PHONE_NR = '+91{your telegram linked number}'
# https://my.telegram.org/auth?to=apps
API_ID = {Telegram app API ID}
API_HASH = "{TELEGRAM APP API HASH}"
# CHAT ID
SOURCE_CHAT = {CHAT ID FROM WHERE WANNA COPY}
TARGET_CHAT = {CHAT ID OF THE GROUP WHERE U WANNA PASTE THE MESSAGES}
# ~~~~~~~~~~~~~~~~~~~~~~ #
app = Client(
ACCOUNT,
phone_number=PHONE_NR,
api_id=API_ID,
api_hash=API_HASH
)
filters.chat(SOURCE_CHAT)
@app.on_message(filters.chat(SOURCE_CHAT))
def my_handler(client, message):
message.copy( # copy() so there's no "forwarded from" header
chat_id=TARGET_CHAT, # the channel you want to post to
caption="Copied from XYZ" # Caption
)
# UNCOMMENT THIS CODE TO FIND OUT CHAT ID OF THE PRIVATE GROUPS
#@app.on_message()
#def my_handler(client, message):
# print(message)
app.run()