def connect_to_slack(self, token):
# Initiates connection to the server based on the token, receives websocket URL "bot_conn"
logger.info("Starting RTM connection")
bot_conn = self.SLACK_CLIENT.api_call(
"rtm.start",
token = token
)
logger.info("Initializing info")
self.initialize_info()
# Creates WebSocketApp based on the URL returned by the RTM API
# Assigns local methods to websocket methods
logger.info("Initializing WebSocketApplication")
self.WEBSOCKET = websocket.WebSocketApp(bot_conn["url"],
on_message=self.on_message,
on_error=self.on_error,
on_close=self.on_close,
on_open=self.on_open)
评论列表
文章目录