Ejemplo n.º 1
0
def witch(sock, line):
    username = botStandard.getUsername(line)
    if not (botFileIO.readTime("witch", username) == "null"):
        if (botFileIO.isThreeHour(botFileIO.readTime("witch", username), botFileIO.getCurrentDateTime()) == 0):
            botCore.sendLine(sock, username, "Be patient, collector of WITCHES. It is not yet your TIME. There are yet " + str(botFileIO.timeLeft(botFileIO.readTime("witch", username), botFileIO.getCurrentDateTime())) + " seconds REMAINING.")
        
        else:
            witchEditing(sock, line, username, 0)
    else:
        witchEditing(sock, line, username, 1)
Ejemplo n.º 2
0
def publicCommands(sock, line):
    caught = False
    botConfig = botCore.readConfig()
    
    if (line[3] == ":&knox"):
        caught = True
        botExtra.knox(sock, line)
    
    elif (line[3] == ":&witch"):
        caught = True
        if (line[2] == botConfig.get('Bot', 'bot_nickname')):
            botCore.sendLine(sock, getUsername(line), "This command is only functional if sent in a CHANNEL.")
        else:
            botExtra.witch(sock, line)
        
    return caught
Ejemplo n.º 3
0
def privateCommands(sock, line, botConfig):
    #Check for the password
    if (len(line) >= 5):
        if (len(line) >= 6):
            if (checkPassword(line[4], botConfig)):
                if (line[3] == ":&join"):
                    botCore.joinChannels(sock, [line[5]])
                
                elif (line[3] == ":&leave"):
                    botCore.leaveChannels(sock, [line[5]])
                
                elif (line[3] == ":&quit"):
                    sock.send("QUIT :" + botConfig.get('Bot', 'quit_message') + "\r\n")
                    sys.exit()
                
                elif (line[3] == ":&say"):
                    lineToSend = ""
                    for x in range(6, len(line)):
                        if (x == 6):
                            lineToSend += line[x]
                        else:
                            lineToSend = lineToSend + " " + line[x]
                    botCore.sendLine(sock, line[5], lineToSend)
                
                elif (line[3] == ":&act"):
                    lineToSend = ""
                    for x in range(6, len(line)):
                        if (x == 6):
                            lineToSend += line[x]
                        else:
                            lineToSend = lineToSend + " " + line[x]
                    botCore.sendAction(sock, line[5], lineToSend)
                
            else:
                botCore.sendLine(sock, getUsername(line), "That password is INCORRECT.")
        else:
            botCore.sendLine(sock, getUsername(line), "You did not specify any parameters. The correct format for the private bot commands is /msg " + botConfig.get('Bot', 'bot_nickname') + " &command password parameter, please try AGAIN.")
    else:
        botCore.sendLine(sock, getUsername(line), "You did not specify a PASSWORD. The correct format for the private bot commands is /msg " + botConfig.get('Bot', 'bot_nickname') + " &command password parameter, please try AGAIN.")
Ejemplo n.º 4
0
def knox(sock, line):
    botCore.sendLine(sock, line[2], randomKnox())
