forked from mahdibland/get_v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_link.py
32 lines (23 loc) · 886 Bytes
/
get_link.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
import sys
from telethon import TelegramClient
if __name__ == '__main__':
phone = sys.argv[1]
password = sys.argv[2]
api_id = sys.argv[3]
api_hash = sys.argv[4]
useProxy = sys.argv[5] if len(sys.argv) > 5 else None
proxy = None
if useProxy is not None and useProxy != "false":
print("useProxy is " + useProxy)
host = "127.0.0.1"
port = 1080
proxy = ("socks5", host, port)
print(proxy)
client = TelegramClient(phone, api_id, api_hash, proxy=proxy).start(phone=phone, password=password)
channel_username = 'kxswa'
async def dow():
dialog = await client.get_entity(channel_username)
async for msg in client.iter_messages(dialog, limit=1):
with open("订阅链接.txt", "w", encoding="utf8") as f:
f.write(msg.message)
client.loop.run_until_complete(dow())