Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- from time import gmtime, strftime
- server = "irc.rizon.net"
- channel = "#channel"
- botnick = "TheNickname"
- def ping():
- ircsock.send("PONG :pingis\r\n")
- def kick(channel, nick):
- ircsock.send('KICK %s %s :Goodbye <3\r\n' % (channel,nick))
- def joinchan(chan):
- ircsock.send("JOIN "+ chan +"\r\n")
- def hello(nick):
- ircsock.send("PRIVMSG %s :Hello %s! \r\n" % (channel,nick))
- def commands(nick,channel,message):
- if message.find(botnick+': 5')!=-1:
- ircsock.send('PRIVMSG %s :%s: Mr.Derple \r\n' % (channel,nick))
- elif message.find(botnick+': help')!=-1:
- ircsock.send('PRIVMSG %s :%s: You don\'t need any help nigga.\r\n' % (channel,nick))
- elif message.find(botnick+': die')!=-1:
- ircsock.send("PART %s :okay.jpg\r\n" % (channel))
- exit()
- elif ircmsg.find(":!k") != -1:
- nick=ircmsg.split('!k')[1][1:]
- channel=ircmsg.split(' PRIVMSG ')[-1].split(' :')[0]
- kick(channel,nick)
- elif ircmsg.find(":Hello "+ botnick) != -1 or ircmsg.find(":Hi "+ botnick) != -1:
- nick=ircmsg.split('!')[0][1:]
- hello(nick)
- ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- ircsock.connect((server, 6667))
- ircsock.send("NICK %s \r\n" % (botnick))
- ircsock.send("USER %s %s %s :Mr.Derple\r\n" % (botnick,botnick,botnick))
- joinchan(channel)
- while True:
- ircmsg = ircsock.recv(2048)
- ircmsg = ircmsg.strip('\n\r')
- if ircmsg.find("PING :") != -1:
- ping()
- #uncomment this to greet people when they join
- #if ircmsg.find(" JOIN ") != -1:
- # nick=ircmsg.split('!')[0][1:]
- # hello(nick)
- if ircmsg.find(' PRIVMSG ')!=-1:
- nick=ircmsg.split('!')[0][1:]
- channel=ircmsg.split(' PRIVMSG ')[-1].split(' :')[0]
- commands(nick,channel,ircmsg)
- if ircmsg.find(' PRIVMSG ')!=-1:
- ircmsg = ircmsg.replace("<","<")
- message = ircmsg.split(channel)
- nick=ircmsg.split('!')[0][1:]
- try:
- message = message[1][2:]
- except:
- continue;
- open("index.html","a+b").write("%s < %s > %s <br>\n" % (strftime("%H:%M:%S", gmtime()),nick,message))
Advertisement
Add Comment
Please, Sign In to add comment