예제 #1
0
def get_user_guilds():
    cache = get_keyvalproperty("OAUTH/USERGUILDS/"+str(make_user_cache_key()))
    if cache:
        return cache
    req = discordrest_from_user("/users/@me/guilds")
    if req.status_code != 200:
        abort(req.status_code)
    req = json.dumps(req.json())
    set_keyvalproperty("OAUTH/USERGUILDS/"+str(make_user_cache_key()), req, 250)
    return req
예제 #2
0
def bot_alive():
    results = {
        "status": False,
        "formatted_utc": "Never",
        "epoch_seconds": None
    }
    epoch = get_keyvalproperty("bot_heartbeat")
    if not epoch:
        return results
    epoch = float(epoch)
    utc = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(epoch))
    results["formatted_utc"] = utc
    results["epoch_seconds"] = epoch
    now = time.time()
    if now - epoch < 60 * 5:
        results["status"] = True
    return results
예제 #3
0
 def _get_bucket(self, key):
     value = get_keyvalproperty(self.global_redis_prefix + key)
     return value