Skip to content

Commit 0bd42f8

Browse files
committed
Move bite data to json file
1 parent 285cace commit 0bd42f8

2 files changed

Lines changed: 43 additions & 10 deletions

File tree

data/bite.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"templates": [
3+
"{action} {user}'s {bodypart}"
4+
],
5+
"parts": {
6+
"action": [
7+
"bites",
8+
"nips",
9+
"nibbles",
10+
"chomps",
11+
"licks",
12+
"teases",
13+
"chews",
14+
"gums",
15+
"tastes"
16+
],
17+
"bodypart": [
18+
"cheeks",
19+
"ear lobes",
20+
"nipples",
21+
"nose",
22+
"neck",
23+
"toes",
24+
"fingers",
25+
"butt",
26+
"taint",
27+
"thigh",
28+
"grundle",
29+
"tongue",
30+
"calf",
31+
"nurses",
32+
"nape"
33+
]
34+
}
35+
}

plugins/hookup.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
import codecs
22
import json
3+
import os
34
import random
45
import time
56

6-
import os
7-
87
from cloudbot import hook
98
from cloudbot.util.textgen import TextGenerator
109

1110
hookups = {}
12-
13-
bitesyns = ["bites", "nips", "nibbles", "chomps", "licks", "teases", "chews", "gums", "tastes"]
14-
bodyparts = ["cheeks", "ear lobes", "nipples", "nose", "neck", "toes", "fingers", "butt", "taint", "thigh", "grundle", "tongue", "calf", "nurses", "nape"]
15-
11+
bites = {}
1612
glomps = []
1713

1814

1915
@hook.on_start
2016
def load_data(bot):
2117
hookups.clear()
2218
glomps.clear()
19+
bites.clear()
2320

2421
with codecs.open(os.path.join(bot.data_dir, "hookup.json"), encoding="utf-8") as f:
2522
hookups.update(json.load(f))
@@ -28,6 +25,9 @@ def load_data(bot):
2825
lines = (line.strip() for line in f if not line.startswith("//"))
2926
glomps.extend(filter(None, lines))
3027

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

3232
@hook.command(autohelp=False)
3333
def hookup(db, chan):
@@ -54,10 +54,8 @@ def bite(text, chan, action):
5454
if not text:
5555
return "please tell me who to bite."
5656
name = text.split(' ')[0]
57-
bite = random.choice(bitesyns)
58-
body = random.choice(bodyparts)
59-
out = "{} {}'s {}.".format(bite, name, body)
60-
action(out, chan)
57+
generator = TextGenerator(bites['templates'], bites['parts'], variables={'user': name})
58+
action(generator.generate_string(), chan)
6159

6260

6361
@hook.command(autohelp=False)

0 commit comments

Comments
 (0)