Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket, ssl, sys, urllib2, urllib
- import time, random, os
- from time import clock
- irc = socket.socket()
- sslEnabled = True #Change to false if you don't want to use SSL
- if sslEnabled == True:
- irc = ssl.wrap_socket(irc)
- ircServer = "server" #IRC Server your bots are going to be connecting to
- ircChannel = "channel" #IRC Channel your bots are going to be connecting to
- ircChannelPassword = "channelpassword" #Leave blank if no password
- ircSSLPort = 6697 #If you're using SSL (enabled by default) this is the port it connects to
- ircPort = 6667 #If you're using raw connection, (not enabled by default) this is the port it uses
- ircNick = "nickname" + str(random.randint(10000, 999999)) #Nicknames your bots are going to have in the channel
- ircCKey = "." #The command key for your bots to listen to commands
- ircPass = "serverpassword" #Leave blank if no password
- authList = "authenticationtousebot" #Person authenticated to use the bots
- def rawSend(data): #Send raw data to server
- irc.send(data + "\r\n")
- def ircConnect():
- global irc
- try:
- irc = socket.socket()
- if sslEnabled == True:
- irc = ""
- irc = socket.socket()
- irc = ssl.wrap_socket(irc)
- irc.connect((ircServer, ircSSLPort))
- else:
- irc.connect((ircServer, ircPort))
- except:
- print("lel1231")
- ircConnect()
- def ircMessage(msg): #Send a message to the IRC channel
- rawSend("PRIVMSG " + ircChannel + " :" + msg + "\r\n")
- def ircRegister():
- rawSend("USER " + ircNick + " 0 * " + ":" + ircNick + "\r\n")
- def ircSendNick():
- rawSend("NICK " + ircNick + "\r\n")
- def ircJoin():
- if ircChannelPassword == "":
- rawSend("JOIN " + ircChannel + "\r\n")
- else:
- rawSend("JOIN " + ircChannel + " " + ircChannelPassword + "\r\n")
- def ircPassword():
- if ircPassword != "":
- rawSend("PASS " + ircPass + "\r\n")
- #print("CLIENT: No password being sent")
- def Initialize(): #Define connecting
- ircConnect()
- ircPassword()
- ircRegister()
- ircSendNick()
- ircJoin()
- try:
- Initialize() #Running Initialize Function
- except socket.error:
- Initialize() #Incase of socket errors
- while True:
- try:
- data = irc.recv(1024)
- print(data)
- except socket.timeout:
- ircConnect()
- except socket.error:
- ircConnect()
- secureData = data.split(" ")
- if ":" and "!" and "@" and "PRIVMSG" and "#" in data:
- userName = data.split(" ")
- userName = userName[0]
- if "PING" in data:
- rawSend("PONG")
- #Commands:
- if ircCKey + "ping" in data:
- ircMessage("pong")
- if ircCKey + "lookup" in data and secureData[0] in authList: #Hostname to IP
- hostname = data.split(" ")
- try:
- hostname = hostname[4]
- hostname = hostname.strip("\r\n")
- ip = socket.gethostbyname(hostname)
- ircMessage(ip + ", " + hostname)
- except:
- ircMessage("Failed to lookup: " + hostname)
- if ircCKey + "isup" in data and secureData[0] in authList: #Is a website up
- hostname = data.split(" ")
- try:
- hostname = hostname[4]
- hostname = hostname.strip("\r\n")
- request = urllib2.urlopen("http://isup.me/" + hostname)
- source = request.read()
- if "s just you." in source:
- ircMessage(hostname + " is up from here.")
- else:
- ircMessage(hostname + " is down from here.")
- except:
- ircMessage("Failed to check if: " + hostname + " is up.")
- if ircCKey + "die" in data and secureData[0] in authList: #Die
- ircMessage("Cya!")
- irc.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement