@@ -61,8 +61,8 @@ def __str__(self):
6161 def __repr__ (self ):
6262 return self .__str__ ()
6363
64- def rtm_connect (self , reconnect = False ):
65- reply = self .api_requester .do (self .token , "rtm.start" )
64+ def rtm_connect (self , reconnect = False , timeout = None ):
65+ reply = self .api_requester .do (self .token , "rtm.start" , timeout = timeout )
6666 if reply .status_code != 200 :
6767 raise SlackConnectionError
6868 else :
@@ -157,24 +157,26 @@ def attach_channel(self, name, channel_id, members=None):
157157 if self .channels .find (channel_id ) is None :
158158 self .channels .append (Channel (self , name , channel_id , members ))
159159
160- def join_channel (self , name ):
160+ def join_channel (self , name , timeout = None ):
161161 '''
162162 Join a channel by name.
163163
164164 Note: this action is not allowed by bots, they must be invited to channels.
165165 '''
166166 return self .api_requester .do (
167167 self .token ,
168- "channels.join?name={}" .format (name )
168+ "channels.join?name={}" .format (name ),
169+ timeout = timeout
169170 ).text
170171
171- def api_call (self , method , ** kwargs ):
172+ def api_call (self , method , timeout = None , ** kwargs ):
172173 '''
173174 Call the Slack Web API as documented here: https://api.slack.com/web
174175
175176 :Args:
176177 method (str): The API Method to call. See here for a list: https://api.slack.com/methods
177178 :Kwargs:
179+ (optional) timeout: stop waiting for a response after a given number of seconds
178180 (optional) kwargs: any arguments passed here will be bundled and sent to the api
179181 requester as post_data
180182 and will be passed along to the API.
@@ -198,7 +200,7 @@ def api_call(self, method, **kwargs):
198200
199201 See here for more information on responses: https://api.slack.com/web
200202 '''
201- return self .api_requester .do (self .token , method , kwargs ).text
203+ return self .api_requester .do (self .token , method , kwargs , timeout = timeout ).text
202204
203205
204206class SlackConnectionError (Exception ):
0 commit comments