Some bot changes and stuff

This commit is contained in:
Russell 2015-11-24 12:56:18 -05:00
parent 94127052c9
commit ebb5f2fe37
9 changed files with 61 additions and 44 deletions

View File

@ -15,6 +15,8 @@ import get_users
import mentions
import pretty_date
import inflect
from rhymesWith import getRhymes
from defineWord import define
parser = OptionParser()
@ -103,8 +105,32 @@ def get_new_banter(channel, user):
word = word[:end] + 't' + word[end+1:]
ircsock.send("PRIVMSG " + channel + " :" + user + ": Here, why don't you try '" + word + "'?\n")
def get_rhymes(channel, user, text):
word = ""
if(len(text.split(' ')) > 1):
word = text.split(' ')[1]
else:
with open("/home/nossidge/poems/words_poetic.txt", "r") as words:
word = random.choice(words.readlines()).strip("\n")
rhymes = getRhymes(word)
if(len(rhymes) == 0):
ircsock.send("PRIVMSG " + channel + " :" + user + ": Couldn't find anything that rhymes with '" + word + "' :(\n")
else:
ircsock.send("PRIVMSG " + channel + " :" + user + ": Here, these words rhyme with '" + word + "': " + ', '.join(rhymes) + "\n")
def define_word(channel, user, text):
word = ""
if(len(text.split(' ')) > 1):
word = text.split(' ')[1]
defs = define(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 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\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, !rhyme, and !define\n")
def connect(server, channel, botnick):
ircsock.connect((server, 6667))
@ -112,6 +138,7 @@ def connect(server, channel, botnick):
ircsock.send("NICK "+ botnick +"\n")
joinchan(channel)
joinchan("#bots")
def get_user_from_message(msg):
try:
@ -150,6 +177,12 @@ def listen():
if ircmsg.find(":!newbanter") != -1:
get_new_banter(channel, user)
if ircmsg.find(":!rhymes") != -1:
get_rhymes(channel, user, messageText)
if ircmsg.find(":!define") != -1:
define_word(channel, user, messageText)
if ircmsg.find(":!rollcall") != -1:
rollcall(channel)

View File

@ -1,30 +0,0 @@
Traceback (most recent call last):
File "./topicbot.py", line 188, in <module>
listen()
File "./topicbot.py", line 176, in listen
topic_history(channel, user, messageText)
File "./topicbot.py", line 104, in topic_history
iCount = int(count.split()[1])
IndexError: list index out of range
Traceback (most recent call last):
File "./topicbot.py", line 88, in <module>
def random_topic(channel, user, time, setTopic=false):
NameError: name 'false' is not defined
Traceback (most recent call last):
File "./topicbot.py", line 193, in <module>
listen()
File "./topicbot.py", line 162, in listen
count_topic(channel,user, time, messageText)
File "./topicbot.py", line 77, in count_topic
userscore = int(data[2])+1
ValueError: invalid literal for int() with base 10: '1insom'
Traceback (most recent call last):
File "./topicbot.py", line 193, in <module>
listen()
File "./topicbot.py", line 168, in listen
set_topic(channel, user, time, messageText[10:])
File "./topicbot.py", line 86, in set_topic
count_topic(channel, user, time, msg)
File "./topicbot.py", line 77, in count_topic
userscore = int(data[2])+1
ValueError: invalid literal for int() with base 10: '1vilmibm'

View File

@ -1,4 +1,5 @@
#!/bin/bash
nohup ./tildebot.py -s 127.0.0.1 -n tildebot -c \#tildetown >> tildelog 2>> tildelog &
if [[ ! `pidof -sx tildebot.py` ]]; then
nohup ./tildebot.py -s 127.0.0.1 -n tildebot -c \#tildetown >> tildelog 2>> tildelog &
fi
#nohup ./tildebot.py -s 127.0.0.1 -n tildebot -c \#bot_test >> tildelog 2>> tildelog &

View File

@ -1,5 +1,6 @@
#!/bin/bash
nohup ./topicbot.py -s 127.0.0.1 -n topicbot -c \#tildetown >> log 2>> log &
if [[ ! `pidof -sx topicbot.py` ]]; then
nohup ./topicbot.py -s 127.0.0.1 -n topicbot -c \#tildetown >> log 2>> log &
fi
#nohup ./topicbot.py -s 127.0.0.1 -n topicbot -c \#bot_test >> log 2>> log &
#./topic_bot.py -s 127.0.0.1 -n topic_bot -c \#bot_test

View File

@ -1,14 +1,14 @@
krowbar&^%238&^%1444399178
krowbar&^%263&^%1448316671
karlen&^%271&^%1426779321
endorphant&^%676&^%1444741627
endorphant&^%682&^%1444775660
jumblesale&^%24&^%1426171214
marcus&^%787&^%1444392035
marcus&^%815&^%1446654919
papa&^%179&^%1438878499
epicmorphism&^%5&^%1421937744
audy&^%78&^%1442345315
kc&^%18&^%1422326056
vilmibm&^%9&^%1423247508
cmr&^%1006&^%1444701265
vilmibm&^%9&^%1445468087
cmr&^%1054&^%1447812299
imt&^%519&^%1424087616
cndorphant&^%788&^%1424094192
rain&^%17&^%1422310975
@ -28,3 +28,6 @@ reppard&^%11&^%1437512059
jesse&^%6&^%1437569027
khoi&^%3&^%1438044039
sanqui&^%4&^%1438184911
endorphan&^%52&^%1448373701
cndorphbo&^%2&^%1447862524
santi&^%3&^%1447873216

View File

@ -16,3 +16,4 @@
1443998388&^%cmr&^%http://tilde.town/~wiki/ircbots.html
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

View File

@ -118,3 +118,10 @@
1442498441&^%krowbar&^%YAR! Happy Talk Like A Pirate Day on this fine September the 17th! Avast, ye scallywags!
1442502425&^%krowbar&^%what should we do for tilde.town's birthday?? | tilde.town turns 1 on October 11th
1444587668&^%vilmibm&^%~~~~~~~~~~~~HAPPY BIRTHDAY~~~~~~~~~~
1444952655&^%vilmibm&^%Welcome to the 30th Century Crystal Tokyo Palace Basement.
1444967383&^%vilmibm&^%http://www.adaweb.com/project/holzer/cgi/pcb.cgi?please
1445028333&^%vilmibm&^%http://www.adaweb.com/project/holzer/cgi/pcb.cgi?please | numb to the pain
1447251055&^%krowbar&^%Welcome to tilde.town! No gods or kings. Only users.
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?

View File

@ -1,6 +1,6 @@
krowbar&^%0&^%13
vilmibm&^%0&^%9
krowbar&^%3&^%16
vilmibm&^%0&^%14
hardmath123&^%0&^%6
joe&^%0&^%1jumblesale&^%1&^%0
joe&^%1&^%1jumblesale
audiodude&^%1&^%0
cmr&^%0&^%3

View File

@ -31,7 +31,8 @@ with open(logfile, "r") as log:
continue #We don't care what they say
if time >= timeCutoff and time <= timeTo:
#print "Processing line from " + user + " at " + str(time)
for word in re.sub('[\'\"\`\/\\;:,.?!*&^\-()<>|_\[\]0-9]', '', message).lower().split():
for word in re.sub('[\'\"\`\/\\;:,.?!*&^\-()<>\{\}|_\[\]0-9]', ' ', message).lower().split():
#changing symbols into spaces instead of stripping them avoids compounded words
if len(word) < minLength or word in bannedWords:
#print "Rejecting " + word
continue