Ported banterbot to pinhook framework and some other changes

This commit is contained in:
RussellChamp committed 2019-01-25 11:16:19 -05:00
1 parent 0627b4a9e3
commit bc102890b2
39 files changed
+1629 -507

No files matched your search

+15 -1
View File
@@ -1,8 +1,13 @@
#!/usr/bin/python
import json
import urllib
import random
import re
quotefile = "/home/karlen/irc/quotes.txt"
chuckfile = "chuck.txt"
chuckApi = "https://api.icndb.com/jokes/random"
def get_quote():
quotes = open(quotefile, "r").read().split("---")
@@ -11,3 +16,12 @@ def get_quote():
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]
def get_chuck():
#chucks = open(chuckfile, "r").readlines()
#chuck = random.choice(chucks).rstrip()[:200] # get only the first 200 chars
# ha ha! let's see if we can confus login
chuck = json.loads(urllib.urlopen(chuckApi).read().decode())['value']['joke'][:200]
word = random.choice([w for w in chuck.split(" ") if len(w) > 1 and w.lower() != "chuck" and w.lower() != "norris"])
chuck = chuck.replace(word, re.sub(r"[a-zA-Z]", "_", word)).replace(""", "\"")
return [word, 'Fill in the blank: "{}"'.format(chuck)]