randydev commited on
Commit
26c910c
·
verified ·
1 Parent(s): f154ce2

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +11 -0
main.py CHANGED
@@ -17,6 +17,17 @@ client = js.create_pyrogram(
17
  bot_token=BOT_TOKEN
18
  )
19
 
 
 
 
 
 
 
 
 
 
 
 
20
  @fast_app.on_event("startup")
21
  async def startup_event():
22
  user = await client.start()
 
17
  bot_token=BOT_TOKEN
18
  )
19
 
20
+ def get_random_from_channel(link):
21
+ clean_link = link.split("?")[0]
22
+ target_link = clean_link.split("/c/") if "/c/" in clean_link else clean_link.split("/")
23
+ random_id = int(target_link[-1].split("/")[-1]) if len(target_link) > 1 else None
24
+ desired_username = target_link[3] if len(target_link) > 3 else None
25
+ username = (
26
+ "@" + desired_username if desired_username else "-100" + target_link[1].split("/")[0]
27
+ if len(target_link) > 1 else None
28
+ )
29
+ return username, random_id
30
+
31
  @fast_app.on_event("startup")
32
  async def startup_event():
33
  user = await client.start()