Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Import socket libraries
- import socket
- # The variables that can be configured
- server = "irc.malvager.com" # Server
- channel = "bot" # Channel
- botnick = "BiowBot" # Your bots nick
- def ping(): # Function to respond to PINGs
- ircsock.send("PONG :pingis\n")
- def sendmsg(chan , msg): # Function for sending messages to a channel
- ircsock.send(str.encode("PRIVMSG " + "#" + chan +" :" + msg + "\n") )
- def joinchan(chan): # This function is used to join channels.
- ircsock.send(str.encode("JOIN " + "#" + chan + "\n"))
- def leavechan(chan): # This is used to part a chan
- ircsock.send(str.encode("PART " + "#" + chan + "\n"))
- ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- ircsock.connect((server, 6667)) # The actual connection to the server through the socket
- ircsock.send(str.encode("USER "+ botnick +" "+ botnick +" "+ botnick +" :hax\n")) # user authentication
- ircsock.send(str.encode("NICK "+ botnick +"\n")) # here we actually assign the nick to the bot
- joinchan(channel) # Join the channel using the functions we previously defined
- hello(channel)
- sendmsg(channel,"sup")
- while 1: # Inb4infinite loop
- ircmsg = ircsock.recv(2048) # receive data from the server
- print(ircmsg)
- if ircmsg.find("PING :") != -1: # if the server pings us then we've got to respond!
- ping()
- print('Ping received')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement