diff options
| author | Fulgen301 <tokmajigeorge@gmail.com> | 2017-03-19 16:03:43 +0100 |
|---|---|---|
| committer | Fulgen301 <tokmajigeorge@gmail.com> | 2017-07-11 11:10:32 +0200 |
| commit | 9f910a0e935204653a23767fd8d22cee200bd417 (patch) | |
| tree | 1a03f7e75318bded3353fa9c2278397ec9adaa60 | |
| parent | 611216b5d60faef53adb237bd9865ee795ac4348 (diff) | |
| download | pycrctrl-9f910a0e935204653a23767fd8d22cee200bd417.tar.gz pycrctrl-9f910a0e935204653a23767fd8d22cee200bd417.zip | |
Fixes
| -rw-r--r-- | pycrctrl/__pycache__/plugin.cpython-36.pyc | bin | 0 -> 1583 bytes | |||
| -rw-r--r-- | pycrctrl/__pycache__/pycrctrl.cpython-36.pyc | bin | 0 -> 20510 bytes | |||
| -rw-r--r-- | pycrctrl/pycrctrl.py | 49 |
3 files changed, 18 insertions, 31 deletions
diff --git a/pycrctrl/__pycache__/plugin.cpython-36.pyc b/pycrctrl/__pycache__/plugin.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..16ed639 --- /dev/null +++ b/pycrctrl/__pycache__/plugin.cpython-36.pyc diff --git a/pycrctrl/__pycache__/pycrctrl.cpython-36.pyc b/pycrctrl/__pycache__/pycrctrl.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..1d536d6 --- /dev/null +++ b/pycrctrl/__pycache__/pycrctrl.cpython-36.pyc diff --git a/pycrctrl/pycrctrl.py b/pycrctrl/pycrctrl.py index 70a87a8..749989b 100644 --- a/pycrctrl/pycrctrl.py +++ b/pycrctrl/pycrctrl.py @@ -264,15 +264,14 @@ class PyCRCtrl(object): if self.config["Clonk"]["Updater"]["enabled"]: self.updater = Updater(self) - for dir in self.config["General"]["Directories"]["plugins"]: - for p in os.listdir(dir): - try: - self.plugins.append(plugins.loadPluginClass(plugins.loadPlugin(p, dir))) - except Exception: - pass + for p in os.listdir(os.path.join(self.path, "plugins")): + try: + self.plugins.append(plugins.loadPluginClass(plugins.loadPlugin(p, dir))) + except Exception: + pass def __ostream__(self, ostream): - return "PyCRCtrl: commandline: {}, channel: {}, scenario: {}".format(self.commandline, self.channels["ingame"], (self.scenario if self.scenario != "" else "None")) + return "PyCRCtrl: commandline: {}, channel: {}, scenario: {}".format(self.commandline, self.config["Clonk"]["IRC"]["Channels"]["ingame"], (self.scenario if self.scenario != "" else "None")) @property def state(self): @@ -307,6 +306,9 @@ class PyCRCtrl(object): return True + def setConfigEntry(self, *args): + pass + def loadCapabilities(self) -> bool: if self.path == None: return False @@ -320,22 +322,17 @@ class PyCRCtrl(object): return False conf = os.path.join(self.path, config) - print(config) if os.path.isdir(conf): return False elif os.path.isfile(conf): self.config = json.load(open(conf, "r")) - return True elif not os.path.exists(conf): c = { "General" : { - "Directories" : { - "plugins" : [] - }, - "useLogfile" : True, + "useLogfile" : True }, "Clonk" : { @@ -383,7 +380,9 @@ class PyCRCtrl(object): } json.dump(c, open(conf, "w"), indent=4) - return c + + self.config = self.setupConfig(c) + return True def setupConfig(self, config): #commandline @@ -402,17 +401,6 @@ class PyCRCtrl(object): def decodeRegExp(self, regexp): return self.codec.toUnicode(base64.b64decode(regexp)) - - def setConfigEntry(self, entry="", value=None): - if type(self.config) != dict: - return - - try: - self.config[entry] = value - finally: - json.dump(self.config, open(os.path.join(self.path, "pycrctrl.conf"), "w"),indent=4) - - return True def host(self, scenario=None, user=None) -> str: if scenario == None: @@ -452,7 +440,6 @@ class PyCRCtrl(object): self.scenario = random.choice(self.scenlist) self.capabilities = deepcopy(self._capa_old) - commandline = self.clonk = subprocess.Popen( './{} {} "{}"'.format(self.config["Clonk"]["engine"], self.config["Clonk"]["commandline"] + self.config["Clonk"]["commandlinePrefix"] + ("league" if self.scenario in self.league_scenlist() else "noleague"),self.scenario), 0, @@ -498,7 +485,7 @@ class PyCRCtrl(object): if output[0] == ">": output = output[1:] - part = re.match("<(.*)> ({})(.*)".format(self.config["Clonk"]["prefix"), output) + part = re.match("<(.*)> ({})(.*)".format(self.config["Clonk"]["prefix"], output)) if part and part.group(0) != self.irc.nick: cmd = part.group(3).split(" ", 1) found = False @@ -532,10 +519,10 @@ class PyCRCtrl(object): if self.irc and self.ingamechat == "aktiviert": if output.find("<" + self.irc.nick + ">") == -1: if re.match(r"^<.*>", output) and output.find("[IRC]") == -1 and output.find(self.config["Clonk"]["prefix"]) == -1: - self.irc.reply("[Clonk]{}".format(output), to=self.config["Clonk"]["IRC"]["channels"]["ingame"]) + self.irc.reply("[Clonk]{}".format(output), to=self.config["Clonk"]["IRC"]["Channels"]["ingame"]) elif self.config["Clonk"]["RegExps"]["joinExp"].match(output) or self.config["Clonk"]["RegExps"]["leaveExp"].match(output): - self.irc.reply(output, to=self.config["Clonk"]["IRC"]["channels"]["ingame"]) + self.irc.reply(output, to=self.config["Clonk"]["IRC"]["Channels"]["ingame"]) except KeyboardInterrupt: @@ -552,7 +539,7 @@ class PyCRCtrl(object): if not (self.irc and self.ingamechat == "aktiviert"): return for channel in msg.args[0].split(","): - if channel == self.config["Clonk"]["IRC]["channels"]["ingame"] and msg.nick != self.irc.nick: + if channel == self.config["Clonk"]["IRC"]["Channels"]["ingame"] and msg.nick != self.irc.nick: self.writeToServer("[IRC]<{}> {}".format(msg.nick, msg.args[1])) @@ -585,7 +572,7 @@ class PyCRCtrl(object): else: self.topic = text - return bool(self.irc.sendMsg(ircmsgs.topic(self.config.get("channels")["ingame"], text))) + return bool(self.irc.sendMsg(ircmsgs.topic(self.config.get("Channels")["ingame"], text))) def admin(self, prm=None, user=""): """Setzt den Rundenadmin.""" |
