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)