tambah ket. env di readme dan hapus beberapa kode yang tidak dipakai
This commit is contained in:
parent
6c61141afc
commit
8de74a7ba5
2 changed files with 14 additions and 12 deletions
|
@ -28,3 +28,10 @@ $ pip install -r requirements.txt
|
|||
```
|
||||
|
||||
Awas, silakan edit dulu isi file requirements.txt karena isinya banyak module yang tak terpakai, ane belum sempat hapus 1 per 1.
|
||||
|
||||
### .env
|
||||
Saat ini ada 4 environment variable yaitu:
|
||||
1. GTS_API : untuk URL API dari instance gotosocial
|
||||
2. GTS_TOKEN : Token dengan scope minimal "Read" untuk akses API gotosocial
|
||||
3. TELE_BOT : Token Bot Telegram, hubungi Bot Father untuk minta
|
||||
4. TELE_CHATID : Chat Id dari channel telegram.
|
||||
|
|
19
main.py
19
main.py
|
@ -26,7 +26,7 @@ TELE_BOT = os.getenv('TELE_BOT')
|
|||
TELE_CHATID = os.getenv('TELE_CHATID')
|
||||
bot = telegram.Bot(token=f'{TELE_BOT}')
|
||||
|
||||
def getNotif():
|
||||
async def getNotif():
|
||||
req = requests.get(f'{gts_api}?limit=5', headers=headers)
|
||||
|
||||
if req.status_code == 200:
|
||||
|
@ -67,16 +67,12 @@ async def kirim_ke_tele():
|
|||
|
||||
|
||||
for notif in cek_data:
|
||||
body = {
|
||||
'text': 'text',
|
||||
'chat_id': {str(TELE_CHATID)},
|
||||
'parse_mode': 'markdown',
|
||||
'text': f"{notif.post_id} : {notif.handler}"
|
||||
}
|
||||
|
||||
if str(notif.type) == 'Follow':
|
||||
if str(notif.type) == 'follow':
|
||||
try:
|
||||
req = requests.post(f"https://api.telegram.org/bot{TELE_BOT}/sendMessage", headers=headers, data="fuck")
|
||||
await bot.send_message(parse_mode='html',chat_id=str(TELE_CHATID), text=f"""
|
||||
<b>{notif.display_name}</b>\n<i>{notif.handler}</i>\n{flag}
|
||||
"""
|
||||
)
|
||||
except:
|
||||
print('Ada masalah saat kirim ke Telebot')
|
||||
else:
|
||||
|
@ -103,11 +99,10 @@ async def kirim_ke_tele():
|
|||
<b>{notif.display_name}</b>\n<i>{notif.handler}</i>\n{flag}\n\n{status_text}\n\n{notif.url}
|
||||
"""
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
print(f'Ada masalah saat kirim ke Telebot1', e)
|
||||
|
||||
|
||||
|
||||
# getNotif()
|
||||
asyncio.run(getNotif())
|
||||
asyncio.run(kirim_ke_tele())
|
||||
|
|
Loading…
Reference in a new issue