Skip to content

Commit c7e5407

Browse files
committed
The slap command was using kills.json - also merge slaps into attacks
1 parent e2a0868 commit c7e5407

2 files changed

Lines changed: 26 additions & 36 deletions

File tree

plugins/attacks.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def load_attacks(bot):
1414
"""
1515
:type bot: cloudbot.bot.CloudBot
1616
"""
17-
global larts, insults, flirts, kills
17+
global larts, insults, flirts, kills, slaps
1818

1919
with codecs.open(os.path.join(bot.data_dir, "larts.txt"), encoding="utf-8") as f:
2020
larts = [line.strip() for line in f.readlines() if not line.startswith("//")]
@@ -25,6 +25,9 @@ def load_attacks(bot):
2525
with codecs.open(os.path.join(bot.data_dir, "kills.json"), encoding="utf-8") as f:
2626
kills = json.load(f)
2727

28+
with codecs.open(os.path.join(bot.data_dir, "slaps.json"), encoding="utf-8") as f:
29+
slaps = json.load(f)
30+
2831

2932
def is_self(conn, target):
3033
"""
@@ -104,3 +107,25 @@ def kill(text, conn, nick, notice, action):
104107

105108
# act out the message
106109
action(generator.generate_string())
110+
111+
112+
@hook.command
113+
def slap(text, action, nick, conn, notice):
114+
"""slap <user> -- Makes the bot slap <user>."""
115+
target = text.strip()
116+
117+
if " " in target:
118+
notice("Invalid username!")
119+
return
120+
121+
# if the user is trying to make the bot slap itself, slap them
122+
if target.lower() == conn.nick.lower() or target.lower() == "itself":
123+
target = nick
124+
125+
variables = {
126+
"user": target
127+
}
128+
generator = textgen.TextGenerator(slaps["templates"], slaps["parts"], variables=variables)
129+
130+
# act out the message
131+
action(generator.generate_string())

plugins/slap.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)