Changed numberwang_bot changed the twee. backup the scores

This commit is contained in:
RussellChamp committed 2015-01-29 21:05:37 +00:00
1 parent 2eb87eb522
commit 9ecd97dff1
6 files changed
+35 -53

No files matched your search

-8
View File
@@ -1,8 +0,0 @@
Traceback (most recent call last):
File "./topicbot.py", line 187, in <module>
listen()
File "./topicbot.py", line 161, in listen
get_topic(channel, user, time)
File "./topicbot.py", line 61, in get_topic
with open("topics_" + channel + ".txt", "r") as topics:
IOError: [Errno 2] No such file or directory: 'topics_topicbot.txt'
+14 -11
View File
@@ -1,16 +1,19 @@
krowbar&^%8&^%1422035087
karlen&^%13&^%1422027689
endorphant&^%26&^%1422033378
krowbar&^%33&^%1422565422
karlen&^%15&^%1422291058
endorphant&^%62&^%1422561985
jumblesale&^%18&^%1422027769
marcus&^%12&^%1421960027
papa&^%5&^%1422029014
papa&^%41&^%1422542104
epicmorphism&^%3&^%1421937744
audy&^%13&^%1422034301
kc&^%5&^%1421975132
audy&^%27&^%1422542589
kc&^%16&^%1422326056
vilmibm&^%3&^%1421887627
cmr&^%4&^%1421989946
imt&^%12&^%1422014172
cndorphant&^%22&^%1422033254
rain&^%4&^%1422034265
sl2c&^%6&^%1422036167
cmr&^%6&^%1422388018
imt&^%95&^%1422565426
cndorphant&^%125&^%1422395920
rain&^%15&^%1422310975
sl2c&^%28&^%1422524176
leni&^%2&^%1421978450
selfsame&^%1&^%1422230012
bear&^%46&^%1422561755
coaxial&^%4&^%1422325983
+2 -2
View File
@@ -1,5 +1,5 @@
krowbar&^%21&^%22
krowbar&^%21&^%23
um&^%11&^%8
kc&^%0&^%22
marcus&^%3&^%1
khoi&^%1&^%0karlen&^%0&^%1karlen&^%0&^%1jumblesale&^%1&^%0karlen&^%0&^%1karlen&^%0&^%1karlen&^%0&^%1dan&^%1&^%0datagrok&^%0&^%1vilmibm&^%0&^%1papa&^%1&^%0vilmibm&^%1&^%0vilmibm&^%0&^%1jumblesale&^%1&^%0selfsame&^%1&^%0karlen&^%0&^%1jumblesale&^%0&^%1karlen&^%0&^%1vilmibm&^%0&^%1vilmibm&^%0&^%1
khoi&^%1&^%0karlen&^%0&^%1karlen&^%0&^%1jumblesale&^%1&^%0karlen&^%0&^%1karlen&^%0&^%1karlen&^%0&^%1dan&^%1&^%0datagrok&^%0&^%1vilmibm&^%0&^%1papa&^%1&^%0vilmibm&^%1&^%0vilmibm&^%0&^%1jumblesale&^%1&^%0selfsame&^%1&^%0karlen&^%0&^%1jumblesale&^%0&^%1karlen&^%0&^%1vilmibm&^%0&^%1vilmibm&^%0&^%1vilmibm&^%0&^%1jumblesale&^%1&^%0
+13 -27
View File
@@ -35,6 +35,7 @@ MIN_ROUNDS = 5
MAX_ROUNDS = 12
SCORE_FILE = "numberwangscores.txt"
SHOW_TOP_NUM = 5
GOOD_CHAN = "#bots"
roundsLeft = 0
bonusRound = 0
@@ -68,6 +69,10 @@ def hello():
ircsock.send("PRIVMSG "+ channel +" :Hello!\n")
def start_numberwang(channel, user):
if(channel != "#bots"):
ircsock.send("PRIVMSG " + channel + " :Numberwang has been disabled for " + channel + " due to spamminess. Please join " + GOOD_CHAN + " to start a game.\n")
return
print user + " started a game"
resetGlobals()
ircsock.send("PRIVMSG " + channel + " :It's time for Numberwang!\n")
@@ -190,29 +195,6 @@ def show_user_score(channel, user):
#if we don't find a score line
ircsock.send("PRIVMSG " + channel + " :" + user + ": You haven't scored any points yet!\n")
def give_tilde(channel, user, time):
found = False
with open("tildescores.txt", "r+") as scorefile:
scores = scorefile.readlines()
scorefile.seek(0)
scorefile.truncate()
for score in scores:
person = score.strip("\n").split("&^%")
if(person[0] == user):
found = True
if(too_recent(time, person[2])):
ircsock.send("PRIVMSG " + channel + " :You have asked for a tilde too recently. Try again later.\n")
else:
prize = get_prize(user)
score = person[0] + "&^%" + str(int(person[1]) + prize[0]) + "&^%" + time + "\n"
ircsock.send("PRIVMSG " + channel + " :" + prize[1] + "\n")
scorefile.write(score)
if(not found):
prize = get_prize(user)
ircsock.send("PRIVMSG " + channel + " :Welcome to the tilde game! Here's " + p.number_to_words(prize[0]+1) + " free tilde(s) to start you off.\n")
scorefile.write(user + "&^%" + str(prize[0]+1) + "&^%" + time + "\n")
def rollcall(channel):
ircsock.send("PRIVMSG "+ channel +" :Is it time for Numberwang? It might be! Start a new game with !numberwang or stop a current game with !wangernumb Get your score with !myscore and the list of top wangers with !topwangers\n")
@@ -222,6 +204,7 @@ def connect(server, channel, botnick):
ircsock.send("NICK "+ botnick +"\n")
joinchan(channel)
joinchan(GOOD_CHAN)
def get_user_from_message(msg):
try:
@@ -256,10 +239,13 @@ def listen():
if ircmsg.find(":!numberwang") != -1 and roundsLeft == 0:
start_numberwang(channel, user)
if ircmsg.find(":!wangernumb") != -1 and roundsLeft > 0:
stop_numberwang(channel, user)
if roundsLeft > 0:
guess_numberwang(channel, user, messageText)
if channel == GOOD_CHAN:
if ircmsg.find(":!wangernumb") != -1 and roundsLeft > 0:
stop_numberwang(channel, user)
if roundsLeft > 0:
guess_numberwang(channel, user, messageText)
if ircmsg.find(":!topwangers") != -1:
show_highscores(channel)
if ircmsg.find(":!myscore") != -1: