Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Add dialog open method from https://github.com/prestonhale/slacker/ fixed by jahirfiquitiva #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Upgreydd
Copy link

@Upgreydd Upgreydd commented Jun 5, 2018

Please merge it if building not fails

@shollingsworth
Copy link
Contributor

If anybody is interested here was my workaround: I extended the class:

And included it with from extend_slacker import Slacker

extend_slacker.py

# -*- coding: utf-8 -*-
import json
import slacker
# https://github.com/os/slacker/pull/135


class SlackerDialogAdd(slacker.BaseAPI):
    def open(self, dialog, trigger_id):
        return self.post(
            'dialog.open',
            data={
                'dialog': json.dumps(dialog),
                'trigger_id': trigger_id,
            }
        )


# Patching to add Dialog
slacker.__all__.append('Dialog')
slacker.Dialog = SlackerDialogAdd


class Slacker(slacker.Slacker):
    def __init__(
            self,
            token,
            incoming_webhook_url=None,
            timeout=10,
            http_proxy=None,
            https_proxy=None,
            session=None,
            rate_limit_retries=0,
    ):
        slacker.Slacker.__init__(
            self,
            token,
            incoming_webhook_url,
            timeout,
            http_proxy,
            https_proxy,
            session,
            rate_limit_retries,
        )
        proxies = self.__create_proxies(http_proxy, https_proxy)
        api_args = {
            'token': token,
            'timeout': timeout,
            'proxies': proxies,
            'session': session,
            'rate_limit_retries': rate_limit_retries,
        }
        self.dialog = SlackerDialogAdd(**api_args)

@@ -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')
Copy link
Owner

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 it's not a part of this PR? There's another PR addressing this.

@@ -20,7 +20,6 @@

from slacker.utils import get_item_id_by_name


Copy link
Owner

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?

Comment on lines -99 to +102
raise Error(response.error)
error = response.error
if response.message:
error = "{error}: {response.message}"
raise Error(error)
Copy link
Owner

Choose a reason for hiding this comment

The 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.

Comment on lines -459 to +462
'unreads' : int(unreads)
'unreads': int(unreads)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 🍰 Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants