diff --git a/.bash_aliases b/.bash_aliases index 86ac393..50253c6 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -14,3 +14,4 @@ alias usenet='tin -r' alias units='~/Code/units/units-2.11/units -f ~/Code/units/units-2.11/definitions.units' alias beats_raw='echo "x = (`date +%s` + 3600) % 86400; scale=3; x / 86.4" | bc' alias beats='printf "@\e[0;36m`beats_raw`\e[m\n"' +alias pp='python -mjson.tool' diff --git a/Code/irc/banterbot.py b/Code/irc/banterbot.py index 0a2c091..1eeacc1 100755 --- a/Code/irc/banterbot.py +++ b/Code/irc/banterbot.py @@ -16,7 +16,9 @@ import mentions import pretty_date import inflect from rhymesWith import getRhymes -from defineWord import define +from rhymesWith import rhymeZone +from defineWord import defWord +from rainbow import makeRainbow parser = OptionParser() @@ -112,7 +114,7 @@ def get_rhymes(channel, user, text): else: with open("/home/nossidge/poems/words_poetic.txt", "r") as words: word = random.choice(words.readlines()).strip("\n") - rhymes = getRhymes(word) + rhymes = rhymeZone(word) if(len(rhymes) == 0): ircsock.send("PRIVMSG " + channel + " :" + user + ": Couldn't find anything that rhymes with '" + word + "' :(\n") else: @@ -122,15 +124,18 @@ def define_word(channel, user, text): word = "" if(len(text.split(' ')) > 1): word = text.split(' ')[1] - defs = define(word) + defs = defWord(word) if(len(defs) == 0): ircsock.send("PRIVMSG " + channel + " :" + user + ": Couldn't find the definition of '" + word + "' :(\n") else: ircsock.send("PRIVMSG " + channel + " :" + user + ": Define '" + word + "'" + ''.join(defs)[0:200] + "\n") +def make_rainbow(channel, user, text): + rbword = makeRainbow(text[9:]) + ircsock.send("PRIVMSG " + channel + " :" + rbword + "\n") def rollcall(channel): - ircsock.send("PRIVMSG "+ channel +" :U wot m8? I score all the top drawer #banter and #bantz on this channel! Find new top-shelf banter with !newbanter, !rhyme, and !define\n") + ircsock.send("PRIVMSG "+ channel +" :U wot m8? I score all the top drawer #banter and #bantz on this channel! Find new top-shelf banter with !newbanter, !rhymes, and !define. Make your chatter #legend with !rainbow\n") def connect(server, channel, botnick): ircsock.connect((server, 6667)) @@ -183,6 +188,9 @@ def listen(): if ircmsg.find(":!define") != -1: define_word(channel, user, messageText) + if ircmsg.find(":!rainbow") != -1: + make_rainbow(channel, user, messageText) + if ircmsg.find(":!rollcall") != -1: rollcall(channel) diff --git a/Code/irc/defineWord.py b/Code/irc/defineWord.py new file mode 100644 index 0000000..9adf8f2 --- /dev/null +++ b/Code/irc/defineWord.py @@ -0,0 +1,25 @@ +import urllib +from bs4 import BeautifulSoup +import random + +def define(word): + defs = [] + url = 'http://www.merriam-webster.com/dictionary/%s' % word + soup = BeautifulSoup(urllib.urlopen(url).read(), 'html.parser') + head = soup.find('div', id='headword') + if head: + for p in head.find_all('p'): + defs.append(p.text.encode('ascii', 'ignore')) + return defs + +key = open("/home/krowbar/.secret/key").readline().rstrip() + +def defWord(word): + defs = [] + url = 'http://www.dictionaryapi.com/api/v1/references/collegiate/xml/%s?key=%s' % (word, key) + soup = BeautifulSoup(urllib.urlopen(url).read(), 'html5lib') + entry = soup.find('entry') + if entry: + for d in entry.find_all('dt'): + defs.append(d.text.encode('ascii', 'ignore')) + return defs diff --git a/Code/irc/numberwangscores.txt b/Code/irc/numberwangscores.txt index 854825f..a4c1435 100644 --- a/Code/irc/numberwangscores.txt +++ b/Code/irc/numberwangscores.txt @@ -1,2 +1,4 @@ endorphant&^%68 -krowbar&^%60 +krowbar&^%119 +karlen&^%2 +jumblesal&^%37 diff --git a/Code/irc/puzzle.py b/Code/irc/puzzle.py new file mode 100644 index 0000000..8d931a6 --- /dev/null +++ b/Code/irc/puzzle.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +import random +import inflect + +p = inflect.engine() + +def make_puzzle(): + answer = 0 + puzzle = random.choice(["Prove you're not a robot: ", "Are you a robot?: ", "Anti-bot check: ", "Counter-cndorphant measures: "]) + puzzle += random.choice(["What is", "How many is", "What do you get from", "What do you get with", "What is the value of", "Can you answer", "Can you tell me"]) + puzzle += " " + roll = random.randrange(0,4) + var1 = random.randrange(1,10) + var2 = random.randrange(1,10) + + if roll == 0: + answer = var1 + var2 + puzzle += p.number_to_words(var1) + " " + random.choice(["and", "plus", "sum", "add"]) + " " + p.number_to_words(var2) + + elif roll == 1: + answer = var1 * var2 + puzzle += p.number_to_words(var1) + " " + random.choice(["times", "multiply", "multiplied by", "product"]) + " " + p.number_to_words(var2) + elif roll == 2: + if var2 > var1: + var1,var2 = var2,var1 + answer = var1 - var2 + puzzle += p.number_to_words(var1) + " " + random.choice(["minus", "subtract", "take away", "less"]) + " " + p.number_to_words(var2) + elif roll == 3: + if var2 > var1: + var1,var2 = var2,var1 + answer = var1 * 2 / var2 + puzzle += p.number_to_words(var1*2) + " " + random.choice(["divided by", "over"]) + " " + p.number_to_words(var2) + " (no remainder)" + elif roll == 4: + answer == var1 ** var2 + puzzle += p.number_to_words(var1) + " to the " + p.ordinal(p.number_to_words(var2)) + " power" + + puzzle += "? (Answer with numbers)" + return [answer, puzzle] diff --git a/Code/irc/rainbow.py b/Code/irc/rainbow.py new file mode 100644 index 0000000..ba0990a --- /dev/null +++ b/Code/irc/rainbow.py @@ -0,0 +1,18 @@ +import random + +def makeRainbow(word): + + word = word or "RAINBOW" + output = "" + rb = ["5","7","8","3","12","13","6"] + bg = "01" + idx = random.randrange(0, len(rb)) + + for l in word: + if l == " ": + output += ' ' + else: + output += "\x03" + rb[idx % len(rb)] + "," + bg + l + idx += 1 + + return output diff --git a/Code/irc/rhymesWith.py b/Code/irc/rhymesWith.py new file mode 100644 index 0000000..3fd584a --- /dev/null +++ b/Code/irc/rhymesWith.py @@ -0,0 +1,25 @@ +import urllib +#from lxml.html import fromstring +from bs4 import BeautifulSoup +import random + +def getRhymes(word): + words = [] + url = 'http://www.rhymer.com/RhymingDictionaryLast/%s.html' % word + soup = BeautifulSoup(urllib.urlopen(url).read(), 'html.parser') + + for t in soup.find_all('table', 'table'): + words.append(random.choice([w for w in t.text.split('\n') if w not in [u'', u'\xa0'] and '-' not in w])) + return words + +def rhymeZone(word): + words = [] + url = 'http://rhymezone.com/r/rhyme.cgi?Word=%s&typeofrhyme=perfect&org1=syl&org2=l&org3=y' % word + soup = BeautifulSoup(urllib.urlopen(url).read(), 'html.parser') + + for t in soup.find_all('a', 'd'): + w = t.text.rstrip() + if w not in [u'', u'\xa0'] and '?' not in t: + words.append(w) + random.shuffle(words) + return words[0:5] diff --git a/Code/irc/tildescores.txt b/Code/irc/tildescores.txt index d41c7e6..75e75e4 100644 --- a/Code/irc/tildescores.txt +++ b/Code/irc/tildescores.txt @@ -1,20 +1,20 @@ -krowbar&^%263&^%1448316671 -karlen&^%271&^%1426779321 +krowbar&^%292&^%1452094972 +karlen&^%272&^%1449500011 endorphant&^%682&^%1444775660 jumblesale&^%24&^%1426171214 -marcus&^%815&^%1446654919 +marcus&^%826&^%1452092376 papa&^%179&^%1438878499 epicmorphism&^%5&^%1421937744 audy&^%78&^%1442345315 kc&^%18&^%1422326056 vilmibm&^%9&^%1445468087 -cmr&^%1054&^%1447812299 +cmr&^%1074&^%1451719260 imt&^%519&^%1424087616 cndorphant&^%788&^%1424094192 rain&^%17&^%1422310975 sl2c&^%91&^%1424847521 selfsame&^%1&^%1422230012 -bear&^%213&^%1443668443 +bear&^%220&^%1452096373 coaxial&^%8&^%1422325983 joe&^%8&^%1422325983 hardmath123&^%4&^%1422325983 @@ -28,6 +28,8 @@ reppard&^%11&^%1437512059 jesse&^%6&^%1437569027 khoi&^%3&^%1438044039 sanqui&^%4&^%1438184911 -endorphan&^%52&^%1448373701 +endorphan&^%57&^%1450367628 cndorphbo&^%2&^%1447862524 santi&^%3&^%1447873216 +insom&^%1&^%1450346059 +tahnok&^%3&^%1450457276 diff --git a/Code/irc/topics_#bots.txt b/Code/irc/topics_#bots.txt index ab4e6f5..19eb8b1 100644 --- a/Code/irc/topics_#bots.txt +++ b/Code/irc/topics_#bots.txt @@ -17,3 +17,4 @@ 1443998393&^%cmr&^%http://tilde.town/~wiki/ircbots.html 1444203916&^%cmr&^%http://tilde.town/~wiki/ircbots.html | cndorphbot: 1447252215&^%krowbar&^%#bots, the last bastion of the free +1451487092&^%krowbar&^%Bots rule! Users drool! diff --git a/Code/irc/topics_#tildetown.txt b/Code/irc/topics_#tildetown.txt index 5f78c4a..7d587c7 100644 --- a/Code/irc/topics_#tildetown.txt +++ b/Code/irc/topics_#tildetown.txt @@ -125,3 +125,8 @@ 1447266389&^%vilmibm&^%let's talk about html + feels now 1447728949&^%vilmibm&^%which html color do you wish the sky was? 1448033496&^%krowbar&^%What is your favorite color tea? +1448660232&^%vilmibm&^%hugsgiving > thanksgiving +1449269868&^%vilmibm&^%is there ethical consumption under capitalism +1449698715&^%vilmibm&^%hack the planet (with feels) +1451971379&^%vilmibm&^%let's talk about html & feels | welcome new users! +1452017977&^%vilmibm&^%let's talk about html & feels! | add yrself to the map of townies! http://tilde.town/~bear/where.html diff --git a/Code/irc/topicscores.txt b/Code/irc/topicscores.txt index e5346ba..362e7a0 100644 --- a/Code/irc/topicscores.txt +++ b/Code/irc/topicscores.txt @@ -1,5 +1,5 @@ -krowbar&^%3&^%16 -vilmibm&^%0&^%14 +krowbar&^%7&^%17 +vilmibm&^%0&^%19 hardmath123&^%0&^%6 joe&^%1&^%1jumblesale audiodude&^%1&^%0 diff --git a/Code/irc/wangbot.py b/Code/irc/wangbot.py index 4f403ba..09f13be 100755 --- a/Code/irc/wangbot.py +++ b/Code/irc/wangbot.py @@ -30,7 +30,7 @@ parser.add_option("-n", "--nick", dest="nick", default='numberwang_bot', (options, args) = parser.parse_args() p = inflect.engine() -LIMIT_GUESSING = False +LIMIT_GUESSING = True MIN_ROUNDS = 5 MAX_ROUNDS = 12 SCORE_FILE = "numberwangscores.txt" diff --git a/Code/python/chatstats.py b/Code/python/chatstats.py new file mode 100644 index 0000000..b19e1d9 --- /dev/null +++ b/Code/python/chatstats.py @@ -0,0 +1,39 @@ +#!/usr/bin/python +import fileinput +import json +import time +import calendar +import shutil + +logfile = "/home/jumblesale/Code/irc/log" +outfile = "/home/krowbar/logs/chatStats.json" +userData = {} #hash keyed by "user" that contains a start timestamp, last timestamp, last said string, chat count, letter count, and word count + +with open(logfile, "r") as log: + for line in log: + try: + time, user, message = line.split("\t", 3) + time = int(time) + except ValueError: + continue #There are some bad lines in the log file that we'll ignore if we can't parse + if user in userData: + if userData[user]['startTime'] == 0: + userData[user]['startTime'] = time + userData[user]['endTime'] = time + #userData[user]['lastSaid'] = message + userData[user]['lineCount'] += 1 + userData[user]['wordCount'] += len(message.split()) + userData[user]['charCount'] += len(message) + else: #if they are new + userData[user] = {} + userData[user]['startTime'] = time + userData[user]['endTime'] = time + #userData[user]['lastSaid'] = message + userData[user]['lineCount'] = 1 + userData[user]['wordCount'] = len(message.split()) + userData[user]['charCount'] = len(message) + + +with open(outfile + ".tmp", "w") as tmpFile: + tmpFile.write(json.dumps(userData)) +shutil.move(outfile + ".tmp", outfile) diff --git a/public_html/chatchecker/index.html b/public_html/chatchecker/index.html new file mode 100644 index 0000000..181d822 --- /dev/null +++ b/public_html/chatchecker/index.html @@ -0,0 +1,45 @@ + + + +Who chats and when? + + + + + + + +
+ + diff --git a/public_html/chatchecker/todo b/public_html/chatchecker/todo new file mode 100644 index 0000000..f6892bf --- /dev/null +++ b/public_html/chatchecker/todo @@ -0,0 +1,26 @@ + +How do do stuff + +Data structure +users["name"] + .talked = array of irc times + .mentioned = array of irc times + + +DATA DAEMON +* Parse log for nicks that said something + - Populate data structure +* For each line, log the person who talked + - Check if any other person was mentioned + - Only log if it is at least 1 minute past their last chat/reference (maybe + to reduce data size) +* Write to log file + - Same file or dated one? + - Only certain time frames?? +* Run daily/hourly? + +PRESENTATION +* Select a user name from the drop down + - See a timeline with colored strands of when they spoke and were mentioned +* Something that looks like the Github commit history +* Use D3 for coolness diff --git a/public_html/chatstats/index.html b/public_html/chatstats/index.html new file mode 100644 index 0000000..310b1c7 --- /dev/null +++ b/public_html/chatstats/index.html @@ -0,0 +1,49 @@ + + + +IRC chat stats + + + + + + + +
+ + diff --git a/public_html/index.html b/public_html/index.html index 74db0cc..dcf63fa 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -6,9 +6,10 @@ Links and stuff

