slacker icon indicating copy to clipboard operation
slacker copied to clipboard

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

Open Upgreydd opened this issue 6 years ago • 1 comments

Please merge it if building not fails

Upgreydd avatar Jun 05 '18 08:06 Upgreydd

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)

shollingsworth avatar Jun 24 '18 04:06 shollingsworth