idk, some changes I guess, lol
This commit is contained in:
parent
e96f884424
commit
9f3c36ec0b
11
commands.py
11
commands.py
|
@ -16,13 +16,15 @@ class Command:
|
||||||
self.util.mesg(cmd.split(" ",1)[1])
|
self.util.mesg(cmd.split(" ",1)[1])
|
||||||
def help(self,prefix,cmd,pm,line,admin,extra):
|
def help(self,prefix,cmd,pm,line,admin,extra):
|
||||||
mesg=self.mesg
|
mesg=self.mesg
|
||||||
prefixes=", ".join(extra[0])
|
prefixes="\""+"\", \"".join(extra[0])+"\""
|
||||||
enabled_commands=extra[1]
|
enabled_commands=extra[1]
|
||||||
admin_commands=", ".join(extra[2])
|
admin_commands=", ".join(extra[2])
|
||||||
try: topic=extra[3]
|
try: topic=extra[3]
|
||||||
except IndexError: topic=None
|
except IndexError: topic=None
|
||||||
|
try: self_nick=extra[4]
|
||||||
|
except IndexError: self_nick=None
|
||||||
abs_topics={
|
abs_topics={
|
||||||
"prefixes":"available prefixes are {prefixes} or my name"
|
"prefixes":f"available prefixes are {prefixes} or \"{self_nick}\""
|
||||||
}
|
}
|
||||||
if topic==None:
|
if topic==None:
|
||||||
mesg(f"available topics: "+", ".join(enabled_commands+list(abs_topics.keys())))
|
mesg(f"available topics: "+", ".join(enabled_commands+list(abs_topics.keys())))
|
||||||
|
@ -30,12 +32,13 @@ class Command:
|
||||||
mesg(f"admin commands: {admin_commands}")
|
mesg(f"admin commands: {admin_commands}")
|
||||||
else:
|
else:
|
||||||
try: mesg(f"{topic}: "+eval(f"self.{topic}.__doc__"))
|
try: mesg(f"{topic}: "+eval(f"self.{topic}.__doc__"))
|
||||||
except TypeError:
|
# except Exception as e:
|
||||||
|
except (TypeError,AttributeError):
|
||||||
|
# mesg(str( e.__class__.__name__ ))
|
||||||
if topic in abs_topics:
|
if topic in abs_topics:
|
||||||
mesg(f"{topic}: "+abs_topics[topic])
|
mesg(f"{topic}: "+abs_topics[topic])
|
||||||
else:
|
else:
|
||||||
mesg(f"no help available for \"{topic}\"...")
|
mesg(f"no help available for \"{topic}\"...")
|
||||||
except AttributeError: mesg(f"there's no such thing as \"{topic}\"!")
|
|
||||||
except Exception as e: mesg(str(e.__class__)+" "+str(e))
|
except Exception as e: mesg(str(e.__class__)+" "+str(e))
|
||||||
def reload(self,prefix,cmd,pm,line,admin):
|
def reload(self,prefix,cmd,pm,line,admin):
|
||||||
mesg=self.mesg
|
mesg=self.mesg
|
||||||
|
|
|
@ -24,4 +24,4 @@ class config:
|
||||||
class cmd:
|
class cmd:
|
||||||
prefixes=["6","'"]
|
prefixes=["6","'"]
|
||||||
enabled_commands=["help","echo"]
|
enabled_commands=["help","echo"]
|
||||||
admin_commands=["eval","exec","quit"]
|
admin_commands=["eval","exec","quit","reload"]
|
||||||
|
|
31
stuff.py
31
stuff.py
|
@ -44,6 +44,8 @@ def stuff(bot,sock):
|
||||||
send(f"PONG :{line.params[0]}")
|
send(f"PONG :{line.params[0]}")
|
||||||
|
|
||||||
if mode=="init":
|
if mode=="init":
|
||||||
|
if line.command == "433":
|
||||||
|
util.nick(config.self.nick+"_")
|
||||||
if line.command == "376":
|
if line.command == "376":
|
||||||
send(irctokens.build("CAP", ["LS","302"]).format())
|
send(irctokens.build("CAP", ["LS","302"]).format())
|
||||||
elif line.command=="CAP" and line.params[1]=="LS":
|
elif line.command=="CAP" and line.params[1]=="LS":
|
||||||
|
@ -75,18 +77,21 @@ def stuff(bot,sock):
|
||||||
util.target=target
|
util.target=target
|
||||||
command.util.target=target
|
command.util.target=target
|
||||||
if is_pm or line.params[1].startswith(self_nick) or line.params[1][0] in prefixes:
|
if is_pm or line.params[1].startswith(self_nick) or line.params[1][0] in prefixes:
|
||||||
cmd=line.params[1]
|
try:
|
||||||
#if message in a channel, remove prefixes
|
cmd=line.params[1]
|
||||||
if not is_pm:
|
#if message in a channel, remove prefixes
|
||||||
if cmd[0] in prefixes:
|
if not is_pm:
|
||||||
cmd=cmd.replace(cmd[0], '', 1)
|
if cmd[0] in prefixes:
|
||||||
command.prefix=cmd[0]
|
cmd=cmd.replace(cmd[0], '', 1)
|
||||||
elif cmd.startswith(self_nick+":"):
|
command.prefix=cmd[0]
|
||||||
cmd=cmd.replace(self_nick+":", '', 1)
|
elif cmd.startswith(self_nick+":"):
|
||||||
command.prefix=self_nick
|
cmd=cmd.replace(self_nick+":", '', 1)
|
||||||
elif cmd.startswith(self_nick):
|
command.prefix=self_nick
|
||||||
cmd=cmd.replace(self_nick, '', 1)
|
elif cmd.startswith(self_nick):
|
||||||
command.prefix=self_nick
|
cmd=cmd.replace(self_nick, '', 1)
|
||||||
|
command.prefix=self_nick
|
||||||
|
except IndexError:
|
||||||
|
cmd="none of yer biznez"
|
||||||
cmd=cmd.strip()
|
cmd=cmd.strip()
|
||||||
is_adm=line.source in admin_users or line.tags["account"] in admin_accounts
|
is_adm=line.source in admin_users or line.tags["account"] in admin_accounts
|
||||||
command.line=line
|
command.line=line
|
||||||
|
@ -100,7 +105,7 @@ def stuff(bot,sock):
|
||||||
command.exec_cmd("help",[prefixes,enabled_commands,admin_commands])
|
command.exec_cmd("help",[prefixes,enabled_commands,admin_commands])
|
||||||
if cmd.startswith("help "):
|
if cmd.startswith("help "):
|
||||||
topic=cmd.split(" ",1)[1]
|
topic=cmd.split(" ",1)[1]
|
||||||
command.exec_cmd("help",[prefixes,enabled_commands,admin_commands,topic])
|
command.exec_cmd("help",[prefixes,enabled_commands,admin_commands,topic,self_nick])
|
||||||
elif is_adm and (cmd=="q" or cmd=="quit"):
|
elif is_adm and (cmd=="q" or cmd=="quit"):
|
||||||
quit()
|
quit()
|
||||||
elif is_adm and (cmd.startswith("q ") or cmd.startswith("quit")):
|
elif is_adm and (cmd.startswith("q ") or cmd.startswith("quit")):
|
||||||
|
|
2
util.py
2
util.py
|
@ -15,7 +15,7 @@ class Util:
|
||||||
else: self.send("NICK "+nick)
|
else: self.send("NICK "+nick)
|
||||||
def mesg(self,msg: str,t=None):
|
def mesg(self,msg: str,t=None):
|
||||||
if t==None: t=self.target
|
if t==None: t=self.target
|
||||||
msg=msg.partition("\n")[0]
|
msg=str(msg).partition("\n")[0]
|
||||||
if len(msg)>=900:
|
if len(msg)>=900:
|
||||||
msg=msg[:900]
|
msg=msg[:900]
|
||||||
mesg("message too long!")
|
mesg("message too long!")
|
||||||
|
|
Loading…
Reference in New Issue