diff --git a/README.md b/README.md deleted file mode 100644 index f649660..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# bot6 - diff --git a/commands.py b/commands.py index 6a8f0a7..a89b6df 100644 --- a/commands.py +++ b/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 diff --git a/config.py b/config.py index 521d4d2..fa595fe 100644 --- a/config.py +++ b/config.py @@ -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"] diff --git a/stuff.py b/stuff.py index aa4d251..f65d4bb 100755 --- a/stuff.py +++ b/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")): diff --git a/util.py b/util.py index f3d7485..b0ed7c9 100644 --- a/util.py +++ b/util.py @@ -15,7 +15,7 @@ class Util: else: self.send("NICK "+nick) def mesg(self,msg: str,t=None): if t==None: t=self.target - msg=msg.partition("\n")[0] + msg=str(msg).partition("\n")[0] if len(msg)>=900: msg=msg[:900] mesg("message too long!")