scrapinghub / slackbot

A chat bot for Slack (https://slack.com).
MIT License
1.26k stars 394 forks source link

Add timeout setting for Slacker #175

Closed amjltc295 closed 6 years ago

amjltc295 commented 6 years ago

There are serveral parameters for slacker:

slacker.Slacker(token,
                incoming_webhook_url=None,
                timeout=DEFAULT_TIMEOUT,
                http_proxy=None,
                https_proxy=None,
                session=None,
                rate_limit_retries=DEFAULT_RETRIES)

However, in the previous code, only token is passed to slacker, and timeout could not be set. It uses DEFAULT_TIMEOUT in slacker, which is 10 seconds, not enough for slackbot to upload large file (20MB video for example). In this commit, timeout could be set in settings as token. Bot() would pass it to SlackClient and to Slacker if TIMEOUT exists in settings.

amuraru commented 6 years ago

👍

matthewshirley commented 6 years ago

👍

townie commented 6 years ago

This could use a test...

def test_init_with_timeout():
    client = SlackClient(None, connect=False)
    assert client.webapi.api.timeout == 10  # seconds default timeout

    expected_timeout = 42  # seconds
    client = SlackClient(None, connect=False, timeout=expected_timeout)
    assert client.webapi.api.timeout == expected_timeout

add to tests/unit/test_slackclient.py

amjltc295 commented 6 years ago

@townie Thanks, I have added the test and rebased it on the latest develop.

lins05 commented 6 years ago

Thanks!