Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import socket
- import sys
- #settings
- server = "irc.freenode.net"
- global botnick
- botnick = "SupahKBot"
- global channel
- channel = "##Penstubal"
- #connect
- irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #defines the socket
- print "connecting to:" +server
- irc.connect((server, 6667)) #connects to the server
- irc.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :"+ botnick +"\n") #user authentication
- irc.send("NICK "+ botnick +"\n")
- irc.send("JOIN "+ channel +"\n")
- #body
- readbuffer = ''
- while 1: #puts it in a loop
- text=irc.recv(2040) #receive the text
- print text #print text to console
- sender = text.split(" ")
- sender = sender[0]
- sender = sender.split("!")
- sender = sender[0]
- sender = sender.strip(":")
- ##Find where command is sent
- sendto = '' # can be a user's nick(from query) or a channel
- if text.find('PRIVMSG ' +botnick+ ' :') != -1: #the command comes from a query
- sendto = sender
- else:
- sendto = channel
- if text.find('PING') != -1: #check if 'PING' is found
- irc.send('PONG ' + text.split() [1] + '\r\n')
- irc.send("PRIVMSG "+channel+" :k\r\n")
- elif text.find('KICK') != -1: #checks if 'KICK' is found (if bot is kicked from channel)
- irc.send("JOIN "+ channel +"\n")
- irc.send("PRIVMSG "+channel+" :k\r\n")
- elif text.find('PRIVMSG') != -1:
- irc.send("PRIVMSG "+channel+" :k\r\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement