Skip to content

Instantly share code, notes, and snippets.

@Nezzerath
Created January 7, 2013 23:46
Show Gist options
  • Save Nezzerath/4479699 to your computer and use it in GitHub Desktop.
Save Nezzerath/4479699 to your computer and use it in GitHub Desktop.
nezzybear
import sys
import socket
import string
import os
import threading
windowtitle = "Nezzbot IRC Client"
from os import system
system("title "+windowtitle)
nickname = raw_input("Nickname: ")
password = raw_input("Password: ")
channel = raw_input("Channel: ")
os.system('cls')
host = "irc.freenode.net"
PORT = 6667
realname = nickname
ident = nickname
s=socket.socket( )
s.connect((host, PORT))
s.send("NICK %s\r\n" % nickname)
s.send("USER %s %s bla :%s\r\n" % (ident, host, realname))
s.send("nickserv IDENTIFY %s\r\n" % password)
s.send("JOIN :%s\r\n" % channel)
while True:
data = s.recv(4096)
print data
if data.find ( 'PING' ) != -1:
s.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )
if not data.find( "PRIVMSG" ) == -1:
if data.find( nickname ) != -1:
try:
IRC_PRIVMSG_Information = [
data.split( ":" )[ 1 ].split( "!" )[ 0 ], #nick
data.split( "!" )[ 1 ].split( "@" )[ 0 ], #user
data.split( " " )[ 0 ].split( "@" )[ 1 ], #host
data.split( " " )[ 2 ], #Channel, Message
":".join( data.split( ":" )[ 2: ] ), True ] # Channel or PM
if not IRC_PRIVMSG_Information[ 3 ][ 0 ] == "#":
IRC_PRIVMSG_Information[ 5 ] = False
if "hello" in IRC_PRIVMSG_Information[4]:
s.send("PRIVMSG %s :%s\r\n" % (channel, "Hello" + " " + IRC_PRIVMSG_Information[0]))
if "disconnect" in IRC_PRIVMSG_Information[4]:
sys.exit()
if "set status to away" in IRC_PRIVMSG_Information[4]:
s.send("AWAY %s\r\s")
if "come back" in IRC_PRIVMSG_Information[4]:
s.send("BACK %s\r\s")
if "bang bang" in IRC_PRIVMSG_Information[4]:
s.send("PRIVMSG %s :%s\r\n" % "/me is dead")
print IRC_PRIVMSG_Information
except Exception, Error: print "Error: %s" % ( Error )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment