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"})