01-14-2014, 06:00 AM
ITS PRONOUNCED MAL-SEE, SHE IS FEMALE. MY GOD.
Prepare for the IRC bot that is going to make the server barf. And the code will probably make someone barf. PYTHON CODE ACTIVATE!
Code:
import socket
import sys
from time import sleep
from random import randint
server = "irc.freenode.net" #settings
channel = "#OREServerChat"
botnick = "MalcyBot"
cmdsign = "."
password = randint(1000*10, 1000**10)
print "Le password to quit! Important! "+str(password)
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "Now connecting! "+server
irc.connect((server, 6667))
irc.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :Le Bot Of Le Malc\n")
irc.send("NICK "+ botnick +"\n")
irc.send("PRIVMSG nickserv : /say\r\n")
irc.send("JOIN "+ channel +"\n")
irc.send("PRIVMSG "+channel+" :Hi! I have no idea why PONG shows up here: ")
while True:
text = irc.recv(2040)
if text.find('PING') != -1: #Le Ping For Le Server
irc.send('PONG ' + text.split() [1] + '\r\n')
if text.find(cmdsign+"hi") != -1: #Le Hi
irc.send('PRIVMSG '+channel+' :Hello, sir!\r\n')
if text.find(cmdsign+"pay") != -1: #Le Pay
t = text.split(cmdsign+"pay")
to = t[1].strip()
if to == "":
irc.send("PRIVMSG "+channel+" :Error! No person.\r\n")
else:
irc.send("PRIVMSG "+channel+" :Random Robot prints lots and lots of money and gives it to "+str(to)+" because why the heck not.\r\n")
if text.find(cmdsign+"apply") != -1:
irc.send("PRIVMSG "+channel+" :Hello, newblet! At least, I assume you are a newblet because you asked how to apply.\r\n")
irc.send("PRIVMSG "+channel+" :Applying is easy-peasy. Just follow this guide:\r\n")
irc.send("PRIVMSG "+channel+" :http://openredstone.org/apply/\r\n")
irc.send("PRIVMSG "+channel+" :Good luck!\r\n")
if text.find(cmdsign+"quit:"+str(password)) != -1: #Le Quit
irc.send("PRIVMSG "+channel+" :Good bye suckers!\r\n")
irc.send("QUIT\r\n")
exit()
sleep(.5)
You don't need to have the commands seperate from other text, so you could type things like:
"Welcome! Say .hi, Malcy!" and he will say hi. Or:
"Dude, just .apply." and Malcy will tell the noob how to apply.
But that feature is probably going to cause Malcy to break a lot.
The password for quitting is a random number between 1000*10 and 1000^10, newly generated on each startup. So, to quit, it would be: .quit:[pass]
When I add more passworded commands, there is always going to be a semicolon right after where you put your password, so the password is kind of like "part of the command" (Yeah, I know, its stupid.)