From 96c975233c71ee3c6c7c23af3c07f4ac89d9f6a3 Mon Sep 17 00:00:00 2001 From: Alexei Sorokin Date: Wed, 24 Aug 2016 02:16:37 +0300 Subject: [PATCH] Work in the directory where hptoad.py is located --- hptoad.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hptoad.py b/hptoad.py index a3b2cdf..9294bc9 100755 --- a/hptoad.py +++ b/hptoad.py @@ -160,7 +160,7 @@ class Zhobe: reply = "%s: GTFO" % nick elif body.startswith("!"): # Any external command. - reply, err = self.extern_cmd(body, nick, from_id, "./plugins", + reply, err = self.extern_cmd(body, nick, from_id, "plugins", is_admin=is_admin) return reply, err @@ -190,7 +190,7 @@ class Zhobe: elif call_regexp.match(body): # Chat. cmd_body = call_regexp.sub("!answer", body) - reply, err = self.extern_cmd(cmd_body, nick, from_id, "./chat", + reply, err = self.extern_cmd(cmd_body, nick, from_id, "chat", is_admin=is_admin) if err: @@ -277,11 +277,16 @@ class Zhobe: if __name__ == "__main__": signal.signal(signal.SIGINT, signal.SIG_DFL) + logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(message)s", datefmt="%Y/%m/%d %H:%M:%S") # Silence sleekxmpp debug information. logging.getLogger("sleekxmpp").setLevel(logging.CRITICAL) + + if os.path.isfile(sys.argv[0]) and os.path.dirname(sys.argv[0]): + os.chdir(os.path.dirname(sys.argv[0])) + zhobe = Zhobe(opts) while True: zhobe.run()