Files
tilde-projects/Code/irc/quote_puzzle.py
T

13 lines
455 B
Python
Raw Normal View History

2018-02-28 21:11:39 +00:00
import random
import re
quotefile = "/home/karlen/irc/quotes.txt"
2018-10-05 16:02:38 -04:00
2018-02-28 21:11:39 +00:00
def get_quote():
quotes = open(quotefile, "r").read().split("---")
2018-10-05 16:02:38 -04:00
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])
2018-02-28 21:11:39 +00:00
quote = quote.replace(word, re.sub(r"[a-zA-Z]", "_", word))
2018-10-05 16:02:38 -04:00
return [word, 'Fill in the blank: "' + quote + '" ' + attr]