Skip to content

Commit 23bc00b

Browse files
committed
Move hookup data to hookup.json and switch to using the TextGenerator for consistency
1 parent cd3b30d commit 23bc00b

2 files changed

Lines changed: 71 additions & 7 deletions

File tree

data/hookup.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"templates": [
3+
"{user1} used {weapon} and did it with {user2} in the {room}."
4+
],
5+
"parts": {
6+
"weapon": [
7+
"a candlestick",
8+
"an axe",
9+
"a pistol",
10+
"rope",
11+
"gloves",
12+
"a horseshoe",
13+
"a knife",
14+
"a baseball bat",
15+
"a chalice",
16+
"a dumbbell",
17+
"a wrench",
18+
"a trophy",
19+
"a pipe",
20+
"garden shears"
21+
],
22+
"room": [
23+
"courtyard",
24+
"guest house",
25+
"observatory",
26+
"theatre",
27+
"drawing room",
28+
"garage",
29+
"spa",
30+
"master bedroom",
31+
"studio",
32+
"pool",
33+
"arcade",
34+
"beach house",
35+
"surf shop",
36+
"kitchen",
37+
"ballroom",
38+
"conservatory",
39+
"billiard room",
40+
"library",
41+
"study",
42+
"hallway",
43+
"lounge",
44+
"dining room",
45+
"cellar"
46+
]
47+
}
48+
}

plugins/hookup.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import codecs
2+
import json
13
import random
24
import time
35

6+
import os
7+
48
from cloudbot import hook
9+
from cloudbot.util.textgen import TextGenerator
510

6-
rooms = ["courtyard", "guest house", "observatory", "theatre", "drawing room", "garage", "spa", "master bedroom", "studio", "pool", "arcade", "beach house", "surf shop", "kitchen", "ballroom", "conservatory", "billiard room", "library", "study", "hallway", "lounge", "dining room", "cellar"]
7-
weapons = ["a candlestick","an axe", "a pistol", "rope", "gloves", "a horseshoe", "a knife", "a baseball bat", "a chalice", "a dumbbell", "a wrench", "a trophy", "a pipe", "garden shears"]
11+
hookups = {}
812

913
bitesyns = ["bites", "nips", "nibbles", "chomps", "licks", "teases", "chews", "gums", "tastes"]
1014
bodyparts = ["cheeks", "ear lobes", "nipples", "nose", "neck", "toes", "fingers", "butt", "taint", "thigh", "grundle", "tongue", "calf", "nurses", "nape"]
@@ -13,8 +17,16 @@
1317

1418
usrcache = []
1519

20+
21+
@hook.on_start
22+
def load_hookups(bot):
23+
hookups.clear()
24+
with codecs.open(os.path.join(bot.data_dir, "hookup.json"), encoding="utf-8") as f:
25+
hookups.update(json.load(f))
26+
27+
1628
@hook.command(autohelp=False)
17-
def hookup(db, conn, chan):
29+
def hookup(db, chan):
1830
"""matches two users from the channel in a sultry scene."""
1931
times = time.time() - 86400
2032
results = db.execute("select name from seen_user where chan = :chan and time > :time", {"chan": chan, "time": times}).fetchall()
@@ -24,10 +36,13 @@ def hookup(db, conn, chan):
2436
people = list(set(row[0] for row in results))
2537
random.shuffle(people)
2638
person1, person2 = people[:2]
27-
room = random.choice(rooms)
28-
weapon = random.choice(weapons)
29-
out = "{} used {} and did it with {} in the {}.".format(person1, weapon, person2, room)
30-
return out
39+
variables = {
40+
'user1': person1,
41+
'user2': person2,
42+
}
43+
generator = TextGenerator(hookups['templates'], hookups['parts'], variables=variables)
44+
return generator.generate_string()
45+
3146

3247
@hook.command(autohelp=False)
3348
def bite(text, chan, action):
@@ -40,6 +55,7 @@ def bite(text, chan, action):
4055
out = "{} {}'s {}.".format(bite, name, body)
4156
action(out, chan)
4257

58+
4359
@hook.command(autohelp=False)
4460
def glomp(text, chan, action):
4561
"""glomps the specified nick."""

0 commit comments

Comments
 (0)