Q-Bot source - qwerasd205 - 04-07-2014
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.
RE: Q-Bot source - Iceglade - 04-07-2014
(04-07-2014, 06:58 PM)qwerasd205 Wrote: Code: #--------------------------------------------#
#----------------WHILE LOOP------------------#
#--------------------------------------------#
Hate to be a party pooper but that comment is probably not needed, much less prettied up like that :/
RE: Q-Bot source - qwerasd205 - 04-07-2014
(04-07-2014, 07:49 PM)Iceglade Wrote: (04-07-2014, 06:58 PM)qwerasd205 Wrote: Code: #--------------------------------------------#
#----------------WHILE LOOP------------------#
#--------------------------------------------#
Hate to be a party pooper but that comment is probably not needed, much less prettied up like that :/
I was using that to find the start of my while loop when working on it, without the comment finding it is pretty hard.
RE: Q-Bot source - Jmking80 - 04-10-2014
oh boy I sense even more bots...
Anybody interested in a java version of this?
RE: Q-Bot source - David - 04-10-2014
(04-10-2014, 05:52 PM)Jmking80 Wrote: oh boy I sense even more bots...
Anybody interested in a java version of this?
RE: Q-Bot source - Chibill - 04-11-2014
I have a java one and I am making a minecraft bot to use with team speak AKA teamspeak to minecraft and minecraft to teamspeak...
maybe that same with the IRC tooo.
RE: Q-Bot source - gelloe - 04-11-2014
(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?
RE: Q-Bot source - David - 04-11-2014
(04-11-2014, 07:17 PM)gelloe Wrote: What's so bad about Java?
Quite a lot, but that's not my point. My point is that I'd rather not have another bot on ORE.
RE: Q-Bot source - Iceglade - 04-11-2014
(04-11-2014, 08:35 PM)David Wrote: My point is that I'd rather not have another bot on ORE.
+1
|