def pizza(text, action): """<user> - give pizza to <user>""" user = text.strip() if not is_valid(user): return "I can't give pizza to that user." generator = textgen.TextGenerator(pizza_data["templates"], pizza_data["parts"], variables={"user": user}) # act out the message action(generator.generate_string())
def doobie(text, action): """<user> - pass the doobie to <user>""" user = text.strip() if not is_valid(user): return "I can't pass the doobie to that user." generator = textgen.TextGenerator(doobie_data["templates"], doobie_data["parts"], variables={"user": user}) # act out the message action(generator.generate_string())
def kill(text, conn, nick, action): """<user> - kills <user>""" target = text.strip() if not is_valid(target): return "I can't attack that." if is_self(conn, target): # user is trying to make the bot attack itself! target = nick generator = textgen.TextGenerator(kills["templates"], kills["parts"], variables={"user": target}) # act out the message action(generator.generate_string())
def dhokla(text, conn, nick, notice, action): """<user> - give a tasty dhokla to <user> :type text: str :type conn: cloudbot.client.Client :type nick: str """ target = text.strip() if " " in target: notice("Invalid username!") return generator = textgen.TextGenerator(dhokla_data["templates"], dhokla_data["parts"], variables={"user": target}) # act out the message action(generator.generate_string())
def present(text, conn, nick, action): """<user> - gives gift to <user>""" target = text.strip() if not is_valid(target): return "I can't gift that." if is_self(conn, target): #user is trying to make the bot gift itself! target = nick variables = {"user": target} generator = textgen.TextGenerator(presents["templates"], presents["parts"], variables=variables) action(generator.generate_string())
def slap(text, action, nick, conn, notice): """<user> -- Makes the bot slap <user>.""" target = text.strip() if not is_valid(target): return "I can't attack that." if is_self(conn, target): # user is trying to make the bot attack itself! target = nick variables = {"user": target} generator = textgen.TextGenerator(slaps["templates"], slaps["parts"], variables=variables) # act out the message action(generator.generate_string())
def basic_format(nick, text, data, **kwargs): user = text kwargs['user'] = user kwargs['target'] = user kwargs['nick'] = nick if text: try: templates = data["target_templates"] except KeyError: templates = data["templates"] else: templates = data["templates"] generator = textgen.TextGenerator(templates, data.get("parts", {}), variables=kwargs) return generator.generate_string()
def slap(text, action, nick, conn, notice): """slap <user> -- Makes the bot slap <user>.""" target = text.strip() if " " in target: notice("Invalid username!") return # if the user is trying to make the bot slap itself, slap them if target.lower() == conn.nick.lower() or target.lower() == "itself": target = nick variables = {"user": target} generator = textgen.TextGenerator(slaps["templates"], slaps["parts"], variables=variables) # act out the message action(generator.generate_string())
def kill(text, conn, nick, notice, action): """<user> - kills <user> :type text: str :type conn: cloudbot.client.Client :type nick: str """ target = text.strip() if " " in target: notice("Invalid username!") return # if the user is trying to make the bot kill itself, kill them if is_self(conn, target): target = nick generator = textgen.TextGenerator(kills["templates"], kills["parts"], variables={"user": target}) # act out the message action(generator.generate_string())
def get_generator(_json): data = json.loads(_json) return textgen.TextGenerator(data["templates"], data["parts"], default_templates=data["default_templates"])
def get_generator(_json, variables): data = json.loads(_json) return textgen.TextGenerator(data["templates"], data["parts"], variables=variables)
def clinton(text, action): """clinton a user.""" user = text.strip() generator = textgen.TextGenerator(clinton_data["templates"], clinton_data["parts"], variables={"user": user}) action(generator.generate_string())
def trump(text, action): """trump a user.""" user = text.strip() generator = textgen.TextGenerator(trump_data["templates"], trump_data["parts"], variables={"user": user}) action(generator.generate_string())