Tilde.town IRC Chat cloud

diff --git a/public_html/mission/js/mission.js b/public_html/mission/js/mission.js index eda06c6..4f6656a 100644 --- a/public_html/mission/js/mission.js +++ b/public_html/mission/js/mission.js @@ -7,24 +7,24 @@ var self = this; -var adjectives = Array('Bold','Breaking','Brilliant','Crescent','Dark|Darkness','Desert|Desert','Eternal','Evening|Darkness','Final','First','Forever','Glorious','Joyful','July','Last','Libery|Liberty','Magic|Magic','Morning|Morning','Power|Power','Phantom','Present','Roaring|Roar|Scream','Rolling','Sand','Screaming|Roar|Scream','Soaring','Standing|Stand','Star|Star','Twisted','Urgent','Utopian','Valiant'); +var adjectives = Array('Bold','Breaking','Brilliant','Crescent','Dark|Darkness','Desert|Desert','Eternal','Evening|Darkness','Final','First','Forever','Glorious','Joyful','July','Last','Liberty|Liberty','Magic|Magic','Morning|Morning','Power|Power','Phantom','Present','Roaring|Roar|Scream','Rolling','Sand','Screaming|Roar|Scream','Soaring','Standing|Stand','Star|Star','Twisted','Urgent','Utopian','Valiant'); var nouns = Array('Action','Alert','Beauty','Claw','Darkness','Dawn','Day','Desert','Envy','Fall','Fist','Flight','Fury','Guard','Hammer','Hand','Honor','Hope','Hurricane','Liberty','Light','Lightning','Magic','Morning','October','Power','Rain','Repose','Roar','Scream','Skull','Sky','Skies','Shield','Stand','Star','Storm','Streak','Strike','Sun','Thunder','Victory','Whisper','Wind','Wrath'); var colors = Array('Black','Blue','Brown','Gray','Green','Indego','Orange','Purple','Rainbow','Red','Scarlet','Silver','Violet','White','Yellow'); var actors = Array('Cobra','Condor','Dragon','Eagle','Guardian','Hawk','Hydra','Jackal','King','Knight','Lady','Lion','Scorpion','Spartan','Titan','Victor','Viking','Warrior'); var mission_grammars = Array( - {chance:30, grammar: 'adj1 + " " + noun1'}, - {chance:20, grammar: 'adj1 + " " + actor'}, - {chance:10, grammar: 'color + " " + noun1'}, - {chance:10, grammar: 'color + " " + actor'}, - {chance:10, grammar: 'actor +"\'s " + noun1'}, - {chance:10, grammar: 'noun1 + " of the " + noun2'}, - {chance:10, grammar: 'noun1 + " of the " + actor'}, - {chance:10, grammar: 'actor + " of the " + noun1'}, - {chance:10, grammar: 'noun1 + " of " + noun2'}, - {chance:10, grammar: 'noun1 + " of " + color + " " + noun2'}, - {chance:10, grammar: 'adj1 + " " + noun1 + " and " + adj2 + " " + noun2'}, - {chance:3, grammar: '"Attack of the " + actor + "s"'}, - {chance:3, grammar: '"Return of the " + actor + "s"'} + {chance:30, grammar: "{adj1} {noun1}"}, + {chance:20, grammar: "{adj1} {actor}"}, + {chance:10, grammar: "{color} {noun1}"}, + {chance:10, grammar: "{color} {actor}"}, + {chance:10, grammar: "{actor}'s {noun1}"}, + {chance:10, grammar: "{noun1} of the {noun2}"}, + {chance:10, grammar: "{noun1} of the {actor}"}, + {chance:10, grammar: "{actor} of the {noun1}"}, + {chance:10, grammar: "{noun1} of {noun2}"}, + {chance:10, grammar: "{noun1} of {color} {noun2}"}, + {chance:10, grammar: "{adj1} {noun1} and {adj2} {noun2}"}, + {chance:3, grammar: "Attack of the {actor}s"}, + {chance:3, grammar: "Return of the {actor}s"} ); this.getNoun = function(badNouns) { return _.chain(nouns) @@ -65,7 +65,13 @@ this.getMissionName = function() { rand -= g.chance; } else { - mission += eval(g.grammar); + mission += g.grammar + .replace(/{adj1}/, adj1) + .replace(/{adj2}/, adj2) + .replace(/{noun1}/, noun1) + .replace(/{noun2}/, noun2) + .replace(/{color}/, color) + .replace(/{actor}/, actor); return mission; } }