login(NICKNAME) #login with only the nickname given. All other data is set to defaults.
joinChannel(CHANNEL) #join the default channel
sendData("PRIVMSG " + CHANNEL + " :Bot online. For bot statistics please see @botStats. If you need any help you may private message me @Help") #message the channel that the bot is online.
while (1): #all while the script is running
buffer = IRC.recv(1024) #set the buffer to the received contents
msg = string.split(buffer) #split the string from buffer
message = ' '.join(msg[3:]) #set the message data
senderData = msg[0].split("!") #split the message for sender data
senderData = senderData[0].replace(":", "") #replace colons with nothing but a void
if msg[0] == "PING": #server sent a ping
sendData("PONG %s" % msg[1]) #lets reply with pong!
if msg[1] == 'JOIN' and senderData != NICKNAME: #someone joins, and its not the bot
print senderData + " has joined " + CHANNEL #print on the script screen that someone joined
sendData("PRIVMSG " + senderData + " :Welcome to " + CHANNEL + ", " + senderData + " If you need any help you may say @Help at any time.") #welcome the user in private message
sendData("PRIVMSG " + CHANNEL + " :Welcome, " + senderData + ".") #welcome the user in the channel itself
if msg[1] == 'PRIVMSG' and msg[2] == NICKNAME: #private message commands and handles if its the bot.
if "@Help" in message: #someone needs help
print senderData + " requested help." #echo locally that someone needed help
commands(senderData) #send them the commands list from earlier
if msg[1] == 'PRIVMSG' and msg[2] != NICKNAME: #some more PM commands
if "@Help" in message: #someone else requested help
print senderData + " requested help." #print locally
commands(senderData) #send commands listing
if "@datetime" in message: #date time requested
print senderData + " requested date and time." #print locally
now = datetime.datetime.now() #set the now time.
myTime = now.strftime("%A, %B %d, %Y %I:%M %p") #this is the time to send the user
sendData("PRIVMSG " + msg[2] + " :Date/Time: " + myTime) #send them a PM with the date/time
if "@botStats" in message: #someone wanted bot statistics
print senderData + " requested bot stats." #print locally.
botPlatform = sys.platform #the bot's platform
botOs = platform.platform() #the bot's operating system
osInfo = botOs.split("-") #split the info from -'s
sendData("PRIVMSG " + senderData + " :Bot Platform: " + botPlatform) #send the data: bot platform
sendData("PRIVMSG " + senderData + " :Operating System: " + osInfo[0] + " " + osInfo[1] + " Version: " + osInfo[2]) #send operating system name, and version