[WIP] #21:2

This commit is contained in:
REDNBLACK 2016-11-30 22:27:58 +03:00
parent 1fc0c31bf4
commit af916a0f09
1 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,16 @@
from src.config import config
class ChanceManager:
def __init__(self, redis):
self.redis = redis
self.key = "chance:{}"
self.default_chance = config['bot']['default_chance']
def get_chance(self, chat_id):
result = self.redis.instance().get(self.key.format(chat_id))
return result if result is not None else self.default_chance
def set_chance(self, chat_id, chance):
self.redis.instance.set(self.key.format(chat_id), chance)