Ejemplo n.º 5
0
def witchEditing(sock, line, username, firstFlag):
    numWitches = random.randint(-3, 9)
    if(numWitches == 0):
        botCore.sendLine(sock, line[2], username + " is a loser and doesn't deserve any WITCHES.")
    else:
        if (firstFlag == 1):
            if(numWitches <= -1):
                botCore.sendLine(sock, line[2], username + " is absolutely terrible and has not managed to attract any witches at all to their SENATE!")
                botFileIO.editLine("witch", username, 0)
            elif(numWitches == 1):
                botCore.sendLine(sock, line[2], username + " is just sort of average and got " + str(numWitches) + " WITCH! " + username + " has " + str(numWitches) + " witches in their SENATE.")
                botFileIO.editLine("witch", username, numWitches)
            elif(numWitches <= 3):
                botCore.sendLine(sock, line[2], username + " is just sort of average and got " + str(numWitches) + " WITCHES! " + username + " has " + str(numWitches) + " witches in their SENATE.")
                botFileIO.editLine("witch", username, numWitches)
            elif(numWitches <= 6):
                botCore.sendLine(sock, line[2], username + " is fairly decent and got " + str(numWitches) + " WITCHES! " + username + " has " + str(numWitches) + " witches in their SENATE.")
                botFileIO.editLine("witch", username, numWitches)
            elif(numWitches <= 9):
                botCore.sendLine(sock, line[2], username + " is quite awesome and got " + str(numWitches) + " WITCHES! " + username + " has " + str(numWitches) + " witches in their SENATE.")
                botFileIO.editLine("witch", username, numWitches)
        else:
            if(numWitches <= -2):
                if (((numWitches) + (int((botFileIO.readLine("witch", username))[1]))) < 0):
                    botCore.sendLine(sock, line[2], username + " is absolutely terrible and managed to drive away " + str(int(math.fabs(numWitches))) + " witches from their Senate, leaving them with no witches REMAINING.")
                else:
                    botCore.sendLine(sock, line[2], username + " is absolutely terrible and managed to drive away " + str(int(math.fabs(numWitches))) + " witches from their SENATE. " + username + " has " + str((numWitches) + (int((botFileIO.readLine("witch", username))[1]))) + " witches in their SENATE.")
                botFileIO.editLine("witch", username, numWitches)
            
            elif(numWitches == -1):
                if (((numWitches) + (int((botFileIO.readLine("witch", username))[1]))) < 0):
                    botCore.sendLine(sock, line[2], username + " is absolutely terrible and managed to drive away " + str(int(math.fabs(numWitches))) + " witch from their Senate, leaving them with no witches REMAINING.")
                else:
                    botCore.sendLine(sock, line[2], username + " is absolutely terrible and managed to drive away " + str(int(math.fabs(numWitches))) + " witch from their SENATE. " + username + " has " + str((numWitches) + (int((botFileIO.readLine("witch", username))[1]))) + " witches in their SENATE.")
                botFileIO.editLine("witch", username, numWitches)
                
            elif(numWitches <= 3):
                botCore.sendLine(sock, line[2], username + " is just sort of average and got " + str(numWitches) + " WITCHES! " + username + " has " + str((numWitches) + (int((botFileIO.readLine("witch", username))[1]))) + " witches in their SENATE.")
                botFileIO.editLine("witch", username, numWitches)
            elif(numWitches <= 6):
                botCore.sendLine(sock, line[2], username + " is fairly decent and got " + str(numWitches) + " WITCHES! " + username + " has " + str((numWitches) + (int((botFileIO.readLine("witch", username))[1]))) + " witches in their SENATE.")
                botFileIO.editLine("witch", username, numWitches)
            elif(numWitches <= 9):
                botCore.sendLine(sock, line[2], username + " is quite awesome and got " + str(numWitches) + " WITCHES! " + username + " has " + str((numWitches) + (int((botFileIO.readLine("witch", username))[1]))) + " witches in their SENATE.")
                botFileIO.editLine("witch", username, numWitches)
Ejemplo n.º 6
0
 readBuffer = botCore.readBuffer(sock)
 
 for line in readBuffer:
     
     #Do some formatting
     line = botCore.formatLine(line)
     
     #Output the line to the console if not empty
     if not (line == []):
         botCore.consoleOutputLine(sock, line)
     
     if (len(line) >= 1):
         #Handler for NickServ identification and ajoining channels
         for x in range(0, len(line)):
             if (line[x] == "/MOTD"):
                 botCore.sendLine(sock, "NickServ", "IDENTIFY " + botConfig.get('Bot', 'bot_nickserv_password'))
                 time.sleep(1)
                 botCore.joinChannels(sock, string.split(botConfig.get('Bot', 'ajoin_channels'), " "))
             
         #Ping response
         if (line[0] == "PING"):
             sock.send("PONG %s\r\n" % line[1])
         
         if (len(line) >= 4):
             #Version response
             if (line[3] == ":VERSION"):
                 botCore.sendNotice(sock, botStandard.getUsername(line), ("VERSION " + botConfig.get('Bot', 'version_text') + ""))
             
             #Command processing (public and private), looking for & command delimiter
             if (len(list(line[3])) >= 2):
                 if ((list(line[3]))[1] == "&"):