return True else: return False def __getitem__(self, lookfor): """Overides Dictionary __getitem__ to use fuzzy matching""" matched, key, item, ratio = self._search(lookfor) if not matched: raise KeyError("'%s'. closest match: '%s' with ratio %.3f" % (str(lookfor), str(key), ratio)) return item WorkingWithFiles.checkExistsPath("data/local_faq/") def FindTheWord(LocalData, GlobalData, word): try: answer = LocalData[word] return answer except: pass try: answer = GlobalData[word] return answer except: pass
enableTokens = True staticTokens = int( 999999999999 ) # Change this to the ammount of tokens everybody will have if enableTokens is False from cloudbot import hook if enableTokens: from cloudbot.util import WorkingWithFiles default = """{ "tokens": 0 }""" if enableTokens: WorkingWithFiles.checkExistsPath("data/usedata/") def getTokens(nick): if enableTokens: data = WorkingWithFiles.JSONloadFromDisk( 'data/usedata/' + nick + '.json', default) # Get data from file tokens = int(data.get("tokens", default)) # Extract tokens of a player return tokens else: return staticTokens def giveTokens(NumberOftokens, nick): if enableTokens: tokens = getTokens(nick)
""" enableTokens = True staticTokens = int(999999999999) # Change this to the ammount of tokens everybody will have if enableTokens is False from cloudbot import hook if enableTokens: from cloudbot.util import WorkingWithFiles default = """{ "tokens": 0 }""" if enableTokens: WorkingWithFiles.checkExistsPath("data/usedata/") def getTokens(nick): if enableTokens: data = WorkingWithFiles.JSONloadFromDisk('data/usedata/' + nick + '.json', default) # Get data from file tokens = int(data.get("tokens", default)) # Extract tokens of a player return tokens else: return staticTokens def giveTokens(NumberOftokens, nick): if enableTokens: tokens = getTokens(nick) tokens += NumberOftokens
else: return False def __getitem__(self, lookfor): """Overides Dictionary __getitem__ to use fuzzy matching""" matched, key, item, ratio = self._search(lookfor) if not matched: raise KeyError( "'%s'. closest match: '%s' with ratio %.3f" % (str(lookfor), str(key), ratio)) return item WorkingWithFiles.checkExistsPath("data/local_faq/") def FindTheWord(LocalData, GlobalData, word): try: answer = LocalData[word] return answer except: pass try: answer = GlobalData[word] return answer except: pass