certalert-bot/notifications_consumer.py
2020-04-22 01:36:22 +02:00

13 lines
410 B
Python
Executable File

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