Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def rtm_connect(self, reconnect=False, timeout=None, use_rtm_start=True, **kwargs):
# rtm.start returns user and channel info, rtm.connect does not.
connect_method = "rtm.start" if use_rtm_start else "rtm.connect"
reply = self.api_requester.do(self.token, connect_method, timeout=timeout, post_data=kwargs)
if reply.status_code != 200:
raise SlackConnectionError(reply=reply)
else:
login_data = reply.json()
if login_data["ok"]:
self.ws_url = login_data['url']
self.connect_slack_websocket(self.ws_url)
if not reconnect:
self.parse_slack_login_data(login_data, use_rtm_start)
else:
raise SlackLoginError(reply=reply)
time.sleep(retry_after)
self.rtm_connect(reconnect=reconnect, timeout=timeout)
else:
raise SlackConnectionError(
"RTM connection attempt was rate limited 5 times."
)
else:
self.rtm_connect_retries = 0
login_data = reply.json()
if login_data["ok"]:
self.ws_url = login_data["url"]
self.connect_slack_websocket(self.ws_url)
if not reconnect:
self.parse_slack_login_data(login_data, use_rtm_start)
else:
raise SlackLoginError(reply=reply)
def __init__(self, message='', reply=None):
super(SlackLoginError, self).__init__(message)
self.reply = reply
def __init__(self, message="", reply=None):
super(SlackLoginError, self).__init__(message)
self.reply = reply
def coffee_is_done():
db = CoffeeDB(db_name='grandma.db') # FIXME how to test it - Makefile?
bot = Grandma(db)
try:
bot.connect()
except SlackLoginError:
abort(500)
bot.notify()
return ''