mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-24 14:07:03 +01:00
Attempt to fix limiting
This commit is contained in:
parent
517e6f4ced
commit
3df40af71a
@ -114,7 +114,7 @@ def format_post_content(message):
|
||||
message = "**<{}#{}>** {}".format(session['username'], session['discriminator'], message) # I would like to do a @ mention, but i am worried about notif spam
|
||||
return message
|
||||
|
||||
@cache.cache(make_guildchannels_cache_key, expires=60)
|
||||
@cache.cache(make_guildchannels_cache_key, expire=60)
|
||||
def get_guild_channels(guild_id):
|
||||
if user_unauthenticated():
|
||||
member_roles = [guild_id] #equivilant to @everyone role
|
||||
|
@ -1,6 +1,7 @@
|
||||
import urlparse
|
||||
from limits.storage import Storage
|
||||
from redislite import Redis
|
||||
import time
|
||||
|
||||
class LimitsRedisLite(Storage): # For Python Limits
|
||||
STORAGE_SCHEME = "redislite"
|
||||
@ -14,12 +15,18 @@ class LimitsRedisLite(Storage): # For Python Limits
|
||||
return self.redis_instance.ttl(key)
|
||||
|
||||
def incr(self, key, expiry, elastic_expiry=False):
|
||||
if self.redis_instance.exists(key):
|
||||
self.redis_instance.set(key, int(self.redis_instance.get(key))+1)
|
||||
else:
|
||||
if not self.redis_instance.exists(key):
|
||||
self.redis_instance.set(key, 1)
|
||||
self.redis_instance.expire(key, expiry)
|
||||
self.redis_instance.expireat(key, int(time.time() + expiry))
|
||||
else:
|
||||
oldexp = self.get_expiry(key)
|
||||
self.redis_instance.set(key, int(self.redis_instance.get(key))+1)
|
||||
self.redis_instance.expireat(key, int(time.time() + oldexp))
|
||||
return
|
||||
|
||||
def get(self, key):
|
||||
print key + " " + str(int(self.redis_instance.get(key))) + " " + str(self.get_expiry(key))
|
||||
return int(self.redis_instance.get(key))
|
||||
|
||||
def reset(self):
|
||||
return self.redis_instance.flushdb()
|
||||
|
Loading…
Reference in New Issue
Block a user