diff --git a/Code/irc/dict_puzzle.py b/Code/irc/dict_puzzle.py new file mode 100644 index 0000000..1814c21 --- /dev/null +++ b/Code/irc/dict_puzzle.py @@ -0,0 +1,15 @@ +#!/usr/bin/python +import random +import inflect + +p = inflect.engine() +dictionary = "/usr/share/dict/american-english-small" + +def get_puzzle(): + dict_words = [word.rstrip() for word in open(dictionary).readlines() if "'" not in word] + words = random.sample(dict_words, 3) + key = random.randrange(0,3) #get values 1-3 + puzzle = "When alphebetized, what is the " + p.ordinal(p.number_to_words(key+1)) + " in " + ", ".join(words) + words.sort() + answer = words[key] + return [answer, puzzle] diff --git a/Code/irc/names.py b/Code/irc/names.py new file mode 100644 index 0000000..bb4a109 --- /dev/null +++ b/Code/irc/names.py @@ -0,0 +1,15 @@ +#!/usr/bin/python +import json + +names_file='/home/jumblesale/Code/canonical_names/canonical_names.json' + +def get_name(name): + try: + with open(names_file) as names_data: + names = json.load(names_data) + try: + return names[name]["userName"] + except KeyError: + return name + except IOError: + return name # if we didn't already diff --git a/Code/irc/quote_puzzle.py b/Code/irc/quote_puzzle.py new file mode 100644 index 0000000..e3acda2 --- /dev/null +++ b/Code/irc/quote_puzzle.py @@ -0,0 +1,12 @@ +import random +import re + +quotefile = "/home/karlen/irc/quotes.txt" + +def get_quote(): + quotes = open(quotefile, "r").read().split("---") + quote,attr = random.choice(quotes).strip().splitlines() + quote = quote[:200] #get only the first 200 chars + word = random.choice([q for q in quote.split(' ') if len(q) > 1]) + quote = quote.replace(word, re.sub(r"[a-zA-Z]", "_", word)) + return [word, "Fill in the blank: \"" + quote + "\" " + attr] diff --git a/Code/irc/tildescores.txt b/Code/irc/tildescores.txt index afb3b9b..8a86dc6 100644 --- a/Code/irc/tildescores.txt +++ b/Code/irc/tildescores.txt @@ -1,5 +1,5 @@ krowbar&^%2023&^%1519851803 -karlen&^%305&^%1519847264 +karlen&^%306&^%1519852204 endorphant&^%682&^%1444775660 jumblesale&^%24&^%1426171214 marcus&^%2516&^%1519843226