|
| 1 | +import codecs |
| 2 | +import json |
| 3 | +import os |
1 | 4 | import random |
2 | 5 | import time |
3 | 6 |
|
4 | 7 | from cloudbot import hook |
| 8 | +from cloudbot.util.textgen import TextGenerator |
5 | 9 |
|
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"] |
| 10 | +hookups = {} |
| 11 | +bites = {} |
| 12 | +glomps = [] |
8 | 13 |
|
9 | | -bitesyns = ["bites", "nips", "nibbles", "chomps", "licks", "teases", "chews", "gums", "tastes"] |
10 | | -bodyparts = ["cheeks", "ear lobes", "nipples", "nose", "neck", "toes", "fingers", "butt", "taint", "thigh", "grundle", "tongue", "calf", "nurses", "nape"] |
11 | 14 |
|
12 | | -glomps = ["glomps", "tackles", "tackle hugs", "sexually glomps", "takes a flying leap and glomps", "bear hugs"] |
| 15 | +@hook.on_start |
| 16 | +def load_data(bot): |
| 17 | + hookups.clear() |
| 18 | + glomps.clear() |
| 19 | + bites.clear() |
13 | 20 |
|
14 | | -usrcache = [] |
15 | | -#glob_chan = chan |
| 21 | + with codecs.open(os.path.join(bot.data_dir, "hookup.json"), encoding="utf-8") as f: |
| 22 | + hookups.update(json.load(f)) |
16 | 23 |
|
17 | | -#@hook.command(autohelp=False) |
18 | | -def hookup(db, conn, chan): |
| 24 | + with codecs.open(os.path.join(bot.data_dir, "glomp.txt"), encoding="utf-8") as f: |
| 25 | + lines = (line.strip() for line in f if not line.startswith("//")) |
| 26 | + glomps.extend(filter(None, lines)) |
| 27 | + |
| 28 | + with codecs.open(os.path.join(bot.data_dir, "bite.json"), encoding="utf-8") as f: |
| 29 | + bites.update(json.load(f)) |
| 30 | + |
| 31 | + |
| 32 | +@hook.command(autohelp=False) |
| 33 | +def hookup(db, chan): |
19 | 34 | """matches two users from the channel in a sultry scene.""" |
20 | 35 | times = time.time() - 86400 |
21 | | - people = db.execute("select name from seen_user where chan = :chan and time > :time", {"chan": chan, "time": times}).fetchall() |
22 | | - if not people: |
| 36 | + results = db.execute("select name from seen_user where chan = :chan and time > :time", {"chan": chan, "time": times}).fetchall() |
| 37 | + if not results or len(results) < 2: |
23 | 38 | return "something went wrong" |
24 | | - person1 = people[random.randint(0,len(people) - 1)] |
25 | | - person2 = people[random.randint(0,len(people) - 1)] |
26 | | - loop = 0 |
27 | | - while person1 == person2 or loop < 5: |
28 | | - person2 = people[random.randint(0, len(people) -1 )] |
29 | | - loop = loop + 2 |
30 | | - room = random.choice(rooms) |
31 | | - weapon = random.choice(weapons) |
32 | | - out = "{} used {} and did it with {} in the {}.".format(person1[0], weapon, person2[0], room) |
33 | | - return out |
| 39 | + # Make sure the list of people is unique |
| 40 | + people = list(set(row[0] for row in results)) |
| 41 | + random.shuffle(people) |
| 42 | + person1, person2 = people[:2] |
| 43 | + variables = { |
| 44 | + 'user1': person1, |
| 45 | + 'user2': person2, |
| 46 | + } |
| 47 | + generator = TextGenerator(hookups['templates'], hookups['parts'], variables=variables) |
| 48 | + return generator.generate_string() |
| 49 | + |
34 | 50 |
|
35 | 51 | @hook.command(autohelp=False) |
36 | 52 | def bite(text, chan, action): |
37 | 53 | """bites the specified nick somewhere random.""" |
38 | 54 | if not text: |
39 | 55 | return "please tell me who to bite." |
40 | 56 | name = text.split(' ')[0] |
41 | | - bite = random.choice(bitesyns) |
42 | | - body = random.choice(bodyparts) |
43 | | - out = "{} {}'s {}.".format(bite, name, body) |
44 | | - action(out, chan) |
| 57 | + generator = TextGenerator(bites['templates'], bites['parts'], variables={'user': name}) |
| 58 | + action(generator.generate_string(), chan) |
| 59 | + |
45 | 60 |
|
46 | 61 | @hook.command(autohelp=False) |
47 | 62 | def glomp(text, chan, action): |
|
0 commit comments