Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import random
- chan = '#voxanon'
- nick = ''
- ident = ''
- password = ''
- server = 'irc.voxanon.net'
- ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- ircsock.connect((server, 6667))
- ircsock.send('USER '+ nick +' '+ nick +' '+ password +' :'+ ident+'\r\n')
- ircsock.send('NICK '+ nick +'\n')
- ircsock.send('JOIN '+ chan +'\n')
- def parsemsg(msg):
- nick = ircmsg.split('!')[0][1:]
- channel = ircmsg.split(' PRIVMSG ')[-1].split(' :')[0]
- complete = ircmsg[1:].split(':',1)
- msgpart = complete[1]
- if nick == '': #the bot owner's nick
- cmd = msgpart.split(' ')
- if ircmsg.find('KICK') != -1:
- ircsock.send('JOIN '+ chan +'\r\n')
- if cmd[0] == '!commands':
- ircsock.send('PRIVMSG %s :!kick\r\n' % (channel))
- ircsock.send('PRIVMSG %s :!join #channel\r\n' % (channel))
- ircsock.send('PRIVMSG %s :!part #channel\r\n' % (channel))
- ircsock.send('PRIVMSG %s :!op <who>\r\n' % (channel))
- ircsock.send('PRIVMSG %s :!deop <who>\r\n' % (channel))
- ircsock.send('PRIVMSG %s :!voice <who>\r\n' % (channel))
- ircsock.send('PRIVMSG %s :!devoice <who>\r\n' % (channel))
- ircsock.send('PRIVMSG %s :!invite <who>\r\n' % (channel))
- ircsock.send('PRIVMSG %s :!topic <what>\r\n' % (channel))
- #=======!8BALL=======#
- if ircmsg.find('!8ball') != -1:
- n = random.randint(1, 7)
- if n == 1:
- ircsock.send('PRIVMSG %s :The answer lies in your heart\r\n' % (channel))
- elif n == 2:
- ircsock.send('PRIVMSG %s :I do not know\r\n' % (channel))
- elif n == 3:
- ircsock.send('PRIVMSG %s :Almost certainly\r\n' % (channel))
- elif n == 4:
- ircsock.send('PRIVMSG %s :No\r\n' % (channel))
- elif n == 5:
- ircsock.send('PRIVMSG %s :Why do you need to ask?\r\n' % (channel))
- elif n == 6:
- ircsock.send('PRIVMSG %s :Go away. I do not wish to answer at this time.\r\n' % (channel))
- elif n == 7:
- ircsock.send('PRIVMSG %s :Time will only tell\r\n' % (channel))
- #=======MASTER COMMANDS=======#
- if cmd[0] == '!kick':
- ircsock.send('KICK %s %s\r\n' % (channel, cmd[1]))
- if cmd[0] == '!join':
- ircsock.send('JOIN %s\r\n' % (cmd[1]))
- if cmd[0] == '!part':
- ircsock.send('PART %s\r\n' % (cmd[1]))
- if cmd[0] == '!op':
- ircsock.send('MODE %s +o %\r\n' % (channel, cmd[1]))
- if cmd[0] == '!deop':
- ircsock.send('MODE %s -o %\r\n' % (channel, cmd[1]))
- if cmd[0] == '!voice':
- ircsock.send('MODE %s +v %\r\n' % (channel, cmd[1]))
- if cmd[0] == '!devoice':
- ircsock.send('MODE %s -v %\r\n' % (channel, cmd[1]))
- if cmd[0] == '!invite':
- ircsock.send('INVITE %s %s\r\n' % (cmd[1], channel))
- if cmd[0] == '!topic':
- ircsock.send('TOPIC %s %s\r\n' % (channel, cmd[1]))
- while 1:
- ircmsg = ircsock.recv(4096)
- print(ircmsg)
- if ircmsg.find('Global!services@voxanon.net NOTICE') !=-1:
- ircsock.send('JOIN '+ chan +'\n')
- if ircmsg.find(' PRIVMSG ')!=-1:
- parsemsg(ircmsg)
- ircmsg = ircmsg.strip('\r\n')
- if ircmsg.find('PING') != -1:
- ircsock.send('PONG :pingis\r\n')
Add Comment
Please, Sign In to add comment