Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
978 B
2
Indexable
Never
Here is a Python IRC bot that kicks the nickname "rootb" out of the channel every time he complains about being poor:


import socket

# Set the server and channel information
server = "irc.freenode.net"
channel = "#mychannel"

# Connect to the IRC server
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
irc.connect((server, 6667))

# Send the necessary commands to join the channel
irc.send("USER mybot mybot mybot :My IRC bot\n".encode())
irc.send("NICK mybot\n".encode())
irc.send("JOIN {}\n".format(channel).encode())

# Continuously listen for messages in the channel
while True:
    # Read the message from the server
    message = irc.recv(2048).decode().strip()
    print(message)

    # If the message is a complaint from "rootb" about being poor, kick him from the channel
    if "PRIVMSG" in message and "rootb" in message and "poor" in message:
        irc.send("KICK {} rootb :You're not welcome here\n".format(channel).encode())