Commits

Adam Coddington  committed b3dce79

Check for keyerror exception when gathering keys. Bumping version number.

  • Participants
  • Parent commits 509c459
  • Tags 1.0.4

Comments (0)

Files changed (2)

File teamspeaknotifier/__init__.py

 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 __author__ = 'Adam Coddington <me@adamcoddington.net>'
-__version__ = (1, 0, 3)
+__version__ = (1, 0, 4)
 
 def run_from_cmdline():
     import logging

File teamspeaknotifier/notifier.py

         self.logger.info("Updated client list: %s" % self.clients)
 
     def message_is_mine(self, message):
-        if 'clid' in message.keys():
-            return message['clid'] == self.identity
-        elif 'invokerid' in message.keys():
-            return message['invokerid'] == self.identity
-        elif 'invokername' in message.keys():
-            return self.clients[self.identity] == message['invokername']
+        try:
+            if 'clid' in message.keys():
+                return message['clid'] == self.identity
+            elif 'invokerid' in message.keys():
+                return message['invokerid'] == self.identity
+            elif 'invokername' in message.keys():
+                return self.clients[self.identity] == message['invokername']
+        except KeyError:
+            pass
         return False
 
     def get_name_for_message(self, message):
-        if 'clid' in message.keys():
-            return self.clients[message['clid']]
-        elif 'invokerid' in message.keys():
-            return self.clients[message['invokerid']]
-        elif 'invokername' in message.keys():
-            return message['invokername']
+        try:
+            if 'clid' in message.keys():
+                return self.clients[message['clid']]
+            elif 'invokerid' in message.keys():
+                return self.clients[message['invokerid']]
+            elif 'invokername' in message.keys():
+                return message['invokername']
+        except KeyError:
+            pass
         return self.DEFAULT_NAME
 
     def teamspeak_is_active(self):