def __init__(self, slack_token, reporting_channel, state):
"""Connect to Slack and setup the object."""
self.channels = {}
self.client = SlackClient(slack_token)
if self.client.rtm_connect():
print("HueBot connected to Slack!")
else:
print("HueBot did not connect to Slack")
raise IOError
self.reporting_channel = reporting_channel
self.state = state
self.state.on_new_failure = self.message_failure
self.state.on_new_warning = self.message_warning
# Retrieve parse functions
self.parse_functions = []
for attr_name in dir(self):
attr = getattr(self, attr_name)
try:
if attr._parse_func:
self.parse_functions.append(attr)
except AttributeError:
pass
评论列表
文章目录