(04-07-2014, 06:58 PM)qwerasd205 Wrote: Tyler asked for it so I'm gonna post a framework
CODE:
Code:import socket
import sympy
HOST="irc.freenode.net"
PORT=6667
NICK="Q-Bot"
IDENT="Q-Bot"
REALNAME="Q-Bot"
CHANNEL="#OREServerChat"
JOINMSG="Q-Bot Online!"
OWNERIRC="qwerasd205"
OWNER="qwerasd205"
CMD="~"
SERVER1="OREBuild"
SERVER2="ORESchool"
s=socket.socket( )
s.connect((HOST, PORT))
s.send("NICK "+NICK+"\r\n")
s.send("USER "+IDENT+" "+HOST+" bla :"+REALNAME+"\r\n")
s.send("JOIN "+CHANNEL+"\r\n")
def send(st):
print(st+"-->"+CHANNEL+"\n")
s.send("PRIVMSG "+CHANNEL+" :"+st+"\r\n")
def ircmsg():
if(not (recv.find(SERVER1)!= -1 and recv.find(SERVER2)!= -1)): return True
def priv(st, u):
print(st+"-->"+u+"\n")
s.send("PRIVMSG "+SERVER1+" :@"+u+" "+st+"\r\n")
s.send("PRIVMSG "+SERVER2+" :@"+u+" "+st+"\r\n")
if(ircmsg()):
s.send("PRIVMSG "+ident+" :"+st+"\r\n")
def isowner():
if((len(name)==len(OWNER))and(ident.find(SERVER1) != -1 or ident.find(SERVER2) != -1) or ident == (OWNERIRC)): return True
def args(st):
args=line.split(st)
return args[1]
send(JOINMSG)
#--------------------------------------------#
#----------------WHILE LOOP------------------#
#--------------------------------------------#
while(1):
recv=s.recv(2040)
split=recv.split("PRIVMSG ")
ident=recv.split("!")
ident=ident[0].split(":")
ident=ident[1]
try:
print(ident+": "+split[1])
line = split[1]
splitname = split[1].split(":")
name = splitname[1]
except:
print(recv)
line = recv
splitname = ["",""]
try:
if(line.find("PING") != -1):
s.send("PONG"+args("PING"))
#-----------CMDS-----------------------------#
if(line.find(CMD+"quit") != -1 and isowner()):
send("SHUTTING DOWN...")
s.send("QUIT\r\n")
if(line.find(CMD+"eval ") != -1 and isowner()):
priv(str(eval(args(CMD+"eval "))), OWNER)
if(line.find(CMD+"echo ") != -1):
send(args(CMD+"echo "))
if(line.find(CMD+"calc ") != -1):
priv(str(sympy.sympify(args(CMD+"calc "))), name)
except:pass
* qwerasd205 doesn't know how to make spoilers.
Fuck, this is almost the same code as my old Gel-Bot thing, except mine was written in Java. WHY DID GEL-BOT NOT WORK!??!
(04-10-2014, 09:03 PM)David Wrote:(04-10-2014, 05:52 PM)Jmking80 Wrote: oh boy I sense even more bots...
Anybody interested in a java version of this?
What's so bad about Java?