This repository has been archived by the owner on Jul 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 244
Add dialog open method from https://github.com/prestonhale/slacker/ fixed by jahirfiquitiva #134
Open
Upgreydd
wants to merge
1
commit into
os:master
Choose a base branch
from
Upgreydd:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18
−5
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ | |
|
||
from slacker.utils import get_item_id_by_name | ||
|
||
|
||
__version__ = '0.9.65' | ||
|
||
API_BASE_URL = 'https://slack.com/api/{api}' | ||
|
@@ -34,7 +33,7 @@ | |
'Stars', 'Emoji', 'Presence', 'RTM', 'Team', 'Reactions', 'Pins', | ||
'UserGroups', 'UserGroupsUsers', 'MPIM', 'OAuth', 'DND', 'Bots', | ||
'FilesComments', 'Reminders', 'TeamProfile', 'UsersProfile', | ||
'IDPGroups', 'Apps', 'AppsPermissions', 'Slacker'] | ||
'IDPGroups', 'Apps', 'AppsPermissions', 'Slacker', 'Dialog'] | ||
|
||
|
||
class Error(Exception): | ||
|
@@ -47,6 +46,7 @@ def __init__(self, body): | |
self.body = json.loads(body) | ||
self.successful = self.body['ok'] | ||
self.error = self.body.get('error') | ||
self.message = self.body.get('response_metadata', {}).get('messages') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you remove this line as it's not a part of this PR? There's another PR addressing this. |
||
|
||
def __str__(self): | ||
return json.dumps(self.body) | ||
|
@@ -78,7 +78,7 @@ def _request(self, method, api, **kwargs): | |
|
||
# handle HTTP 429 as documented at | ||
# https://api.slack.com/docs/rate-limits | ||
elif response.status_code == requests.codes.too_many: # HTTP 429 | ||
elif response.status_code == requests.codes.too_many: # HTTP 429 | ||
time.sleep(int(response.headers.get('retry-after', DEFAULT_WAIT))) | ||
continue | ||
|
||
|
@@ -96,7 +96,10 @@ def _request(self, method, api, **kwargs): | |
|
||
response = Response(response.text) | ||
if not response.successful: | ||
raise Error(response.error) | ||
error = response.error | ||
if response.message: | ||
error = "{error}: {response.message}" | ||
raise Error(error) | ||
Comment on lines
-99
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you remove this section as it's not directly related to this PR? Although I'm not a big fan of this as I want to keep the implementation as close as the original API as possible. |
||
|
||
return response | ||
|
||
|
@@ -456,7 +459,7 @@ def history(self, channel, latest=None, oldest=None, count=None, | |
'oldest': oldest, | ||
'count': count, | ||
'inclusive': inclusive, | ||
'unreads' : int(unreads) | ||
'unreads': int(unreads) | ||
Comment on lines
-459
to
+462
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice 🍰 Thanks. |
||
}) | ||
|
||
def replies(self, channel, thread_ts): | ||
|
@@ -988,6 +991,15 @@ def permissions(self): | |
return self._permissions | ||
|
||
|
||
class Dialog(BaseAPI): | ||
def open(self, dialog, trigger_id): | ||
return self.post('dialog.open', | ||
data={ | ||
'dialog': json.dumps(dialog), | ||
'trigger_id': trigger_id | ||
}) | ||
|
||
|
||
class IncomingWebhook(object): | ||
def __init__(self, url=None, timeout=DEFAULT_TIMEOUT, proxies=None): | ||
self.url = url | ||
|
@@ -1044,6 +1056,7 @@ def __init__(self, token, incoming_webhook_url=None, | |
self.reactions = Reactions(**api_args) | ||
self.idpgroups = IDPGroups(**api_args) | ||
self.usergroups = UserGroups(**api_args) | ||
self.dialog = Dialog(**api_args) | ||
self.incomingwebhook = IncomingWebhook(url=incoming_webhook_url, | ||
timeout=timeout, proxies=proxies) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove this line as well?