mirror of
https://github.com/RussellChamp/tilde-projects.git
synced 2026-10-28 00:22:34 +00:00
Ported banterbot to pinhook framework and some other changes
This commit is contained in:
1 parent
0627b4a9e3
commit
bc102890b2
39 files changed
+1629
-507
No files matched your search
@@ -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)]
|
||||
Reference in new issue
Block a user