# -*- coding: utf-8 -*- from random import choice import json class StaticAnswers: """ collection of callable static/ semi-static strings """ def __init__(self): with open("./common/strings.json") as basefile: self.strings = json.load(basefile) self.helpfile = self.strings["help"] self.keywords = self.strings["functions"]["keywords"] self.replys = self.strings["functions"]["answers"] def keys(self, key=None): # if specific keyword in referenced return that if key in self.keywords: return self.keywords[key] # in any other case return the whole dict return self.keywords["all"] def help_doc(self, key=None): # if specific key is referenced return only that key if key is not None: return self.helpfile["help_advanced"][key] # in any other case return basic dict return self.helpfile["help_basic"] def answers(self, nick=None): # return pseudo random answer return choice(self.replys) % nick