mirror of
https://github.com/RussellChamp/tilde-projects.git
synced 2026-10-28 00:22:34 +00:00
Some recent changes and stuff
This commit is contained in:
1 parent
ebb5f2fe37
commit
86916fb5fa
18 files changed
+321
-30
No files matched your search
+12
-4
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -1,2 +1,4 @@
|
||||
endorphant&^%68
|
||||
krowbar&^%60
|
||||
krowbar&^%119
|
||||
karlen&^%2
|
||||
jumblesal&^%37
|
||||
@@ -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]
|
||||
@@ -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
|
||||
@@ -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]
|
||||
@@ -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
|
||||
@@ -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!
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user