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])
|
||||
def help(self,prefix,cmd,pm,line,admin,extra):
|
||||
mesg=self.mesg
|
||||
prefixes=", ".join(extra[0])
|
||||
prefixes="\""+"\", \"".join(extra[0])+"\""
|
||||
enabled_commands=extra[1]
|
||||
admin_commands=", ".join(extra[2])
|
||||
try: topic=extra[3]
|
||||
except IndexError: topic=None
|
||||
try: self_nick=extra[4]
|
||||
except IndexError: self_nick=None
|
||||
abs_topics={
|
||||
"prefixes":"available prefixes are {prefixes} or my name"
|
||||
"prefixes":f"available prefixes are {prefixes} or \"{self_nick}\""
|
||||
}
|
||||
if topic==None:
|
||||
mesg(f"available topics: "+", ".join(enabled_commands+list(abs_topics.keys())))
|
||||
|
@ -30,12 +32,13 @@ class Command:
|
|||
mesg(f"admin commands: {admin_commands}")
|
||||
else:
|
||||
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:
|
||||
mesg(f"{topic}: "+abs_topics[topic])
|
||||
else:
|
||||
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))
|
||||
def reload(self,prefix,cmd,pm,line,admin):
|
||||
mesg=self.mesg
|
||||
|
|
|
@ -24,4 +24,4 @@ class config:
|
|||
class cmd:
|
||||
prefixes=["6","'"]
|
||||
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]}")
|
||||
|
||||
if mode=="init":
|
||||
if line.command == "433":
|
||||
util.nick(config.self.nick+"_")
|
||||
if line.command == "376":
|
||||
send(irctokens.build("CAP", ["LS","302"]).format())
|
||||
elif line.command=="CAP" and line.params[1]=="LS":
|
||||
|
@ -75,18 +77,21 @@ def stuff(bot,sock):
|
|||
util.target=target
|
||||
command.util.target=target
|
||||
if is_pm or line.params[1].startswith(self_nick) or line.params[1][0] in prefixes:
|
||||
cmd=line.params[1]
|
||||
#if message in a channel, remove prefixes
|
||||
if not is_pm:
|
||||
if cmd[0] in prefixes:
|
||||
cmd=cmd.replace(cmd[0], '', 1)
|
||||
command.prefix=cmd[0]
|
||||
elif cmd.startswith(self_nick+":"):
|
||||
cmd=cmd.replace(self_nick+":", '', 1)
|
||||
command.prefix=self_nick
|
||||
elif cmd.startswith(self_nick):
|
||||
cmd=cmd.replace(self_nick, '', 1)
|
||||
command.prefix=self_nick
|
||||
try:
|
||||
cmd=line.params[1]
|
||||
#if message in a channel, remove prefixes
|
||||
if not is_pm:
|
||||
if cmd[0] in prefixes:
|
||||
cmd=cmd.replace(cmd[0], '', 1)
|
||||
command.prefix=cmd[0]
|
||||
elif cmd.startswith(self_nick+":"):
|
||||
cmd=cmd.replace(self_nick+":", '', 1)
|
||||
command.prefix=self_nick
|
||||
elif cmd.startswith(self_nick):
|
||||
cmd=cmd.replace(self_nick, '', 1)
|
||||
command.prefix=self_nick
|
||||
except IndexError:
|
||||
cmd="none of yer biznez"
|
||||
cmd=cmd.strip()
|
||||
is_adm=line.source in admin_users or line.tags["account"] in admin_accounts
|
||||
command.line=line
|
||||
|
@ -100,7 +105,7 @@ def stuff(bot,sock):
|
|||
command.exec_cmd("help",[prefixes,enabled_commands,admin_commands])
|
||||
if cmd.startswith("help "):
|
||||
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"):
|
||||
quit()
|
||||
elif is_adm and (cmd.startswith("q ") or cmd.startswith("quit")):
|
||||
|
|
Loading…
Reference in New Issue