Random update of various things
This commit is contained in:
parent
d76dd9c674
commit
57485f6ffd
|
@ -15,3 +15,6 @@ alias units='~/Code/units/units-2.11/units -f ~/Code/units/units-2.11/definition
|
|||
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'
|
||||
alias ttbp='~endorphant/bin/ttbp'
|
||||
alias vuln='find /home/ \! -type l -perm -o=w 2> /dev/null'
|
||||
alias vulnc='vuln | sed "s/\/home\/\([^/]*\)\/.*/\1/g" | sort | uniq -c | sort -nr'
|
||||
|
|
13
.bashrc
13
.bashrc
|
@ -102,5 +102,16 @@ fi
|
|||
PERL_MB_OPT="--install_base \"/home/krowbar/perl5\""; export PERL_MB_OPT;
|
||||
PERL_MM_OPT="INSTALL_BASE=/home/krowbar/perl5"; export PERL_MM_OPT;
|
||||
|
||||
export TZ=EST
|
||||
export TZ=EDT
|
||||
export PS1='$(beats):'$PS1
|
||||
|
||||
man() {
|
||||
env \
|
||||
LESS_TERMCAP_md=$'\e[1;36m' \
|
||||
LESS_TERMCAP_me=$'\e[0m' \
|
||||
LESS_TERMCAP_se=$'\e[0m' \
|
||||
LESS_TERMCAP_so=$'\e[1;40;92m' \
|
||||
LESS_TERMCAP_ue=$'\e[0m' \
|
||||
LESS_TERMCAP_us=$'\e[1;32m' \
|
||||
man "$@"
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import urllib
|
||||
from bs4 import BeautifulSoup
|
||||
import random
|
||||
import string
|
||||
|
||||
|
||||
dict = '/usr/share/dict/american-english-huge'
|
||||
(userId,token) = open("/home/krowbar/.secret/s4token").readline().rstrip().split(',')
|
||||
|
||||
def get_acros(word):
|
||||
def get_acros(word, silly):
|
||||
acros = []
|
||||
url = "http://www.stands4.com/services/v2/abbr.php?uid=%s&tokenid=%s&term=%s" % (userId, token, word)
|
||||
soup = BeautifulSoup(urllib.urlopen(url).read(), 'html5lib')
|
||||
|
@ -14,7 +15,7 @@ def get_acros(word):
|
|||
defs = []
|
||||
for r in results:
|
||||
rdef = r.find('definition').text
|
||||
match = next((x for x in defs if x['definition'] == rdef), None)
|
||||
match = next((x for x in defs if x['definition'].lower() == rdef.lower()), None)
|
||||
if match is not None:
|
||||
#if we find a match, add the category to the existing categories and increase the score
|
||||
match['categories'].append(((r.find('parentcategoryname').text + '\\') if r.find('parentcategoryname') else '') + r.find('categoryname').text)
|
||||
|
@ -32,4 +33,21 @@ def get_acros(word):
|
|||
acros.append(("%s: \"%s\" (%s, score: %s)" % \
|
||||
(d['term'], d['definition'], ', '.join(d['categories']), d['score'])\
|
||||
).encode('ascii', 'ignore'))
|
||||
if silly is True:
|
||||
newDef = []
|
||||
words = open(dict, 'r').readlines()
|
||||
try:
|
||||
for idx,letter in enumerate(word):
|
||||
newWord = random.choice(\
|
||||
filter(lambda w: (idx is 0 or not w.strip().lower().endswith('\'s'))\
|
||||
and w.lower().startswith(letter.lower()), words)\
|
||||
).strip()
|
||||
print str(idx) + ' -> ' + newWord
|
||||
newDef.append(newWord)
|
||||
acros.append(("%s: \"%s\" (%s, score: %s)" % \
|
||||
(word.upper(), string.capwords(' '.join(newDef)), 'Tilde.town Original', '0')\
|
||||
).encode('ascii', 'ignore'))
|
||||
except IndexError:
|
||||
acros.append("Future hazy, try again later: Tilde.town Error");
|
||||
|
||||
return acros
|
||||
|
|
|
@ -10,6 +10,8 @@ import fileinput
|
|||
import random
|
||||
import re
|
||||
import subprocess
|
||||
import time
|
||||
import datetime
|
||||
|
||||
import formatter
|
||||
import get_users
|
||||
|
@ -26,6 +28,7 @@ import tumblr
|
|||
import xkcdApropos
|
||||
import wikiphilosophy
|
||||
import acronymFinder
|
||||
from whosaid import whoSaid
|
||||
|
||||
parser = OptionParser()
|
||||
|
||||
|
@ -157,7 +160,7 @@ def get_tumble(url, channel):
|
|||
ircsock.send("PRIVMSG " + channel + " :" + line + "\n")
|
||||
|
||||
def get_xkcd(channel, text):
|
||||
links = xkcdApropos.xkcd_links(text[6:])
|
||||
links = xkcdApropos.xkcd(text[6:])
|
||||
joined_links = ', '.join(links)
|
||||
for line in [joined_links[i:i+400] for i in range(0, len(joined_links), 400)]:
|
||||
ircsock.send("PRIVMSG " + channel + " :" + line + "\n")
|
||||
|
@ -183,13 +186,39 @@ def figlet(channel, text):
|
|||
for line in lines.split('\n'):
|
||||
ircsock.send("PRIVMSG " + channel + " :" + line + "\n")
|
||||
|
||||
def toilet(channel, text):
|
||||
if not text:
|
||||
ircsock.send("PRIVMSG " + channel + " :No text given. :(\n")
|
||||
else:
|
||||
lines = subprocess.Popen(["toilet", "--irc"] + text.split(' '), shell=False, stdout=subprocess.PIPE).stdout.read()
|
||||
for line in lines.split('\n'):
|
||||
ircsock.send("PRIVMSG " + channel + " :" + line + "\n")
|
||||
time.sleep(0.3) #to avoid channel throttle due to spamming
|
||||
|
||||
def get_acronym(channel, text):
|
||||
if not text:
|
||||
ircsock.send("PRIVMSG " + channel + " :No text given :(\n")
|
||||
else:
|
||||
defs = acronymFinder.get_acros(text)
|
||||
defs = acronymFinder.get_acros(text, True)
|
||||
for d in defs[0:5]: #only the first five. they are already sorted by 'score'
|
||||
ircsock.send("PRIVMSG " + channel + " :" + d + "\n")
|
||||
if len(defs) > 5:
|
||||
ircsock.send("PRIVMSG " + channel + " :" + defs[-1] + "\n")
|
||||
|
||||
def get_whosaid(channel, text):
|
||||
if not text:
|
||||
ircsock.send("PRIVMSG " + channel + " :No text given :(\n")
|
||||
else:
|
||||
result = whoSaid(text)
|
||||
date = datetime.date.fromtimestamp(result['timecutoff'])
|
||||
dateStr = date.strftime('%B %d')
|
||||
if not result['data']:
|
||||
msg = 'Nobody said \'%s\' since %s' % (text, dateStr)
|
||||
else:
|
||||
msg = 'Since %s, %s said \'%s\' %d times' % (dateStr, result['data'][0][0], text, result['data'][0][1])
|
||||
if len(result['data']) > 1:
|
||||
msg += ' and %s said it %d times' % (result['data'][1][0], result['data'][1][1])
|
||||
ircsock.send("PRIVMSG " + channel + " :" + msg + ".\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, !rhymes, and !define. Make your chatter #legend with !rainbow and get jokes with !welch and !evil\n")
|
||||
|
@ -268,9 +297,15 @@ def listen():
|
|||
if ircmsg.find("!figlet") != -1:
|
||||
figlet(channel, messageText[8:])
|
||||
|
||||
if ircmsg.find("!toilet") != -1:
|
||||
toilet(channel, messageText[8:])
|
||||
|
||||
if ircmsg.find("!acronym") != -1:
|
||||
get_acronym(channel, messageText[9:])
|
||||
|
||||
if ircmsg.find(":!whosaid") != -1:
|
||||
get_whosaid(channel, messageText[9:])
|
||||
|
||||
if ircmsg.find(":!rollcall") != -1:
|
||||
rollcall(channel)
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
endorphant&^%68
|
||||
krowbar&^%142
|
||||
krowbar&^%175
|
||||
karlen&^%2
|
||||
jumblesal&^%37
|
||||
marcus&^%28
|
||||
premysl&^%29
|
||||
demophoon&^%50
|
||||
minerobbe&^%76
|
||||
|
|
|
@ -4,10 +4,11 @@ import inflect
|
|||
|
||||
p = inflect.engine()
|
||||
primes = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]
|
||||
obfuscate = True
|
||||
|
||||
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(["Prove you're not a robot: ", "Are you a robot?: ", "Anti-bot check: ", "Counter-cndorphant measures: ", "Cosnok countermeasures: "])
|
||||
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,6)
|
||||
|
@ -42,4 +43,8 @@ def make_puzzle():
|
|||
|
||||
|
||||
puzzle += "? (Answer with numbers)"
|
||||
if obfuscate == True:
|
||||
for _ in range(3):
|
||||
idx = random.randrange(len(puzzle)-1) #get between 0 and string length
|
||||
puzzle = ''.join([puzzle[0:idx], chr(random.randint(33,126)), puzzle[idx+1:]])
|
||||
return [answer, puzzle]
|
||||
|
|
|
@ -139,8 +139,7 @@ Who sent the last text message you received?
|
|||
Which store would you choose to max out your credit card?
|
||||
What time is bed time?
|
||||
Have you ever been in a beauty pageant?
|
||||
How many tattoos do you have?
|
||||
If you don't have any, have you ever thought of getting one?
|
||||
How many tattoos do you have? If you don't have any, have you ever thought of getting one?
|
||||
What did you do for your last birthday?
|
||||
Do you carry a donor card?
|
||||
Who was the last person you ate dinner with?
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
if [[ ! `pidof -sx banterbot.py` ]]; then
|
||||
nohup ./banterbot.py -s 127.0.0.1 -n banterbot -c \#tildetown >> banterlog 2>> banterlog &
|
||||
echo "Starting banterbot"
|
||||
#nohup ./banterbot.py -s 127.0.0.1 -n banterbot -c \#bot_test >> banterlog 2>> banterlog &
|
||||
#nohup ./banterbot.py -s 127.0.0.1 -n banterbot -c \#bot_test >> banterlog 2>> banterlog &
|
||||
else
|
||||
echo "Banterbot has already been started"
|
||||
fi
|
||||
|
|
|
@ -54,9 +54,9 @@ def too_recent(time1, time2):
|
|||
return False
|
||||
|
||||
def get_prize(user, isHuman, bonus=0):
|
||||
prizes = [1] * 8 + [2] * 4 + [3] * 2 + [5] * isHuman #no 5pt prize for non-humans
|
||||
prize = random.choice(prizes) + bonus
|
||||
if(random.randint(1,10) > 6 - 4 * isHuman): #80% of the time it's a normal prize (40% for not humans)
|
||||
prizes = [1] * 8 + [2] * 4 + [3] * 2 + [5] * isHuman #no 5pt prize for non-humans
|
||||
prize = random.choice(prizes) + bonus
|
||||
return [prize, user + ": " + (random.choice(['Yes','Yep','Correct','You got it']) if isHuman else random.choice(['No', 'Nope', 'Sorry', 'Wrong']))\
|
||||
+ "! You are " + ("super " if prize > 4 else "really " if prize > 2 else "") + "cool and get " + p.number_to_words(prize) + " tildes!"]
|
||||
else: #20% of the time its a jackpot situation
|
||||
|
@ -65,8 +65,8 @@ def get_prize(user, isHuman, bonus=0):
|
|||
jackpotfile.seek(0)
|
||||
jackpotfile.truncate()
|
||||
if(random.randint(1,10) > 1 or not isHuman): #90% of the time it's a non-prize. non-humans never win jackpot
|
||||
new_jackpot = jackpot+1
|
||||
jackpotfile.write(str(new_jackpot)) #increase the jackpot by 1
|
||||
new_jackpot = jackpot+max(1,prize)
|
||||
jackpotfile.write(str(new_jackpot)) #increase the jackpot by the prize size
|
||||
return [0, user + " is a meanie and gets no tildes! (Jackpot is now " + str(new_jackpot) + " tildes)"]
|
||||
else: #hit jackpot!
|
||||
jackpotfile.write(str(JACKPOT_MIN))
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
krowbar&^%568&^%1457628524
|
||||
karlen&^%272&^%1449500011
|
||||
krowbar&^%976&^%1473263667
|
||||
karlen&^%277&^%1472020404
|
||||
endorphant&^%682&^%1444775660
|
||||
jumblesale&^%24&^%1426171214
|
||||
marcus&^%1017&^%1457620552
|
||||
marcus&^%1684&^%1472578522
|
||||
papa&^%179&^%1438878499
|
||||
epicmorphism&^%5&^%1421937744
|
||||
audy&^%78&^%1442345315
|
||||
audy&^%78&^%1466749239
|
||||
kc&^%18&^%1422326056
|
||||
vilmibm&^%9&^%1445468087
|
||||
cmr&^%1138&^%1457560235
|
||||
vilmibm&^%9&^%1466847955
|
||||
cmr&^%1806&^%1473263713
|
||||
imt&^%519&^%1424087616
|
||||
cndorphant&^%788&^%1424094192
|
||||
rain&^%17&^%1422310975
|
||||
sl2c&^%91&^%1424847521
|
||||
selfsame&^%1&^%1422230012
|
||||
bear&^%234&^%1457620876
|
||||
bear&^%249&^%1469459728
|
||||
coaxial&^%8&^%1422325983
|
||||
joe&^%8&^%1422325983
|
||||
hardmath123&^%4&^%1422325983
|
||||
|
@ -27,15 +27,18 @@ cndorphbot&^%11&^%1441299746
|
|||
reppard&^%11&^%1437512059
|
||||
jesse&^%6&^%1437569027
|
||||
khoi&^%3&^%1438044039
|
||||
sanqui&^%4&^%1438184911
|
||||
endorphan&^%65&^%1456348638
|
||||
cndorphbo&^%4&^%1455813639
|
||||
sanqui&^%19&^%1472819894
|
||||
endorphan&^%101&^%1472425043
|
||||
cndorphbo&^%9&^%1466591324
|
||||
santi&^%3&^%1447873216
|
||||
insom&^%1&^%1450346059
|
||||
tahnok&^%3&^%1450457276
|
||||
tahnok&^%4&^%1464913072
|
||||
nilsding&^%12&^%1454100197
|
||||
vypr&^%3&^%1452470872
|
||||
synergian&^%21&^%1454583808
|
||||
synergian&^%22&^%1458152889
|
||||
dheeraj&^%5&^%1456489270
|
||||
demobot&^%6&^%1454439605
|
||||
premysl&^%19&^%1456882805
|
||||
premysl&^%65&^%1461768606
|
||||
minerobbe&^%23&^%1465950289
|
||||
xkeeper&^%14&^%1461967961
|
||||
cosnok&^%385&^%1473263717
|
||||
|
|
|
@ -22,3 +22,8 @@
|
|||
1453924207&^%krowbar&^%The best things happen when you're parsing
|
||||
1455303761&^%krowbar&^%Writing bots for fun and profit!
|
||||
1456153721&^%krowbar&^%BOTS OF TILDE TOWN, RISE FROM YOUR GRAVES!
|
||||
1459345246&^%krowbar&^%The only thing certain in life is bots and taxes
|
||||
1461591246&^%krowbar&^%What is your favorite memory of Christmases past?
|
||||
1470840451&^%marcus&^%Bots are cool, yo!
|
||||
1471364647&^%krowbar&^%Test bots and play games
|
||||
1471365078&^%krowbar&^%Test bots and play games. Use !rollcall to list bot's abilities
|
||||
|
|
|
@ -133,3 +133,29 @@
|
|||
1453427743&^%vilmibm&^%WHAT MOVIE SHOULD WE WATCH IN ASCII ON MOVIE NIGHT? | add yrself to the map http://tilde.town/~bear/where.html
|
||||
1455911894&^%vilmibm&^%RESTART IMMINENT | OUT YOUR CRUSHES | WATCH THE WORLD BURN
|
||||
1456278388&^%vilmibm&^%how about the feels tho?
|
||||
1459142397&^%vilmibm&^%what is your favorite html tag and why
|
||||
1459201315&^%vilmibm&^%who would like to be able to use cgi bin scripts?
|
||||
1459831112&^%vilmibm&^%when was the last time you thought about a tree?
|
||||
1460409890&^%vilmibm&^%why, though?
|
||||
1460603383&^%vilmibm&^%when was the last time you puked?
|
||||
1460603418&^%vilmibm&^%have you ever intentionally destroyed some tangible thing?
|
||||
1461126470&^%vilmibm&^%fire?
|
||||
1461445727&^%vilmibm&^%does the internet feel more or less lonely now than in the past?
|
||||
1461584303&^%premysl&^%If you could have a child with any famous person alive, who would it be? What would you name him/her?
|
||||
1461709537&^%vilmibm&^%did you know there's a tilde.town zine in the works? submit! https://github.com/tildetown/zine
|
||||
1462235950&^%vilmibm&^%omg ~endorphant/bin/ttbp | contrib 2 zine <3 https://github.com/tildetown/zine
|
||||
1462435258&^%vilmibm&^%harsh
|
||||
1462435306&^%vilmibm&^%Everything is Up | contrib 2 zine <3 https://github.com/tildetown/zine
|
||||
1462913538&^%vilmibm&^%lol washpo http://wapo.st/1WVQGuS | contrib 2 zine <3 https://github.com/tildetown/zine
|
||||
1467089202&^%vilmibm&^%when was the last time you cried for joy, not sadness
|
||||
1468306858&^%vilmibm&^%have you ever taken apart a computer to hang its innards on your wall
|
||||
1469144561&^%vilmibm&^%who is your favorite lizard?
|
||||
1470363543&^%vilmibm&^%TILDE.TOWN ZINE ISSUE 1 IS OUT! https://t.co/EqOBdefVkQ | CONTRIBUTE TO ISSUE 2 https://github.com/tildetown/zine/blob/master/contributing.md
|
||||
1470840724&^%vilmibm&^%someone did some seemingly malicious things and amazon cut us off of everything but ssh
|
||||
1470842778&^%vilmibm&^%scanning was not malicious; waiting on amazon to restore our non-ssh access
|
||||
1470936112&^%vilmibm&^%please don't ever perform pentesting from this host
|
||||
1471278375&^%cmr&^%oom-killer killed the ircd because the box ran out of memory. does anyone know what ate all the memory?
|
||||
1471364675&^%cmr&^%Would you rather lead or follow? Why?
|
||||
1471364822&^%krowbar&^%If you could be permanently one color for the rest of your life, what color would it be & why?
|
||||
1472981491&^%vilmibm&^%any feedback on the new homepage template? http://tilde.town/~vilmibm/new_tilde_index.html
|
||||
1473143684&^%vilmibm&^%how was your day?
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
krowbar&^%10&^%21
|
||||
vilmibm&^%0&^%22
|
||||
krowbar&^%15&^%26
|
||||
vilmibm&^%0&^%44
|
||||
hardmath123&^%0&^%6
|
||||
joe&^%1&^%1jumblesale
|
||||
audiodude&^%1&^%0
|
||||
cmr&^%0&^%3
|
||||
cmr&^%0&^%5
|
||||
insom&^%1&^%0
|
||||
premysl&^%0&^%1marcus&^%1&^%0
|
||||
marcus&^%1&^%1
|
||||
|
|
|
@ -7,17 +7,25 @@ def tumble(url):
|
|||
#Find the max pages
|
||||
soup = BeautifulSoup(urllib.urlopen(url).read(), 'html.parser')
|
||||
pages = soup.findAll('span', 'page-numbers')[0].text.split('/')[1] #this could totally fail several ways
|
||||
page = random.randrange(1, int(pages)+1)
|
||||
tries = 3
|
||||
while True:
|
||||
try:
|
||||
page = random.randrange(1, int(pages)+1)
|
||||
|
||||
#Parse a page
|
||||
soup = BeautifulSoup(urllib.urlopen(url + '/page/' + str(page)).read(), 'html.parser')
|
||||
article = random.choice(soup.findAll('article'))
|
||||
quote = article.find('blockquote').text.replace('\n','');
|
||||
if len(article.find('footer').findAll('ul')) > 1:
|
||||
quote += re.sub('\n+', ' ', article.find('footer').findAll('ul')[0].text); #the hash tags
|
||||
quote += '(' + re.sub('\n+', ' ', article.find('footer').findAll('ul')[1].text) + ')'; #and the date and notes
|
||||
else:
|
||||
quote += '(' + re.sub('\n+', ' ', article.find('footer').findAll('ul')[0].text) + ')'; #just the date and notes
|
||||
|
||||
return quote.encode('ascii', 'ignore')
|
||||
#Parse a page
|
||||
soup = BeautifulSoup(urllib.urlopen(url + '/page/' + str(page)).read(), 'html.parser')
|
||||
article = random.choice(soup.findAll('article'))
|
||||
quote = article.find('blockquote').text.replace('\n','');
|
||||
if len(article.find('footer').findAll('ul')) > 1:
|
||||
quote += re.sub('\n+', ' ', article.find('footer').findAll('ul')[0].text); #the hash tags
|
||||
quote += '(' + re.sub('\n+', ' ', article.find('footer').findAll('ul')[1].text) + ')'; #and the date and notes
|
||||
else:
|
||||
quote += '(' + re.sub('\n+', ' ', article.find('footer').findAll('ul')[0].text) + ')'; #just the date and notes
|
||||
|
||||
return quote.encode('ascii', 'ignore')
|
||||
except: #sometimes we fail. let's retry a few times
|
||||
if tries == 0:
|
||||
return ''
|
||||
else:
|
||||
tries -= 1
|
||||
break
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/python
|
||||
import fileinput
|
||||
import time
|
||||
import calendar
|
||||
import re
|
||||
import operator
|
||||
|
||||
MAX_NODES = 5
|
||||
|
||||
logfile = "/home/jumblesale/Code/irc/log"
|
||||
timeCutoff = calendar.timegm(time.gmtime()) - (3 * 7 * 24 * 60 * 60) #3 weeks
|
||||
|
||||
nameFix = {
|
||||
'jumblesal': 'jumblesale',
|
||||
'hardmath1': 'kc',
|
||||
'hardmath123': 'kc',
|
||||
'bendorphan': 'endorphant',
|
||||
'endorphan': 'endorphant',
|
||||
'synergian': 'synergiance'
|
||||
}
|
||||
def whoSaid(word):
|
||||
word = word.lower()
|
||||
userData = {} #hash keyed by "user" that contains a hash of mentioned other users with count
|
||||
#Get a list of all user names by checking the logs for people who have said things
|
||||
with open(logfile, "r") as log:
|
||||
for line in log:
|
||||
try:
|
||||
time, user, message = line.split("\t", 3)
|
||||
time = int(time)
|
||||
if nameFix.has_key(user):
|
||||
user = nameFix[user]
|
||||
else:
|
||||
user = user.lower()
|
||||
except ValueError:
|
||||
continue #There are some bad lines in the log file that we'll ignore if we can't parse
|
||||
|
||||
if time > timeCutoff and message[0] is not '!' and word in message.lower():
|
||||
if user in userData:
|
||||
userData[user] += 1
|
||||
else:
|
||||
userData[user] = 1
|
||||
userData = sorted(userData.items(), key=operator.itemgetter(1), reverse=True)
|
||||
return {'timecutoff': timeCutoff, 'data': userData}
|
|
@ -9,16 +9,20 @@ def xkcd(query):
|
|||
title = BeautifulSoup(urllib.urlopen(res).read(), 'html.parser').title.text
|
||||
except:
|
||||
pass #just swallow the error. maybe the result wasn't a url or something else bad happened
|
||||
return (((title + ' - ') if title else '') + res).encode('ascii', 'ignore')
|
||||
return [(((title + ' - ') if title else '') + res).encode('ascii', 'ignore')]
|
||||
|
||||
def xkcd_links(query):
|
||||
url = "https://duckduckgo.com/html/?q=site%3Axkcd.com+" + query.replace(' ', '+')
|
||||
soup = BeautifulSoup(urllib.urlopen(url).read(), 'html.parser')
|
||||
links = filter(lambda a: a[0:8] == 'xkcd.com', [a.text.strip() for a in soup.find_all("div", class_="url")])
|
||||
def pretty_link(url):
|
||||
data = BeautifulSoup(urllib.urlopen('http://'+url).read(), 'html.parser')
|
||||
title = data.title.text if data.title else ''
|
||||
return (title + ' - ' + url) if title else url
|
||||
|
||||
links = map(lambda url: pretty_link(url), links)
|
||||
return links
|
||||
# never mind, blocked by ddg
|
||||
#def xkcd_links(query):
|
||||
# url = "https://duckduckgo.com/html/?q=site%3Axkcd.com+" + query.replace(' ', '+')
|
||||
# soup = BeautifulSoup(urllib.urlopen(url).read(), 'html.parser')
|
||||
# items = soup.find_all("a", class_="result__a")
|
||||
# print items
|
||||
# items = filter(lambda i: i[0:8] == 'xkcd.com', [i.find(class_="result__title").text.strip() for i in items])
|
||||
# print items
|
||||
# def pretty_link(item):
|
||||
# url = item.find(class_="result__url").text.strip()
|
||||
# title = item.find(class_="result__title").text.strip()
|
||||
# return (title + ' - ' + url) if title else url
|
||||
#
|
||||
# links = map(lambda url: pretty_link(url), items)
|
||||
# return links
|
||||
|
|
|
@ -8,11 +8,13 @@ import re
|
|||
import math
|
||||
import operator
|
||||
|
||||
MAX_NODES = 3
|
||||
MAX_NODES = 5
|
||||
|
||||
logfile = "/home/jumblesale/Code/irc/log"
|
||||
outfile = "/home/krowbar/logs/chatBesties.json"
|
||||
outCircle = "/home/krowbar/logs/chatcircle.json"
|
||||
timePeriod = calendar.timegm(time.gmtime()) - (3 * 7 * 24 * 60 * 60) #3 weeks
|
||||
|
||||
userData = {} #hash keyed by "user" that contains a hash of mentioned other users with count
|
||||
nameFix = {
|
||||
'jumblesal': 'jumblesale',
|
||||
|
@ -47,6 +49,8 @@ with open(logfile, "r") as log:
|
|||
for line in log:
|
||||
try:
|
||||
time, user, message = line.split("\t", 3)
|
||||
if int(time) < timePeriod:
|
||||
continue #only consider the past three weeks of chats
|
||||
if nameFix.has_key(user):
|
||||
user = nameFix[user]
|
||||
else:
|
||||
|
@ -61,31 +65,38 @@ with open(logfile, "r") as log:
|
|||
userData[user]['data'][word] += 1
|
||||
else: #This user never mentioned this person before
|
||||
userData[user]['data'][word] = 1
|
||||
#give both the target and mentioner a point
|
||||
else: #This user was never set up
|
||||
userData[user] = {} #make it a dictionary!
|
||||
userData[user]['data'] = {}
|
||||
userData[user]['data'][word] = 1
|
||||
userData[user]['score'] = 0
|
||||
userData[user]['id'] = len(d3data['nodes']) #so we know how to match people during the links phase
|
||||
d3data['nodes'].append({"name": user, "group": 1})
|
||||
if not userData.has_key(word): #check if the target has not been set up
|
||||
userData[word] = {}
|
||||
userData[word]['data'] = {}
|
||||
userData[word]['score'] = 0
|
||||
userData[word]['id'] = len(d3data['nodes'])
|
||||
d3data['nodes'].append({"name": word, "group": 1})
|
||||
userData[user]['score'] += 1
|
||||
userData[word]['score'] += 1
|
||||
|
||||
d3data['links'] = []
|
||||
#Now connect all the pople to their stuff
|
||||
for user, values in userData.iteritems():
|
||||
besties = sorted(values['data'].items(), key=operator.itemgetter(1), reverse=True)[0:MAX_NODES] #ONLY the top 5 besties
|
||||
#give the user a 'group' based on their total score
|
||||
d3data['nodes'][values['id']]['group'] = int(math.ceil(math.sqrt(math.sqrt(values['score']))))
|
||||
besties = sorted(values['data'].items(), key=operator.itemgetter(1), reverse=True)[0:MAX_NODES] #ONLY the top besties
|
||||
for target, score in besties:
|
||||
try:
|
||||
print "Adding link for " + user + " (" + str(values['id']) + ") to " + target + " (" + str(userData[target]['id']) + ") for " + str(score)
|
||||
print "Adding link from " + user + " (" + str(values['id']) + ") to " + target + " (" + str(userData[target]['id']) + ") with strength " + str(score)
|
||||
d3data['links'].append({"source": values['id'], "target": userData[target]['id'], "value": math.ceil(math.sqrt(score))})
|
||||
except KeyError:
|
||||
print "Error when trying to link " + user + " to " + target
|
||||
print "! Error when trying to link " + user + " to " + target
|
||||
continue
|
||||
if len(values['data']) > MAX_NODES:
|
||||
print "...ignoring " + str(len(values['data']) - MAX_NODES) + " more connections"
|
||||
print " ...ignoring " + str(len(values['data']) - MAX_NODES) + " more connections from " + user
|
||||
|
||||
d3Circle = {}
|
||||
d3Circle['names'] = [''] * len(userData)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
This is just some stuff I've worked on as a member of tilde.town
|
||||
When the site ever goes away (and I know it will someday), I'll at least have a copy of all my silly, mostly-pointless projects.
|
|
@ -5,3 +5,5 @@ TopicBot
|
|||
and who set the topic
|
||||
- On load, sets the last topic in the topics file as the current topic
|
||||
- Current topic will time out after X hours (or just display the time)
|
||||
|
||||
Play with http://www.chartjs.org/docs/
|
||||
|
|
|
@ -24,7 +24,11 @@ charset="utf-8"></script>-->
|
|||
userData.lineCount,
|
||||
userData.wordCount, Number((userData.wordCount / userData.lineCount).toFixed(2)),
|
||||
userData.charCount, Number((userData.charCount / userData.lineCount).toFixed(2)),
|
||||
userData.streak, userData.mentions, userData.botUse,
|
||||
userData.streak,
|
||||
userData.mentions,
|
||||
(userData.mentions / userData.daysActive),
|
||||
(userData.mentions / userData.lineCount),
|
||||
userData.botUse,
|
||||
Number((userData.responseTime / (userData.mentions ? userData.mentions : 1) / 60).toFixed(2)),
|
||||
]);
|
||||
});
|
||||
|
@ -40,7 +44,7 @@ charset="utf-8"></script>-->
|
|||
var minFormatter = new google.visualization.NumberFormat({pattern: '##.## minutes'});
|
||||
var dayFormatter = new google.visualization.NumberFormat({pattern: '## days'});
|
||||
var wordFormatter = new google.visualization.NumberFormat({pattern: '##.## words'});
|
||||
var charFormatter = new google.visualization.NumberFormat({pattern: '##.## chars'});
|
||||
var charFormatter = new google.visualization.NumberFormat({pattern: '##.## char'});
|
||||
var streakFormatter = new google.visualization.NumberFormat({pattern: '## lines'});
|
||||
var mentionsFormatter = new google.visualization.NumberFormat({pattern: '## mentions'});
|
||||
|
||||
|
@ -48,17 +52,19 @@ charset="utf-8"></script>-->
|
|||
dataTable.addColumn('datetime', 'First Spoke'); //col1
|
||||
dataTable.addColumn('datetime', 'Last Spoke'); //col2
|
||||
dataTable.addColumn('number', 'Total'); //col3
|
||||
dataTable.addColumn('number', 'Active on'); //col4
|
||||
dataTable.addColumn('number', 'Active'); //col4
|
||||
dataTable.addColumn('number', 'Ratio'); //col5
|
||||
dataTable.addColumn('number', 'Lines'); //col6
|
||||
dataTable.addColumn('number', 'Words'); //col7
|
||||
dataTable.addColumn('number', 'per Line'); //col8
|
||||
dataTable.addColumn('number', 'Characters'); //col9
|
||||
dataTable.addColumn('number', 'per Line'); //col10
|
||||
dataTable.addColumn('number', 'Chat Streak'); //col11
|
||||
dataTable.addColumn('number', 'Streak'); //col11
|
||||
dataTable.addColumn('number', 'Popularity'); //col12
|
||||
dataTable.addColumn('number', 'Bot Use'); //col13
|
||||
dataTable.addColumn('number', 'Response time'); //col14
|
||||
dataTable.addColumn('number', 'by Day'); //col13
|
||||
dataTable.addColumn('number', 'by Line'); //col14
|
||||
dataTable.addColumn('number', 'Bot Use'); //col15
|
||||
dataTable.addColumn('number', 'Response time'); //col16
|
||||
|
||||
dataTable.addRows(data);
|
||||
userFormatter.format(dataTable, [0]);
|
||||
|
@ -68,7 +74,7 @@ charset="utf-8"></script>-->
|
|||
charFormatter.format(dataTable, 10);
|
||||
streakFormatter.format(dataTable, 11);
|
||||
mentionsFormatter.format(dataTable, 12);
|
||||
minFormatter.format(dataTable, 14);
|
||||
minFormatter.format(dataTable, 16);
|
||||
console.log("* Set up the columns!");
|
||||
|
||||
var table = new google.visualization.Table(document.getElementById('statTable'));
|
||||
|
|
|
@ -53,15 +53,22 @@
|
|||
//maybe i could add something to show more points but we're not losing too much granularity for the speed we gain
|
||||
if(idx % 8 != 0) return;
|
||||
_.forEach(set.data, function(point) {
|
||||
if(point.du > 2000) { //the 'interesting' threshold is set at 20000kb
|
||||
if(!userData[point.user]) {
|
||||
userData[point.user] = [];
|
||||
if(point.du > 5000) { //the 'interesting' threshold is set at 5000kb
|
||||
if(!userData[point.user]) { //if the current user has not been initialized yet
|
||||
userData[point.user] = []; //create an empty array
|
||||
var size = json.length;
|
||||
while(size--) userData[point.user][size] = 0;
|
||||
linedata.addColumn('number', point.user);
|
||||
while(size--) userData[point.user][size] = 0; //and populate it with zeros for the lenght of our entire set
|
||||
linedata.addColumn('number', point.user); //then add a column of type 'number' for this user
|
||||
|
||||
}
|
||||
userData[point.user][idx] = point.du;
|
||||
userData[point.user][idx] = point.du; //add a point for this user
|
||||
//if the last three data points are the same value
|
||||
//if(idx > 16 && userData[point.user][idx] == userData[point.user][idx-8] && userData[point.user][idx-16]) {
|
||||
// userData[point.user].splice(idx,1); //then get rid of the middle one
|
||||
// if(point.user == '~vilmibm') {
|
||||
// console.log('points', userData[point.user]);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -7,9 +7,12 @@ Links and stuff
|
|||
<ul>
|
||||
<li><a href="chatchecker/">Tilde.town IRC Chat checker</a></li>
|
||||
<li><a href="chatstats/">IRC User Chat Statistics</a></li>
|
||||
<li><a href="besties/">IRC Chat Bestie Nodes</a></li>
|
||||
<li><a href="circle/">IRC Chat Bestie Circle</a></li>
|
||||
<li><a href="twine2/">Twine 2.0</a></li>
|
||||
<li><a href="grimoire/app/">Grimoire: The Pathfinder Item Roller</a></li>
|
||||
<li><a href="https://github.com/RussellChamp/PragmaticDiceBag">Pragmatic Dice Bag: Artsy fartsy guide!</a></li>
|
||||
<li><a href="limericks/">Dumb Limericks</a></li>
|
||||
</ul>
|
||||
|
||||
<h2><a href="chatcloud/">Tilde.town IRC Chat cloud</a></h2>
|
||||
|
|
Loading…
Reference in New Issue