-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
37 lines (33 loc) · 1.29 KB
/
main.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
from pyrogram import Client
from pyrogram.errors import BadRequest
from asyncio import *
from functions import *
from constants import API_ID, API_HASH, INITIAL_BIO
db = get_db()
app = Client("spotifytgbio", API_ID, API_HASH, no_updates=True)
async def worker(app):
me = await app.get_me()
while True:
current_bio = (await app.get_chat(me.id)).bio
scp = get_current_playing()
if scp and "is_playing" in scp:
if scp["is_playing"] == True:
artist = scp["item"]["artists"][0]["name"]
song = scp["item"]["name"]
bio = u"\U0001F3B5" + f" {artist} - {song}"
bio = bio if len(bio) <= 70 else INITIAL_BIO
if bio != current_bio:
await app.update_profile(bio=bio)
print(f"[LOG] Updated bio to {bio}")
else:
if current_bio != INITIAL_BIO:
await app.update_profile(bio=INITIAL_BIO)
print(f"[LOG] Updated bio to {INITIAL_BIO}")
else:
if current_bio != INITIAL_BIO:
await app.update_profile(bio=INITIAL_BIO)
print(f"[LOG] Updated bio to {INITIAL_BIO}")
await sleep(5)
app.start()
get_event_loop().run_until_complete(worker(app))
idle()