示例#1
0
def main():
    while True:
        if not makeConnection():
            break
        while True:
            command = irc.readCommand()
            if command == None:
                break
            parsed = Parse(command)
            for module in enabled_modules:
                module(parsed)
        irc.disconnect()
        log.notice("Lost connection, reconnecting...")
示例#2
0
def main():
    irc.connect(HOST, PORT)
    irc.send_pass(PASS)
    irc.send_nick(NICK)
    irc.join_channel(CHAN)

    # irc.send_message(CHAN, ".me A WILD BOT JOINED THE CHAT!")
    print("SYS: A WILD BOT JOINED THE CHAT!")

    while True:
        try:
            data = irc.receive()
            data = re.split(r"[~\r\n]+", data)
            # data.pop()

            for line in data:
                line = str.rstrip(line)
                line = str.split(line)

                if len(line) >= 1:
                    if line[0] == "PING":
                        irc.send_pong(line[1])
                    if line[1] == "PRIVMSG":
                        parse_message(line)
            sleep(1 / (20 / 30))

        except socket.error:
            print("Socket died")
            break
        except socket.timeout:
            print("Socket timeout")
            break
        except (KeyboardInterrupt, SystemExit):
            break

    irc.disconnect()

    # irc.send_message(CHAN, ".me A WILD BOT LEFT THE CHAT!")
    print("SYS: A WILD BOT LEFT THE CHAT!")