def run(self, start=True):
<EOL>if not self.is_setup:<EOL><INDENT>raise NotSetupError<EOL><DEDENT>self.webserver.start()<EOL>first_connect = True<EOL>try:<EOL><INDENT>while self.runnable:<EOL><INDENT>if self.reconnect_needed:<EOL><INDENT>if not self.sc.rtm_connect(with_team_state=start):<EOL><INDENT>return False<EOL><DEDENT>self.reconnect_needed = False<EOL>if first_connect:<EOL><INDENT>first_connect = False<EOL>self.plugins.connect()<EOL><DEDENT><DEDENT>try:<EOL><INDENT>events = self.sc.rtm_read()<EOL><DEDENT>except AttributeError:<EOL><INDENT>self.log.exception('<STR_LIT>')<EOL>self.runnable = False<EOL>events = []<EOL><DEDENT>except:<EOL><INDENT>self.log.exception('<STR_LIT>')<EOL>self.reconnect_needed = True<EOL>events = []<EOL><DEDENT>for e in events:<EOL><INDENT>try:<EOL><INDENT>self._handle_event(e)<EOL><DEDENT>except KeyboardInterrupt:<EOL><INDENT>self.runnable = False<EOL><DEDENT>except:<EOL><INDENT>self.log.exception('<STR_LIT>')<EOL><DEDENT><DEDENT>sleep(<NUM_LIT:0.1>)<EOL><DEDENT><DEDENT>except KeyboardInterrupt:<EOL><INDENT>pass<EOL><DEDENT>except:<EOL><INDENT>self.log.exception('<STR_LIT>')<EOL><DEDENT>
Connects to slack and enters the main loop.

* start - If True, rtm.start API is used. Else rtm.connect API is used

For more info, refer to
https://python-slackclient.readthedocs.io/en/latest/real_time_messaging.html#rtm-start-vs-rtm-connect