Updated tildebot. backup topics and scores. updated twine
This commit is contained in:
parent
90c4270ebf
commit
670eb6fac8
|
@ -14,6 +14,7 @@ import get_users
|
|||
import mentions
|
||||
import pretty_date
|
||||
import inflect
|
||||
import puzzle
|
||||
|
||||
parser = OptionParser()
|
||||
|
||||
|
@ -27,6 +28,7 @@ parser.add_option("-n", "--nick", dest="nick", default='tildebot',
|
|||
(options, args) = parser.parse_args()
|
||||
|
||||
p = inflect.engine()
|
||||
challenges = {}
|
||||
SCORE_FILE = "tildescores.txt"
|
||||
JACKPOT_FILE = "tildejackpot.txt"
|
||||
JACKPOT_MIN = 3
|
||||
|
@ -50,17 +52,18 @@ def too_recent(time1, time2):
|
|||
else:
|
||||
return False
|
||||
|
||||
def get_prize(user):
|
||||
if(random.randint(1,10) > 2): #80% of the time it's a normal prize
|
||||
prizes = [1] * 8 + [2] * 4 + [3] * 2 + [5] * 1
|
||||
def get_prize(user, isHuman):
|
||||
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)
|
||||
return [prize, user + " is " + ("super " if prize > 4 else "really " if prize > 2 else "") + "cool and gets " + p.number_to_words(prize) + " tildes!"]
|
||||
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
|
||||
with open(JACKPOT_FILE, "r+") as jackpotfile:
|
||||
jackpot = int(jackpotfile.readline().strip("\n"))
|
||||
jackpotfile.seek(0)
|
||||
jackpotfile.truncate()
|
||||
if(random.randint(1,10) > 1): #90% of the time it's a non-prize
|
||||
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
|
||||
return [0, user + " is a meanie and gets no tildes! (Jackpot is now " + str(new_jackpot) + " tildes)"]
|
||||
|
@ -73,10 +76,7 @@ def show_jackpot(channel):
|
|||
jackpot = int(jackpotfile.readline().strip("\n"))
|
||||
ircsock.send("PRiVMSG " + channel + " :The jackpot is currently " + p.number_to_words(jackpot) + " tildes!\n")
|
||||
|
||||
def give_tilde(channel, user, time):
|
||||
if(channel != "#bots" and not DEBUG):
|
||||
ircsock.send("PRIVMSG " + channel + " :" + user + " is a meanie and gets no tildes. **Tildebot now only gives out tildes in the #bots channel.**\n")
|
||||
return
|
||||
def give_tilde(channel, user, time, human):
|
||||
found = False
|
||||
with open(SCORE_FILE, "r+") as scorefile:
|
||||
scores = scorefile.readlines()
|
||||
|
@ -89,12 +89,12 @@ def give_tilde(channel, user, time):
|
|||
if(too_recent(time, person[2]) and not DEBUG):
|
||||
ircsock.send("PRIVMSG " + channel + " :You have asked for a tilde too recently. Try again later.\n")
|
||||
else:
|
||||
prize = get_prize(user)
|
||||
prize = get_prize(user, human)
|
||||
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)
|
||||
prize = get_prize(user, True)
|
||||
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")
|
||||
|
||||
|
@ -108,6 +108,27 @@ def show_tildescore(channel, user):
|
|||
#person has not played yet
|
||||
ircsock.send("PRIVMSG " + channel + " :" + user + " has no tildes yet!\n")
|
||||
|
||||
def challenge(channel, user, time):
|
||||
if(channel != "#bots" and not DEBUG):
|
||||
ircsock.send("PRIVMSG " + channel + " :" + user + " is a meanie and gets no tildes. **Tildebot now only gives out tildes in the #bots channel.**\n")
|
||||
return
|
||||
global challenges;
|
||||
challenge = puzzle.make_puzzle();
|
||||
challenges[user] = challenge[0]; #challenges[USER] = ANSWER
|
||||
ircsock.send("PRIVMSG " + channel + " :" + user + ": " + challenge[1] + "\n");
|
||||
|
||||
def challenge_response(channel, user, time, msg):
|
||||
global challenges
|
||||
print(msg);
|
||||
if(challenges.has_key(user)):
|
||||
if(msg == str(challenges[user]) or msg == p.number_to_words(challenges[user])):
|
||||
give_tilde(channel, user, time, True);
|
||||
else:
|
||||
give_tilde(channel, user, time, False);
|
||||
del challenges[user]; #delete the user from challenges either way
|
||||
|
||||
|
||||
|
||||
def rollcall(channel):
|
||||
ircsock.send("PRIVMSG "+ channel +" :tildebot reporting! I respond to !tilde !tildescore\n")
|
||||
|
||||
|
@ -117,7 +138,8 @@ def connect(server, channel, botnick):
|
|||
ircsock.send("NICK "+ botnick +"\n")
|
||||
|
||||
joinchan(channel)
|
||||
joinchan("#bots")
|
||||
if(not DEBUG):
|
||||
joinchan("#bots")
|
||||
|
||||
def get_user_from_message(msg):
|
||||
try:
|
||||
|
@ -152,8 +174,11 @@ def listen():
|
|||
|
||||
if ircmsg.find(":!tildescore") != -1:
|
||||
show_tildescore(channel, user)
|
||||
elif ircmsg.find(":!tilde") != -1:
|
||||
give_tilde(channel, user, time)
|
||||
elif ircmsg.find(":!tilde") != -1 and not challenges.has_key(user):
|
||||
challenge(channel, user, time)
|
||||
elif challenges.has_key(user):
|
||||
challenge_response(channel, user, time, messageText)
|
||||
#give_tilde(channel, user, time)
|
||||
|
||||
if ircmsg.find(":!jackpot") != -1:
|
||||
show_jackpot(channel)
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
krowbar&^%79&^%1423251140
|
||||
karlen&^%104&^%1423228714
|
||||
endorphant&^%158&^%1423249581
|
||||
krowbar&^%120&^%1423775651
|
||||
karlen&^%175&^%1423763248
|
||||
endorphant&^%193&^%1423771636
|
||||
jumblesale&^%20&^%1422027769
|
||||
marcus&^%30&^%1423250397
|
||||
marcus&^%51&^%1423688385
|
||||
papa&^%48&^%1423148291
|
||||
epicmorphism&^%5&^%1421937744
|
||||
audy&^%46&^%1423232762
|
||||
audy&^%62&^%1423763125
|
||||
kc&^%18&^%1422326056
|
||||
vilmibm&^%9&^%1423247508
|
||||
cmr&^%18&^%1422919247
|
||||
imt&^%296&^%1423251253
|
||||
cndorphant&^%338&^%1423251253
|
||||
imt&^%492&^%1423769662
|
||||
cndorphant&^%640&^%1423773262
|
||||
rain&^%17&^%1422310975
|
||||
sl2c&^%69&^%1423227648
|
||||
sl2c&^%83&^%1423583083
|
||||
selfsame&^%1&^%1422230012
|
||||
bear&^%91&^%1423203340
|
||||
bear&^%114&^%1423775107
|
||||
coaxial&^%8&^%1422325983
|
||||
joe&^%8&^%1422325983
|
||||
hardmath123&^%4&^%1422325983
|
||||
leni&^%3&^%1422325983
|
||||
cel&^%7&^%1423724883
|
||||
|
|
|
@ -85,10 +85,13 @@ def set_topic(channel, user, time, msg):
|
|||
ircsock.send("TOPIC "+ channel +" :" + msg + "\n")
|
||||
count_topic(channel, user, time, msg)
|
||||
|
||||
def random_topic(channel, user, time):
|
||||
def random_topic(channel, user, time, setTopic=false):
|
||||
with open("randomtopics.txt") as rtopics:
|
||||
msg = random.choice(rtopics.readlines()).strip("\n")
|
||||
set_topic(channel, user, time, msg)
|
||||
if(setTopic):
|
||||
set_topic(channel, user, time, msg)
|
||||
else:
|
||||
ircsock.send("TOPIC "+ channel +" :Suggested Topic: " + msg + "\n")
|
||||
|
||||
def rollcall(channel):
|
||||
ircsock.send("PRIVMSG "+ channel +" :topicbot reporting! I respond to !topic !settopic !randomtopic !thistory\n")
|
||||
|
@ -170,7 +173,9 @@ def listen():
|
|||
topic_score(channel)
|
||||
|
||||
if ircmsg.find(":!randomtopic") != -1:
|
||||
random_topic(channel, user, time)
|
||||
random_topic(channel, user, time, True)
|
||||
if ircmsg.find(":!suggesttopic") != -1:
|
||||
random_topic(channel,user,time, False)
|
||||
|
||||
if ircmsg.find(":!thistory") != -1:
|
||||
topic_history(channel, user, messageText)
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
1422907756&^%krowbar&^%tildebot's score file got wiped but mostly restord. Sorry!
|
||||
1423077842&^%krowbar&^%tildebot now has a jackpot that increases for each non-payout. every request has a chance to hit jackpot!
|
||||
1423607774&^%krowbar&^%WARNING! Anti-botting measures enacted... soon. Un-clever work-arounds will not be tolerated
|
||||
1423771803&^%krowbar&^%Anti-botting measure have been enacted. Un-clever work-arounds will not be tolerated.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
krowbar&^%21&^%25
|
||||
krowbar&^%21&^%27
|
||||
um&^%11&^%8
|
||||
kc&^%0&^%22
|
||||
marcus&^%4&^%1
|
||||
|
|
|
@ -46,7 +46,7 @@ The path [[continues downward|krowbar-FollowPath2]].
|
|||
A squat, [[dirty man|krowbar-ExamineMan]] stands beside the road, mubmling to himself.
|
||||
[[Talk to the man|krowbar-TalkToMan]]
|
||||
<<if $items["translator"]>>[[Use translator with man|krowbar-TalkToManTranslated]]<<endif>>
|
||||
<<if not visited("krowbar-PressButton")>>There is a [[softly glowing stone|krowbar-GetGlowingRock]] on the ground<<endif>>
|
||||
<<if not visited("krowbar-GetGlowingRock")>>There is a [[softly glowing stone|krowbar-GetGlowingRock]] on the ground<<endif>>
|
||||
|
||||
:: krowbar-ExamineMan
|
||||
The man has dirt-stained skin and a broad hat that partially covers his eyes. He mumble viscious nothings to himself.
|
||||
|
@ -80,10 +80,10 @@ This cottage appears to be made from the native trees.
|
|||
|
||||
:: krowbar-EnterCottage [inv]
|
||||
There is a thick layer of dust on everything within the cottage. Very little light is able to make its way inward.
|
||||
<<if not $events["krowbar-cottageOpenWindows"]>>The [[window frames|krowbar-CottageOpenWindows]] have been boarded up.
|
||||
<<if not $events["krowbar-cottageOpenWindows"]>>The window frames have been boarded up.
|
||||
<<if not $items["crowbar"]>> The boards could probably be removed witht the right tool.
|
||||
<<else>>[[Open windows with crowbar|krowbar-CottageOpenWindows]]<<endif>>
|
||||
<<else>>The windows are now letting in enough light to see [[some cupboards|krowbar-CottageSearchcupboards]].<<endif>>
|
||||
<<else>>The windows are now letting in enough light to see [[some cupboards|krowbar-CottageSearchCupboards]].<<endif>>
|
||||
[[Leave cottage|krowbar-FollowPath2]]
|
||||
|
||||
:: krowbar-CottageOpenWindows
|
||||
|
|
Loading…
Reference in New Issue