diff --git a/Code/irc/banterbot.py b/Code/irc/banterbot.py index 956e94d..4c35bc6 100755 --- a/Code/irc/banterbot.py +++ b/Code/irc/banterbot.py @@ -60,12 +60,6 @@ args = parser.parse_args() p = inflect.engine() - -def joinchan(chan): - ircsock.send("JOIN " + chan + "\r\n") - ircsock.send("JOIN #bots\r\n") - - def hello(): util.sendmsg(ircsoc, channel, "Hello!") @@ -336,86 +330,88 @@ def rollcall(channel): def listen(botnick): - while 1: + while 1: # loop forever + try: + ircmsg = ircsock.recv(2048).decode('utf-8') + ircmsg = ircmsg.strip("\n\r") - ircmsg = ircsock.recv(2048).decode('utf-8') - ircmsg = ircmsg.strip("\n\r") + if ircmsg[:4] == "PING": + util.ping(ircsock, ircmsg) + continue - if ircmsg[:4] == "PING": - util.ping(ircsock, ircmsg) + formatted = util.format_message(ircmsg) - formatted = util.format_message(ircmsg) + if "" == formatted: + continue - if "" == formatted: - continue + # print formatted - # print formatted + _time, user, _command, channel, messageText = formatted.split("\t") - _time, user, _command, channel, messageText = formatted.split("\t") + if ircmsg.find("#banter") != -1 or ircmsg.find("#bantz") != -1: + score_banter(channel, user, messageText) - if ircmsg.find("#banter") != -1 or ircmsg.find("#bantz") != -1: - score_banter(channel, user, messageText) + if ircmsg.find(":!newbanter") != -1: + get_new_banter(channel, user) - if ircmsg.find(":!newbanter") != -1: - get_new_banter(channel, user) + if ircmsg.find(":!rhymes") != -1: + get_rhymes(channel, user, messageText) - if ircmsg.find(":!rhymes") != -1: - get_rhymes(channel, user, messageText) + if ircmsg.find(":!define") != -1: + define_word(channel, user, messageText) - if ircmsg.find(":!define") != -1: - define_word(channel, user, messageText) + if ircmsg.find(":!rainbow") != -1: + make_rainbow(channel, user, messageText) - if ircmsg.find(":!rainbow") != -1: - make_rainbow(channel, user, messageText) + if ircmsg.find(":!welch") != -1: + get_welch(channel) - if ircmsg.find(":!welch") != -1: - get_welch(channel) + if ircmsg.find(":!evil") != -1: + get_evil(channel) - if ircmsg.find(":!evil") != -1: - get_evil(channel) + if ircmsg.find(":!kjp") != -1: + get_tumble("http://kingjamesprogramming.tumblr.com", channel) - if ircmsg.find(":!kjp") != -1: - get_tumble("http://kingjamesprogramming.tumblr.com", channel) + if ircmsg.find(":!help") != -1: + get_tumble("http://thedoomthatcametopuppet.tumblr.com", channel) - if ircmsg.find(":!help") != -1: - get_tumble("http://thedoomthatcametopuppet.tumblr.com", channel) + if ircmsg.find(":!xkcd") != -1: + get_xkcd(channel, messageText) + if ircmsg.find(":!wiki-philosophy") != -1: + get_wphilosophy(channel, messageText) - if ircmsg.find(":!xkcd") != -1: - get_xkcd(channel, messageText) - if ircmsg.find(":!wiki-philosophy") != -1: - get_wphilosophy(channel, messageText) + if ircmsg.find(":!figlet") != -1: + figlet(channel, messageText[8:]) - if ircmsg.find(":!figlet") != -1: - figlet(channel, messageText[8:]) + if ircmsg.find(":!toilet") != -1: + toilet(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(":!acronym") != -1: - get_acronym(channel, messageText[9:]) + if ircmsg.find(":!whosaid") != -1: + get_whosaid(channel, messageText[9:]) - if ircmsg.find(":!whosaid") != -1: - get_whosaid(channel, messageText[9:]) + if ircmsg.find(":!notice") != -1: + get_notice(user, channel) - if ircmsg.find(":!notice") != -1: - get_notice(user, channel) + if ircmsg.find(":!water") != -1: + get_water(user, channel, messageText[7:], botnick) - if ircmsg.find(":!water") != -1: - get_water(user, channel, messageText[7:], botnick) + if ircmsg.find(":!rollcall") != -1: + rollcall(channel) - if ircmsg.find(":!rollcall") != -1: - rollcall(channel) + if ircmsg.find(":" + botnick + ":") != -1: + mug_off(channel) - if ircmsg.find(":" + botnick + ":") != -1: - mug_off(channel) + sys.stdout.flush() + time.sleep(1) - if ircmsg[:4] == "PING": - util.ping(ircsock, ircmsg) - - sys.stdout.flush() - time.sleep(1) + except socket.timeout: + return # ABORT! We got kicked or something else weird happened -ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -util.connect(ircsock, args) -listen(args.nick) +# ROOT: i commented this out until it stops pegging the CPU. +#ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +#util.connect(ircsock, args) +#listen(args.nick) diff --git a/Code/irc/puzzle.py b/Code/irc/puzzle.py index 8595fc9..ba35d14 100644 --- a/Code/irc/puzzle.py +++ b/Code/irc/puzzle.py @@ -20,17 +20,26 @@ def make_puzzle(obfuscate=True): "Counter-cnd0rphant measures: ", "Cosn0k countermeasures: ", "Anti-tilde7hief precautions: ", + "Pro-l0gin challenge: ", + "Riddle me this: ", + "Would you like to play a game? ", + "How about this? " ] ) 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", + "Ask wiz3bot what is", + "Does anybody know", + "Who knows", + "Guess what", + "Calculate", + "Find out" ] ) puzzle += " " @@ -107,7 +116,7 @@ def make_puzzle(obfuscate=True): if let1_ord + var1 > ord("z"): let1_ord -= var1 answer = chr(let1_ord + var1) - puzzle += "What letter comes {} letters after '{}'".format( + puzzle += "letter comes {} letters after '{}'".format( p.number_to_words(var1), chr(let1_ord) ) @@ -116,7 +125,7 @@ def make_puzzle(obfuscate=True): if let1_ord - var1 < ord("a"): let1_ord += var1 answer = chr(let1_ord - var1) - puzzle += "What letter comes {} letters before '{}'".format( + puzzle += "letter comes {} letters before '{}'".format( p.number_to_words(var1), chr(let1_ord) ) @@ -126,7 +135,7 @@ def make_puzzle(obfuscate=True): obfuscate = False elif roll == 10: answer = str(min(var1, var2, var3, var4)) - puzzle += "What is the {} of {}, {}, {}, and {}".format( + puzzle += "the {} of {}, {}, {}, and {}".format( random.choice(["smallest", "lowest"]), p.number_to_words(var1), p.number_to_words(var2), @@ -136,7 +145,7 @@ def make_puzzle(obfuscate=True): elif roll == 11: answer = str(max(var1, var2, var3, var4)) - puzzle += "What is the {} of {}, {}, {}, and {}".format( + puzzle += "the {} of {}, {}, {}, and {}".format( random.choice(["biggest", "largest"]), p.number_to_words(var1), p.number_to_words(var2), @@ -151,10 +160,13 @@ def make_puzzle(obfuscate=True): answer, puzzle = dict_puzzle.get_anagram() obfuscate = False - puzzle += "?" + # Add a question mark on the end of the question + if puzzle[-1] != "?": + puzzle += "?" + if obfuscate == True: for _ in range(fuzz_amount): - idx = random.randrange(len(puzzle) - 1) # get between 0 and string length + idx = random.randrange(len(puzzle) - 2) # get between 0 and string length (except the ? mark) puzzle = "".join( [puzzle[0:idx], chr(random.randint(33, 126)), puzzle[idx + 1 :]] ) diff --git a/Code/irc/tildescores.txt b/Code/irc/tildescores.txt index b31ad93..712bcbf 100644 --- a/Code/irc/tildescores.txt +++ b/Code/irc/tildescores.txt @@ -1,10 +1,10 @@ -krowbar&^%2507&^%1541083807 +krowbar&^%2590&^%1542633864 karlen&^%498&^%1527613440 -endorphant&^%682&^%1444775660 -jumblesale&^%24&^%1426171214 +endorphant&^%801&^%1444775660 +jumblesale&^%25&^%1426171214 marcus&^%2578&^%1538071912 papa&^%181&^%1474509971 -epicmorphism&^%6&^%1540035522 +epicmorphism&^%7&^%1541346396 audy&^%83&^%1504564254 kc&^%28&^%1480730333 vilmibm&^%24&^%1540452691 @@ -23,13 +23,11 @@ cel&^%11&^%1430162676 quote_bots&^%3&^%1424737471 bave&^%1&^%1427591141 scellef&^%13&^%1428707074 -cndorphbot&^%11&^%1441299746 +cndorphbot&^%20&^%1441299746 reppard&^%11&^%1437512059 jesse&^%6&^%1437569027 khoi&^%3&^%1438044039 sanqui&^%22&^%1474904633 -endorphan&^%119&^%1519838766 -cndorphbo&^%9&^%1466591324 santi&^%3&^%1447873216 insom&^%2&^%1524182067 tahnok&^%4&^%1464913072 @@ -39,14 +37,14 @@ synergian&^%22&^%1458152889 dheeraj&^%5&^%1456489270 demobot&^%6&^%1454439605 premysl&^%65&^%1461768606 -minerobbe&^%269&^%1530328006 +minerobber&^%279&^%1542508589 xkeeper&^%201&^%1539193279 cosnok&^%807&^%1508878859 escobar&^%1&^%1475431401 amicabot&^%30&^%1481225205 caff&^%1030&^%1540040705 -kadin&^%17&^%1540410522 -desvox&^%34&^%1539809505 +kadin&^%18&^%1541514839 +desvox&^%36&^%1542379512 mankins&^%3&^%1480211581 cinch&^%2&^%1480454755 caffbot&^%969&^%1532662872 @@ -54,12 +52,12 @@ evilbot&^%4&^%1480693919 tybaltcat&^%7&^%1481076625 minerbot&^%146&^%1520382015 mio&^%347&^%1529720473 -archangel&^%479&^%1538689239 -tehfraga&^%669&^%1540933836 +archangelic&^%482&^%1538689239 +tehfraga&^%671&^%1542490496 sushi&^%10&^%1493253212 troido&^%302&^%1538991819 -gamebot&^%199&^%1538991833 -nilaky&^%1445&^%1541047850 +gamebot&^%203&^%1542505151 +nilaky&^%1501&^%1542491307 bucket&^%103&^%1507931139 lolbot&^%1&^%1502568407 m455&^%12&^%1512076715 @@ -72,11 +70,11 @@ pinhook&^%8&^%1509744722 emfor&^%3&^%1509671353 k2l8m11n2&^%11&^%1510932395 sacredpix&^%3&^%1522082931 -deltawitc&^%3267&^%1538609961 -login&^%2446&^%1541083668 +deltawitch&^%3304&^%1542620562 +login&^%2633&^%1542634018 kelpiebot&^%3&^%1513101957 unreal&^%2&^%1534387108 -tildethie&^%5612&^%1538710812 +tildethief&^%7421&^%1542467787 kinsey&^%26&^%1520446672 testgameb&^%2&^%1537604954 erin&^%2&^%1517681999 @@ -86,14 +84,13 @@ ubergeek&^%63&^%1530410162 silver&^%9&^%1519333029 equa&^%53&^%1534373756 audiodude&^%2&^%1519453927 -jumblesal&^%1&^%1519746512 whimsy&^%47&^%1529678733 -wangofett&^%200&^%1539436703 +wangofett&^%206&^%1542635705 saturn597&^%3&^%1521429369 cwmccabe&^%2&^%1521598124 lucidiot&^%28&^%1526201925 tracer&^%1&^%1521744878 -jan6&^%1088&^%1540831048 +jan6&^%1116&^%1542487863 jan&^%10&^%1522319160 etathetae&^%3&^%1522937843 eeeeeta&^%52&^%1540361066 @@ -104,18 +101,16 @@ carbon&^%9&^%1524135505 ne1&^%7&^%1524024485 Halian&^%32&^%1528360263 lunasspec&^%4&^%1524164784 -bowlercap&^%3&^%1524165068 -littlebig&^%46&^%1535927253 +littlebigly&^%49&^%1535927253 severak&^%17&^%1540822455 ralph&^%4&^%1526980620 -benjaminw&^%526&^%1538599664 -von&^%407&^%1540980176 +von&^%425&^%1542623529 ensis&^%1750&^%1539356542 simon&^%26&^%1527937489 -benharri&^%2055&^%1541052332 +benharri&^%2277&^%1542609742 cpb&^%3&^%1528930564 -calmbit&^%156&^%1540942599 -wisebot&^%5613&^%1539612163 +calmbit&^%160&^%1542220635 +wisebot&^%5652&^%1542183214 paannd_a&^%2&^%1529617165 nincollin&^%6&^%1531186900 x4464&^%1&^%1532028546 @@ -123,22 +118,23 @@ pounce&^%19&^%1532133325 von_&^%5&^%1532502104 livix&^%7&^%1533603142 ben&^%3&^%1533767627 -npa&^%84&^%1541066354 +npa&^%139&^%1542620546 ezo&^%6&^%1533883842 aliasless&^%36&^%1541001821 -kirch&^%51&^%1541006239 +kirch&^%213&^%1542401397 root&^%2&^%1535558514 byte&^%5&^%1536416308 qbe&^%7&^%1537850181 informati&^%3&^%1536733938 h00fi&^%1&^%1537050053 -fantoro&^%7&^%1540854244 -tildethief&^%1051&^%1541084586 -benjaminwil&^%9&^%1541018886 -deltawitch&^%12&^%1540915500 -archangelic&^%2&^%1540574433 +fantoro&^%26&^%1542538478 +benjaminwil&^%550&^%1542409435 diodelass&^%3&^%1539382302 -minerobber&^%4&^%1540467667 brendantcc&^%3&^%1539908223 -dozens&^%16&^%1540784558 -bowlercaptain&^%3&^%1540926135 +dozens&^%21&^%1542222479 +bowlercaptain&^%6&^%1540926135 +nicole&^%6&^%1541276844 +midnightpupil&^%12&^%1542216854 +ahriman&^%79&^%1542617214 +tunas&^%37&^%1542583679 +khuxkm&^%2&^%1542566334