def reward(self): self.poll_users() for user in self.users: score.add(user, config.get('random-points')) c.say("Random giveaway of points! " + str(config.get('random-points')) + " points given to:") c.say(" ".join(self.users))
def rick_roll(nick, name): if not v.getrank(nick) == 4: name = nick c.whisper("Well done, " + nick + ".", nick) rickroll = [ "We're no strangers to love", "You know the rules, and so do I", "A full commitment's what I'm thinking of", "You wouldn't get this from any other guy", "I just wanna tell you how I'm feeling", "Gotta make you understand", "Never gonna give you up", "Never gonna let you down", "Never gonna run around and desert you", "Never gonna make you cry", "Never gonna say goodbye", "Never gonna tell a lie and hurt you", "We've known each other for so long", "Your heart's been aching, but", "You're too shy to say it", "Inside, we both know what's been going on", "We know the game and we're gonna play it", "And if you ask me how I'm feeling", "Don't tell me you're too blind to see", "Never gonna give you up", "Never gonna let you down", "Never gonna run around and desert you", "Never gonna make you cry", "Never gonna say goodbye", "Never gonna tell a lie and hurt you" ] for line in rickroll: if nick == "Manyman": c.whisper("< " + name + " > " + f.random() + line, nick) else: c.say("< " + name + " > " + f.random() + line) time.sleep(2) c.say(f.PINK + "This Rick-Roll brought to you by " + f.CYAN + nick + f.PINK + ".")
def confirm_account(nick): ACC_CHECKED = True if config.get('use-json-whitelist'): if not is_white_listed(nick): c.say("Kicking user: "******". Reason: Not on the whitelist.") #c.kick(nick, "NotWhitelisted") else: c.say(nick + " is whitelisted.")
def handle(self, nick, val): if val > config.get("kick"): connect.kick(nick, "Spamming") connect.say(f.YELLOW + "User " + f.RED + nick + f.YELLOW + " was kicked for spamming.") log("User: "******" was kicked for spamming", m_type="SPAMHANDLR", reset=False) # ACTION_LOG.info(Fore.RED + 'KCK' + Fore.RESET + ' User: '******' was kicked for spamming') del self.FLOOD[nick] elif val > config.get("warn"): connect.msg(f.YELLOW + "Please slow down with your messages, or else you'll be kicked.", nick)
def guess(self, guess, nick): if self.check(guess): c.say(f.GREEN + self.f + nick + f.WHITE + " got the answer! " + f.ORANGE + "+" + str(config.get('trivia-points')) + " points!") self.current = "" score.add(nick, config.get('trivia-points')) else: c.msg(self.f + "Incorrect!", nick) return True
def _runnable(self): nick = 'Oracle' while True: msg = replace(raw_input()) cmd = False for char in config.get('command-chars'): if msg.startswith(char): # make sure to only get rid of one '?' msg = msg.split(char, 1)[1] oracle.process_cmd(nick, msg) cmd = True if not cmd: say(msg)
def _runnable(self): nick = "Oracle" while True: msg = replace(raw_input()) cmd = False for char in config.get("command-chars"): if msg.startswith(char): # make sure to only get rid of one '?' msg = msg.split(char, 1)[1] oracle.process_cmd(nick, msg) cmd = True if not cmd: say(msg)
def cb(ask, nick): """Asks cleverbot a question, and logs and says the response (broken). Cleverbot API has been discontinued and so this will probably no longer work. """ if config.get('cleverbot'): cbot = cleverbot.Session() response = cbot.Ask(" ".join(ask)) ACTION_LOG.info(Fore.CYAN + "CBT" + Fore.RESET + " " + response) c.say(nick + ": " + response) else: c.msg("Cleverbot is currently disabled.", nick)
def handle(self, nick, val): if val > config.get('kick'): connect.kick(nick, "Spamming") connect.say(f.YELLOW + 'User ' + f.RED + nick + f.YELLOW + ' was kicked for spamming.') log('User: '******' was kicked for spamming', m_type='SPAMHANDLR', reset=False) #ACTION_LOG.info(Fore.RED + 'KCK' + Fore.RESET + ' User: '******' was kicked for spamming') del self.FLOOD[nick] elif val > config.get('warn'): connect.msg( f.YELLOW + 'Please slow down with your messages, or else you\'ll be kicked.', nick)
def _runnable(self): if not self.current == "": c.say(self.f + "Nobody got it! New round.") self.current = self.get_question() self.answer = self.get_answer() c.say(self.f + self.current + " (" + str(len(self.answer.split(" "))) + ")") c.say(self.f + "Use ?a [answer] to answer")
def process_cmd(nick, msg): """Splits the message, processes the commands and does all the relevant functions required. Should reverse the 'rank' if statements but it's not much of a problem. """ cmd = msg.split(" ") rank = v.getrank(nick) if len(cmd) == 1: log("*" + cmd[0].capitalize() + "* | nick: " + nick, m_type="COMMAND", colour=Fore.CYAN) #ACTION_LOG.info(Fore.MAGENTA + "COMMAND " + Fore.RESET + " " + cmd[0] + " | nick: " + nick) else: log("*" + cmd[0].capitalize() + "* | args: " + " ".join(cmd[1:]) + " | nick: " + nick, m_type="COMMAND", colour=Fore.CYAN) #ACTION_LOG.info(Fore.MAGENTA + "COMMAND " + Fore.RESET + " " + cmd[0] + " | args: " + " ".join(cmd[1:]) + " | nick: " + nick) try: # regular user # rank = 1 if rank >= 1: #! emotes !# if cmd[0] == "fliptable": c.say("(╯°□°)╯︵ ┻━┻") elif cmd[0] == "puttableback": c.say("┬─┬ ノ( ゜-゜ノ)") elif cmd[0] == "ohyou": c.say("¯_(ツ)_/¯") elif cmd[0] == "FLIPTABLE": c.say("(ノಠ益ಠ)ノ彡┻━┻") elif cmd[0] == "fff": c.say("ლ(ಠ益ಠლ)") elif cmd[0] == "disapprove": c.say("ಠ_ಠ") elif cmd[0] == "crie": c.say("ಥ_ಥ") elif cmd[0] == "lenny": c.say("( ͡° ͜ʖ ͡°)") elif cmd[0] == "dongers": c.say("ヽ༼ຈل͜ຈ༽ノ") elif cmd[0] == "raise": c.say("ヽ༼ຈل͜ຈ༽ノ") elif cmd[0] == "butterfly": c.say("Ƹ̵̡Ӝ̵̨̄Ʒ") elif cmd[0] == "partytime": c.say("┏(-_-)┛┗(-_- )┓┗(-_-)┛┏(-_-)┓") elif cmd[0] == "fliptables": c.say("┻━┻︵ \(°□°)/ ︵ ┻━┻") elif cmd[0] == "polarbear": c.say("ˁ˚ᴥ˚ˀ") elif cmd[0] == "gun": c.say("︻╦╤─") elif cmd[0] == "pirate": c.say("✌(◕‿-)✌") elif cmd[0] == "happybirthday": c.say("¸¸♬·¯·♩¸¸♪·¯·♫¸¸Happy Birthday To You¸¸♬·¯·♩¸¸♪·¯·♫¸¸") elif cmd[0] == "sunglasses": c.say("( •_•) ( •_•)>⌐■-■ (⌐■_■)") elif cmd[0] == "rage": c.say("t(ಠ益ಠt)") elif cmd[0] == "cards": c.say("[♥]]] [♦]]] [♣]]] [♠]]]") elif cmd[0] == "gimme": c.say("༼ つ ◕_◕ ༽つ") elif cmd[0] == "monocle": c.say("ಠ_ರೃ") elif cmd[0] == "ghost": c.say("‹’’›(Ͼ˳Ͽ)‹’’›") elif cmd[0] == "why": c.say("ლ(`◉◞౪◟◉‵ლ)") elif cmd[0] == "praise": c.say("し(*・∀・)/♡\(・∀・*)ノ") elif cmd[0] == "lennyy": c.say(" ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з=( ͡° ͜ʖ ͡°)=ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿ ") # tears can be potentially dangerous, limited to admin + elif cmd[0] == "tears" and rank >= 3: c.say(" Ỏ̷͖͈̞̩͎̻̫̫̜͉̠̫͕̭̭̫̫̹̗̹͈̼̠̖͍͚̥͈̮̼͕̠̤̯̻̥̬̗̼̳̤̳̬̪̹͚̞̼̠͕̼̠̦͚̫͔̯̹͉͉̘͎͕̼̣̝͙̱̟̹̩̟̳̦̭͉̮̖̭̣̣̞̙̗̜̺̭̻̥͚͙̝̦̲̱͉͖͉̰̦͎̫̣̼͎͍̠̮͓̹̹͉̤̰̗̙͕͇͔̱͕̭͈̳̗̭͔̘̖̺̮̜̠͖̘͓̳͕̟̠̱̫̤͓͔̘̰̲͙͍͇̙͎̣̼̗̖͙̯͉̠̟͈͍͕̪͓̝̩̦̖̹̼̠̘̮͚̟͉̺̜͍͓̯̳̱̻͕̣̳͉̻̭̭̱͍̪̩̭̺͕̺̼̥̪͖̦̟͎̻̰_á»") #! other !# elif cmd[0] == "rps": target = cmd[1] global rps rps = games.RockPaperScissors(nick, target) c.msg(nick + " has challenged you to a game of rock, paper scissors.", target) c.msg("To participate, use " + f.BLUE + "/msg Oracle ?[rock/paper/scissors] (use /imsg if you're in-game)", target) c.msg("You have 30 seconds.", target) c.msg("You have challenged " + target + " to a game of rock, paper scissors.", nick) c.msg("To participate, use " + f.BLUE + "/msg Oracle ?[rock/paper/scissors] (use /imsg if you're in-game)", nick) c.msg("You have 30 seconds.", nick) elif cmd[0] == "rock" or cmd[0] == "paper" or cmd[0] == "scissors": if rps != None: if rps.guess(cmd[0], nick): c.msg("Decision accepted", nick) c.msg("Your opponent has made a decision", rps.get_opponent(nick)) else: c.msg("You're not in this RPS game!", nick) else: c.msg("There is no RPS game at the moment.", nick) elif cmd[0] == "a": global trivia trivia.guess(cmd[1:], nick) elif cmd[0] == "help" or cmd[0] == "what": if(len(cmd) < 2): help_(nick, "no") else: help_(nick, cmd[1]) elif cmd[0] == "cb": cb(cmd[1:], nick) elif cmd[0] == "pick": c.say(nick + ": " + misc.pick(cmd[1:])) elif cmd[0] == "diamonds": if config.get('rick-roll'): gags.rick_roll(nick, cmd[1]) else: c.msg(f.WHITE + "64 diamonds have been credited to the Minecraft account " + f.RED + nick + f.WHITE + ".", nick) time.sleep(5) c.msg("Just kidding.", nick) c.msg("This command has been disabled in the config.", nick) elif cmd[0] == "ayylmao": c.say("http://puu.sh/6wo5D.png") elif cmd[0] == "score": if cmd[1] == "check": if len(cmd) > 2 and rank >= 3: c.msg(cmd[2] + " has " + str(score.get(cmd[2])) + " points.", nick) else: c.msg("Your have " + str(score.get(nick)) + " points.", nick) elif cmd[1] == "top": list = score.get_leader_boards() amount = int(cmd[2]) if len(cmd) > 2 else 5 i = 1 for line in list: c.msg(str(i) + ". " + line[0] + " - " + str(line[1]), nick) i += 1 if i > amount: break elif cmd[0] == "resolve": data = socket.gethostbyname_ex(" ".join(cmd[1:])) c.say(" ".join(cmd[1:]) + " resolved to " + repr(data[2])) #! server !# elif cmd[0] == "events": results = e.get() if results: c.say(f.BOLD + "Event: " + results[0] + " || " + f.BOLD + "Time" + f.BOLD + ": " + results[1] + " UTC") else: c.say(f.BOLD + "No events found" + f.BOLD + " - there may be none planned.") elif cmd[0] == "utc": c.say(e.utc() + " UTC") elif cmd[0] == "nether": c.msg(misc.netherposition(int(cmd[1]), int(cmd[2]), int(cmd[3])), nick) elif cmd[0] == "overworld": c.msg(misc.overworldposition(int(cmd[1]), int(cmd[2]), int(cmd[3])), nick) #! personal !# elif cmd[0] == "mail": try: if cmd[1].lower() == "check": if not m.check(nick): c.msg("You have no mail.", nick) else: c.msg("Use ?mail read [mail]: "+ ", ".join(m.check(nick)), nick) elif cmd[1].lower() == "send": text = " ".join(cmd[4:]) if m.send(nick, cmd[2], cmd[3], text): c.msg("Message sent.", nick) else: c.msg("Message failed to send.", nick) elif cmd[1].lower() == "read": c.msg(m.read(nick, cmd[2]), nick) elif cmd[1].lower() == "delete" or cmd[1].lower() == "del": if m.delete(nick, cmd[2]): c.msg("Message deleted.", nick) else: c.msg("Message not deleted.", nick) else: c.msg("Usage: ?mail [check|send|read|delete]", nick) except: traceback.print_exc() c.msg("Usage: ?mail [check|send|read|delete]", nick) elif cmd[0] == "notes": try: if cmd[1].lower() == "new": text = " ".join(cmd[3:]) if n.new(cmd[2], text): c.msg("Note successfully created.", nick) else: c.msg("Note already exists with that file name", nick) elif cmd[1].lower() == "delete": if n.delete(cmd[2]): c.msg("Note successfully deleted.", nick) else: c.msg("Deletion failed", nick) elif cmd[1].lower() == "edit": text = " ".join(cmd[3:]) n.edit(cmd[2], text[1]) elif cmd[1].lower() == "listall": c.msg(" ".join(n.listall()), nick) elif cmd[1].lower() == "search" or cmd[1].lower() == "list": c.msg(" ".join(n.find(cmd[2])), nick) elif cmd[1].lower() == "get": c.msg(nick + ": " + n.get(cmd[2]), nick) else: c.msg("Usage: ?notes [new|delete|edit|listall|search|get]", nick) except: traceback.print_exc() c.msg("Usage: ?notes [new|delete|edit|listall|search|get]", nick) elif cmd[0] == "eval": try: sm = " ".join(cmd[1:]) c.say(sm + " = " + str(eval(sm))) except: traceback.print_exc() else: c.msg("Seems like you don't have access to these commands. Message an admin for help.", nick) #! moderator !# # rank = 2 if rank >= 2: if cmd[0] == "say": c.say(format.replace(" ".join(cmd[1:]))) elif cmd[0] == "ATTENTION": global ATTENTION ATTENTION = True c.getusers() elif cmd[0] == "ban" : v.setvar(nick, cmd[1], "rank", 0) c.msg("User: "******" has been banned.", nick) elif cmd[0] == "kick": if len(cmd) < 3: c.kick(cmd[1], "") c.msg("User kicked.", nick) else: c.kick(cmd[1], " ".join(cmd[2:])) c.msg("User kicked for " + " ".join(cmd[2:]) + ".", nick) #! admin !# # rank = 3 if rank >= 3: if cmd[0] == "close": c.stop(nick) EXIT = True elif cmd[0] == "restart" : c.restart(nick) elif cmd[0] == "reload": log("Reload issued by " + nick, m_type="RELOAD", colour=Fore.YELLOW, reset=False) reload_() c.say(f.YELLOW + "Reload complete.") elif cmd[0] == "sreload": reload_() c.msg(f.YELLOW + "Silent reload complete.", nick) elif cmd[0] == "setrank": v.setvar(cmd[1], "rank", int(cmd[2])) c.msg(cmd[1] + "'s rank set to " + cmd[2] + ".", nick) elif cmd[0] == "mode": c.mode(cmd[1:]) elif cmd[0] == "getrank": c.msg(cmd[1] + "'s rank is " + str(v.getvar(cmd[1], "rank")) + ".", nick) elif cmd[0] == "flood": if cmd[1] == "reset": spam.clear() c.msg("Cleared FLOOD dictionary", nick) elif cmd[1] == "decrement": spam.decrement() c.msg("FLOOD decrement performed", nick) elif cmd[0] == "randompoints": if cmd[1] == "run": randompoints.poll_users() time.sleep(1) randompoints.reward() elif cmd[0] == "trivia": if cmd[1] == "new": c.say("[" + f.PURPLE + "Trivia" + f.WHITE + "] New round started by " + f.BLUE + nick) trivia._runnable() elif cmd[1] == "off": trivia.disable() c.say("[" + f.PURPLE + "Trivia" + f.WHITE + "] Disabled by " + f.BLUE + nick) elif cmd[1] == "on": if trivia._getdisabled(): del trivia trivia = games.trivia() c.say("[" + f.PURPLE + "Trivia" + f.WHITE + "] Re-enabled by " + f.BLUE + nick) elif cmd[1] == "info": c.msg(trivia.getinfo(), nick) elif cmd[0] == "score": if cmd[1] == "reset": if score.reset(cmd[2]): c.msg("Successfully reset " + cmd[2] + "'s score.", nick) else: c.msg("Reset failed.", nick) elif cmd[1] == "add": points = score.add(cmd[2], cmd[3]) if not points: c.msg("Points failed to add.", nick) else: c.msg("Sucessfully added points, " + cmd[2] + " now has " + str(points) + " points.", nick) elif cmd[0] == "ignore": try: IGNORE_LIST.append(cmd[1]) c.msg("Successfuly added " + cmd[1] + " to ignore list.", nick) except: c.msg("Ignore unsuccessful.", nick) elif cmd[0] == "pardon": try: del ingore_list[cmd[1]] c.msg("Successfully pardoned " + cmd[1] + ".", nick) except: c.msg("Pardon unsuccessful. Perhaps " + cmd[1] + " is not currently being ignored.", nick) #! developer !# # rank = 4 if rank >= 4: if cmd[0] == "makevar": target = cmd[1] if(v.makevarfile(target)): ACTION_LOG.info(Fore.RED + "!!!" + Fore.RESET + " - New var file created for " + target + " by " + nick) c.msg("VAR file successfully created for " + target, nick) else: ACTION_LOG.info(Fore.RED + "!!!" + Fore.RESET + " - Var file creation failed - " + nick) c.msg("VAR file failed to create for " + target, nick) elif cmd[0] == "getvar": response = v.getvar( cmd[1], cmd[2]) c.msg("VAR: %s = %s" % (cmd[2], response),nick) elif cmd[0] == "listvar": response = v.listvar(cmd[1]) c.msg(response, nick) elif cmd[0] == "setvar": if(v.setvar(cmd[1], cmd[2], int(cmd[3]))): c.msg("VAR: %s set to %s for %s" % (cmd[2], cmd[3], cmd[1]), nick) else: c.msg("Setting of variable failed.", nick) elif cmd[0] == "deletevar": if(v.deletevarfile(cmd[1])): c.msg("VAR file successfully deleted.", nick) else: c.msg("VAR file deletion failed.", nick) elif cmd[0] == "resetvar": target = cmd[1] if(v.deletevarfile(target)): c.msg("VAR file successfully deleted.", nick) else: c.msg("VAR file deletion failed.") if(v.makevarfile(target)): ACTION_LOG.info(Fore.RED + "!!!" + Fore.RESET + " - New var file created for " + target + " by " + nick) c.msg("VAR file successfully created for " + target, nick) else: ACTION_LOG.info(Fore.RED + "!!!" + Fore.RESET + " - Var file creation failed - " + nick) c.msg("VAR file failed to create for " + target, nick) elif cmd[0] == "formats" : c.say(vars(f)) elif cmd[0] == "cls": os.system("cls") elif cmd[0] == "join": join(nick) elif cmd[0] == "joinn": join(cmd[1]) elif cmd[0] == "raw": c.raw(cmd[1:]) elif cmd[0] == "config": if cmd[1] == "reload": try: config.reload() c.msg("Config reloaded.", nick) except: traceback.print_exc() c.msg("Error reloading config", nick) elif cmd[1] == "set": try: config.set(cmd[2], cmd[3:]) c.msg("Config set.", nick) except: traceback.print_exc() c.msg("Error setting config", nick) elif cmd[1] == "get": try: c.msg(config.get(cmd[2]), nick) except: traceback.print_exc() c.msg("Error getting config", nick) elif cmd[0] == "testlog": log("No string test") log("Action test", l_type='action', m_type="TESTLOG", colour=Fore.GREEN) if len(cmd) > 1: log(' '.join(cmd[1:]), colour=Fore.GREEN, m_type="TESTLOG") elif cmd[0] == "exec": try: exec " ".join(cmd[1:]) except: c.say(traceback.print_exc()) except SystemExit: return except: # any and every error will throw this traceback.print_exc() c.msg("Oops! Something went wrong. Please contact an admin for help.",nick)
def poll_users(self): c.say("~players") c.getusers()
def _runnable(self): text = self.result() c.say(self.p1 + ": " + self.g1 + ", " + self.p2 + ": " + self.g2) c.say(f.YELLOW + text)
def get_response(nick, message): if(message.lower() == "nope nope"): c.say("nope.avi - http://www.youtube.com/watch?v=gvdf5n-zI14") elif(message.lower() == "nice"): c.say("nice - http://www.youtube.com/watch?v=jjtkMCLRf-M") elif(message.lower() == "alrighty then"): c.say("alrighty then - http://www.youtube.com/watch?v=hS1okqbnePQ") elif(message.lower() == "noice"): c.say("noice - http://www.youtube.com/watch?v=rQnYi3z56RE") elif(message.lower() == "sad"): c.say("sad - http://www.youtube.com/watch?v=CwK74w4VwgQ") elif(message.lower() == "hello my baby"): c.say("hello my baby - http://www.youtube.com/watch?v=49EoV50oba0") elif(message.lower() == "thanks oracle"): c.say(pick(("No worries mate!","No problem!","T'was a pleasure.","You're welcome!"))) elif(message.lower() == "nice work oracle" or message.lower() == "well done oracle" or message.lower() == "good job oracle"): c.say(pick(("Thanks man!","Thanks, appreciate it.","Why, thank you sir!"))) elif(message.lower() == "bye" or message.lower() == "later" or message.lower() == "cya" or message.lower() == "brb"): c.say(pick(("Ciao!","Adios!","Tsch�ss!","Despedida!","Hasta la Vista!","Au Revoir!","Farewell!","Cya!"))) elif(message.lower().startswith('should ') and '?' in message): c.say(pick(('Yes.','No.','It depends.','Please ask again.','No, f**k you'))) elif(message.lower().startswith('will ') and '?' in message): c.say(pick(('Of course!','Never.','No.','Yes.','Maybe.','Impossible.','Never going to happen, buster.'))) elif('f**k' in message.lower() and 'you' in message.lower() and 'oracle' in message.lower()): c.say(pick(('That\'s not very nice!','F**k you too, my good sir!','Come at me bro!','Do you want a punch-on?!'))) elif("alrighty" in message): c.say("Alrightyroo") elif(message.lower() == "welcome"): c.say("Welcome " + nick + " to the server!") elif(message.lower() == "oracle"): c.say("Yes?") elif(message.lower() == "oh sweet baby jesus"): c.say("http://gfycat.com/ScientificUnawareAmericanwigeon")
def print(s): c.say("OUT:" + s) log(s, m_type="PRINT", colour=Fore.CYAN)
def main(socket): """Main loop, everything happens through this loop Data received from s is placed in the readbuffer, which is then split into lines that are iterated over as incoming messages. Returning false will close Oracle, and true will reload oracle.py """ readbuffer = "" global RELOAD global EXIT RELOAD = EXIT = False if config.get('trivia'): global trivia trivia = games.Trivia() if config.get('command-line'): global commandline commandline = input.CommandLine() if config.get('random-points'): global randompoints randompoints = games.RandomPoints() while True: try: # get messages from the server readbuffer = readbuffer + socket.recv(1024) except Exception: # this only happens when the server throttles the connection log("Cannot connect, throttled by server.", m_type="WARNING", colour=Fore.RED, reset=False) log("Will try again in 20 seconds...", m_type="WARNING", colour=Fore.RED, reset=False) time.sleep(20) # reloads the bot, rather than exit return True temp = string.split(readbuffer, "\n") readbuffer = temp.pop() for line in temp: line = string.split(string.rstrip(line)) message = " ".join(line) # reply to every periodic PING event if(line[0] == "PING"): c.ping(line[1]) # join the channel elif(line[1] == "376" and line[2] == config.get('ident')): c.join() # identify with nickserv after being prompted elif("NickServ!" in line[0] and line[4] == "nickname"): c.identify() log("Identified with NickServ", m_type="NICKSERV", colour=Fore.GREEN) #ACTION_LOG.info(Style.BRIGHT + Fore.CYAN + "IDENTIFY " + Fore.WHITE + "Identified") # return of NAMES list elif(line[1] == "353"): nicks = "".join(message.split(":")[2].replace("@","").replace("+","").replace("Oracle ","")) global ATTENTION if ATTENTION: c.say(nicks) ATTENTION = False users = nicks.replace(config.get('server-bots')[0],"").replace(config.get('server-bots')[1],"") if config.get('random-points'): randompoints.add_users(users) # realise that Orace just joined, say welcome elif("JOIN" in line) and ("Oracle" in message): # if welcome-message == false if not config.get('welcome-message'): pass else: c.say(format.replace(config.get('welcome-message'))) # throw nick to join() after they join elif ("JOIN" in line or ":JOIN" in line) and not ("Oracle" in message): join(line[0].split(":",1)[1].split("!",1)[0]) # possible 'line(s)' # ':[email protected]', 'PRIVMSG', '#rapid', ': [message]' # ':[email protected]', 'PRIVMSG', 'Oracle', ': [message]' # ':nova.esper.net', 'NOTICE', '*' ':***', 'foo', 'is', 'bar' # 'PING', ':nova.esper.net' # ':[email protected]', 'MODE', '#rapid', '+o', 'Oracle' # ':nova.esper.net', '001', 'Oracle', '[thing]' if (len(line) > 2): # grab nick from first string in line # grab message from fourth string onwards try: nick = line[0].replace(":","").split("!",1)[0] msg = " ".join(line[3:]).replace(":","",1) except: nick = "null" break id = None if nick.endswith('.esper.net'): id = "ESPERNET" elif nick.lower() == ('nickserv'): id = "NICKSERV" elif nick.lower() == ('chanserv'): id = "CHANSERV" if id is not None: log(msg, m_type=id, colour=Fore.GREEN, lg='receive') #RECEIVE_LOG.info(Style.BRIGHT + Fore.GREEN + id + " " + Fore.RESET + msg) elif nick.lower() is not 'oracle': log("<" + nick + "> " + msg, m_type="MESSAGE", colour=Fore.MAGENTA, lg='receive') #RECEIVE_LOG.info(Style.BRIGHT + Fore.MAGENTA + "MESSAGE " + Fore.RESET + " <" + nick + "> " + msg) else: # the message is bad break # reply from WHOIS if "is logged in as" in msg and ".esper.net" in nick: confirm_account(msg.split(" ",2)[1]) # reset variable that tells connect if it is a # message from a server bot if c.getactive(): c.set_inactive() # throw msg and nick to spamhandler if config.get('spam-handler'): global spam if spam == None: spam = spamhandler.Handler() sh = True for bot in config.get('server-bots'): if nick == bot: sh = False if nick == config.get('nick'): sh = False elif nick.lower() == 'nickserv' or nick.lower() == 'chanserv': sh = False if sh: spam.increment(nick, msg) # ignore list doesn't work properly, but meh if not nick in IGNORE_LIST or nick == 'Toofifty': # check if the nick is one of the RapidIRC bots # change nick and msg accordingly for bot in config.get('server-bots'): if nick == bot: try: if msg.startswith("<"): nick, msg = msg.split("<",1)[1].split("> ",1) c.set_active(bot) elif msg.split(" ")[1] == "whispers": nick, msg = msg.split(" whispers ", 1) c.set_active(bot) elif msg.startswith("Online Players:"): users = msg.replace("Online Players:", "") if not users == "": randompoints.add_users(users) except IndexError: pass # handle sudo commands if msg.startswith(str(config.get('sudo-char'))) and v.getrank(nick) >= 4: msg = msg.replace(config.get('sudo-char'),"") nick, msg = msg.split(" ",1) # identify commands from msg for char in config.get('command-chars'): if msg.startswith(char): # make sure to only get rid of one '?' msg = msg.split(char, 1)[1] process_cmd(nick, msg) # throw msg to translator if config.get('translate'): if translate.requires_translate(msg): ACTION_LOG.info("TRN Translating...") c.say("I think you mean: " + translate.translate_result(msg)) # throw msg and nick to gags if config.get('say-responses'): gags.get_response(nick, msg) # check and handle youtube links if config.get('youtube-links'): if(msg.startswith("http://www.youtube.com/")): try: author, title = youtube.processlink(msg) c.say(f.BOLD + f.RED + "YouTube Video" + f.BOLD + f.WHITE + " - " + title + " by " + author) except: c.say(f.BOLD + f.RED + "Youtube video failed" + f.BOLD + f.WHITE + " - 404 Not Found") # tell run.py to reload or exit if RELOAD: return True if EXIT: return False
def get_response(nick, message): if (message.lower() == "nope nope"): c.say("nope.avi - http://www.youtube.com/watch?v=gvdf5n-zI14") elif (message.lower() == "nice"): c.say("nice - http://www.youtube.com/watch?v=jjtkMCLRf-M") elif (message.lower() == "alrighty then"): c.say("alrighty then - http://www.youtube.com/watch?v=hS1okqbnePQ") elif (message.lower() == "noice"): c.say("noice - http://www.youtube.com/watch?v=rQnYi3z56RE") elif (message.lower() == "sad"): c.say("sad - http://www.youtube.com/watch?v=CwK74w4VwgQ") elif (message.lower() == "hello my baby"): c.say("hello my baby - http://www.youtube.com/watch?v=49EoV50oba0") elif (message.lower() == "thanks oracle"): c.say( pick(("No worries mate!", "No problem!", "T'was a pleasure.", "You're welcome!"))) elif (message.lower() == "nice work oracle" or message.lower() == "well done oracle" or message.lower() == "good job oracle"): c.say( pick(("Thanks man!", "Thanks, appreciate it.", "Why, thank you sir!"))) elif (message.lower() == "bye" or message.lower() == "later" or message.lower() == "cya" or message.lower() == "brb"): c.say( pick(("Ciao!", "Adios!", "Tsch�ss!", "Despedida!", "Hasta la Vista!", "Au Revoir!", "Farewell!", "Cya!"))) elif (message.lower().startswith('should ') and '?' in message): c.say( pick(('Yes.', 'No.', 'It depends.', 'Please ask again.', 'No, f**k you'))) elif (message.lower().startswith('will ') and '?' in message): c.say( pick(('Of course!', 'Never.', 'No.', 'Yes.', 'Maybe.', 'Impossible.', 'Never going to happen, buster.'))) elif ('f**k' in message.lower() and 'you' in message.lower() and 'oracle' in message.lower()): c.say( pick(('That\'s not very nice!', 'F**k you too, my good sir!', 'Come at me bro!', 'Do you want a punch-on?!'))) elif ("alrighty" in message): c.say("Alrightyroo") elif (message.lower() == "welcome"): c.say("Welcome " + nick + " to the server!") elif (message.lower() == "oracle"): c.say("Yes?") elif (message.lower() == "oh sweet baby jesus"): c.say("http://gfycat.com/ScientificUnawareAmericanwigeon")