certalert-bot/notifications_consumer.py
2020-05-13 11:53:58 +02:00

15 lines
457 B
Python
Executable File

import redis
import json
import os
import requests
r = redis.Redis()
token = os.environ.get('TOKEN')
print(token)
while True:
notification = json.loads(r.blpop('notifications')[1].decode('utf-8'))
print(notification)
res = requests.get("https://api.telegram.org/bot{}/sendMessage".format(token), params={"chat_id": notification["chat"], "text": "New cert for *{}*".format(notification["domain"]), "parse_mode": "Markdown"})
print(res.text)