def addCommand(ctx, command): validatePrivateContext(ctx) profileSet = getOrMakeProfileSet(ctx) obj, args = getObjAndArgs(command) if obj == "roll": name, dice = getObjAndArgs(args) profileSet.addRoll(name, dice) return "Added " + name + " as " + dice elif obj == "profile": profileSet.addProfile(args) return "Added a new profile named " + args else: return "You cannot add " + obj
def setCommand(name, command): profileSet = getOrMakeProfileSet(name) obj, args = getObjAndArgs(command) if obj == "profile": profileSet.setProfile(args) return args + " is now the active profile!" elif obj == "default": profileSet.setDefaultProfile(args) return args + " is now the default profile!" else: return "You cannot set " + obj
def setCommand(ctx, command): validatePrivateContext(ctx) profileSet = getOrMakeProfileSet(ctx) obj, args = getObjAndArgs(command) if obj == "profile": profileSet.setProfile(args) return args + " is now the active profile!" elif obj == "default": profileSet.setDefaultProfile(args) return args + " is now the default profile!" else: return "You cannot set " + obj
def addCommand(name, command): profileSet = getOrMakeProfileSet(name) obj, args = getObjAndArgs(command) if obj == "roll": opts = getArgsByOpts(["-n", "-r"], args) name = opts["-n"] dice = opts["-r"] profileSet.addRoll(name, dice) return "Added " + name + " as " + dice elif obj == "profile": profileSet.addProfile(args) return "Added a new profile named " + args else: return "You cannot add " + obj
def templateCommand(name, command): profileSet = getOrMakeProfileSet(name) obj, args = getObjAndArgs(command) if obj == "install": opts = getArgsByOpts(["-t", "-n", "-p"], args) profileSet.addAndSetProfile(opts["-n"]) template = Template(opts["-t"]) template.installToProfile(profileSet, opts["-p"]) return template.template["tips"] elif obj == "action": opts = getArgsByOpts(["-t", "-a", "-p"], args) template = Template(opts["-t"]) try: return [template.performAction(profileSet, opts["-a"], opts["-p"])] except Exception as err: return ["Cannot perform action " + opts["-a"] + ": " + str(err)] elif obj == "list": # opts = getArgsByOpts(["-t", "-p"], args) # template = Template( return ["This feature coming soon!"] elif obj == "detail": return ["This feature coming soon!"] else: return [f"You cannot {command} a template"]