|
12 | 12 | glomps = ["glomps", "tackles", "tackle hugs", "sexually glomps", "takes a flying leap and glomps", "bear hugs"] |
13 | 13 |
|
14 | 14 | usrcache = [] |
15 | | -#glob_chan = chan |
16 | 15 |
|
17 | | -#@hook.command(autohelp=False) |
| 16 | +@hook.command(autohelp=False) |
18 | 17 | def hookup(db, conn, chan): |
19 | 18 | """matches two users from the channel in a sultry scene.""" |
20 | 19 | 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: |
| 20 | + results = db.execute("select name from seen_user where chan = :chan and time > :time", {"chan": chan, "time": times}).fetchall() |
| 21 | + if not results or len(results) < 2: |
23 | 22 | 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 |
| 23 | + # Make sure the list of people is unique |
| 24 | + people = list(set(row[0] for row in results)) |
| 25 | + random.shuffle(people) |
| 26 | + person1, person2 = people[:2] |
30 | 27 | room = random.choice(rooms) |
31 | 28 | weapon = random.choice(weapons) |
32 | | - out = "{} used {} and did it with {} in the {}.".format(person1[0], weapon, person2[0], room) |
| 29 | + out = "{} used {} and did it with {} in the {}.".format(person1, weapon, person2, room) |
33 | 30 | return out |
34 | 31 |
|
35 | 32 | @hook.command(autohelp=False) |
|
0 commit comments