diff options
author | tv <tv@nomic.retiolum> | 2014-04-25 12:52:05 +0200 |
---|---|---|
committer | tv <tv@nomic.retiolum> | 2014-04-25 12:52:05 +0200 |
commit | 5efd6c0b11ce5b0ab3ec5975bfe6125af7eb6ea4 (patch) | |
tree | 8a82e362714359465c3e7e06a651a85b934ee03d /Reaktor | |
parent | 3907535dd48b94b3edd5facde0245719f04effb2 (diff) |
reaktor getconf: allow default_value
Diffstat (limited to 'Reaktor')
-rw-r--r-- | Reaktor/IRC/getconf.py | 7 | ||||
-rw-r--r-- | Reaktor/IRC/ircasy.py | 5 | ||||
-rwxr-xr-x | Reaktor/IRC/reaktor.py | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/Reaktor/IRC/getconf.py b/Reaktor/IRC/getconf.py index f9cd4404..168c908c 100644 --- a/Reaktor/IRC/getconf.py +++ b/Reaktor/IRC/getconf.py @@ -9,14 +9,17 @@ import os def make_getconf(filename): - def getconf(prop): + def getconf(prop, default_value=None): prop_split = prop.split('.') string = '' config = load_config(filename) #imp.reload(config) tmp = config.__dict__ for pr in prop_split: - tmp = tmp[pr] + if pr in tmp: + tmp = tmp[pr] + else: + return default_value return tmp return getconf diff --git a/Reaktor/IRC/ircasy.py b/Reaktor/IRC/ircasy.py index 259ea98c..9a7f44f3 100644 --- a/Reaktor/IRC/ircasy.py +++ b/Reaktor/IRC/ircasy.py @@ -114,10 +114,7 @@ class asybot(asychat): self.on_kick(prefix, command, params, rest) elif command == 'JOIN': - try: - self.on_join(prefix, command, params, rest) - except: - pass + self.on_join(prefix, command, params, rest) elif command == '433': # ERR_NICKNAMEINUSE, retry with another name diff --git a/Reaktor/IRC/reaktor.py b/Reaktor/IRC/reaktor.py index b53ef651..54091c5d 100755 --- a/Reaktor/IRC/reaktor.py +++ b/Reaktor/IRC/reaktor.py @@ -36,7 +36,7 @@ class Reaktor(asybot): return False def on_join(self, prefix, command, params, rest): - for command in getconf('on_join'): + for command in getconf('on_join', []): self.execute_command(command, None, prefix, params) def on_privmsg(self, prefix, command, params, rest): |