Refactor check_should_open
Make the method a bit easier to follow, and don't use exceptions for
flow control.
@@ -1244,22 +1244,17 @@ class SlackChannel(object):
# self.create_buffer()
def check_should_open(self, force=False):
- try:
- if self.is_archived:
+ if hasattr(self, "is_archived") and self.is_archived:
return
- except:
- pass
+
if force:
self.create_buffer()
- else:
- for reason in ["is_member", "is_open", "unread_count_display"]:
- try:
- if eval("self." + reason):
+ return
+
+ if (hasattr(self, "is_member") and self.is_member) or self.is_open or self.unread_count_display:
self.create_buffer()
if config.background_load_all_history:
self.get_history(slow_queue=True)
- except:
- pass
def set_related_server(self, team):
self.team = team
