hot reload!
This commit is contained in:
parent
695163453c
commit
68ee237c14
|
@ -4,6 +4,7 @@ class Command:
|
|||
self.sock=sock
|
||||
self.util=Util(sock)
|
||||
def mesg(self,msg): self.util.mesg(msg)
|
||||
def err_perm(self,level="admin"): mesg("Error: insufficient privileges, you lack {level} access")
|
||||
def exec_cmd(self,command,extra=[None]):
|
||||
if extra!=[None]:
|
||||
eval(f"self.{command}(self.prefix,self.cmd,self.pm,self.line,self.admin,extra)")
|
||||
|
@ -35,3 +36,11 @@ class Command:
|
|||
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
|
||||
if admin:
|
||||
mesg("reloading...")
|
||||
self.util.reload()
|
||||
mesg("reloaded!")
|
||||
else:
|
||||
err_perm()
|
|
@ -24,4 +24,4 @@ class config:
|
|||
class cmd:
|
||||
prefixes=["6","'"]
|
||||
enabled_commands=["help","echo"]
|
||||
admin_commands=["eval","quit"]
|
||||
admin_commands=["eval","quit","reload"]
|
||||
|
|
11
stuff.py
11
stuff.py
|
@ -1,8 +1,10 @@
|
|||
import irctokens
|
||||
from config import config
|
||||
from config import config as Config
|
||||
from util import Util
|
||||
from command import Command
|
||||
from commands import Command
|
||||
import sys, importlib
|
||||
def stuff(bot,sock):
|
||||
config=Config
|
||||
chan=config.server.channel
|
||||
util=Util(sock)
|
||||
command=Command(sock)
|
||||
|
@ -93,6 +95,11 @@ def stuff(bot,sock):
|
|||
quit()
|
||||
elif is_adm and (cmd.startswith("q ") or cmd.startswith("quit")):
|
||||
quit(cmd.split(" ",1)[1])
|
||||
elif is_adm and cmd.startswith("reload"):
|
||||
# command.exec_cmd("reload")
|
||||
command=importlib.reload(sys.modules["commands"]).Command(sock)
|
||||
config=importlib.reload(sys.modules["config"]).config
|
||||
mesg("reloaded")
|
||||
elif cmd.startswith("eval "):
|
||||
if(is_adm):
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue