aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-09-12 16:32:24 -0400
committerTeddy Wing2016-09-12 16:32:24 -0400
commit68c7884bd109076b1a7c67bedcf91e36ec50ea6c (patch)
tree21600bbedca83a145abc9e1a03e85a6c04d2e7d1
parentb40212e4214b41e2265cf42680a7a995c04f6efc (diff)
downloadirssi-slack-profile-68c7884bd109076b1a7c67bedcf91e36ec50ea6c.tar.bz2
slack_api: Allow API arguments to be passed to the sub
When calling the `slack_api` subroutine, an optional `$args` parameter can be passed which is a hash of Slack API arguments. The token gets added to this hash and the whole thing is set to the API URL query string.
-rw-r--r--slack_profile.pl4
1 files changed, 3 insertions, 1 deletions
diff --git a/slack_profile.pl b/slack_profile.pl
index 4812dbf..f7b1c1d 100644
--- a/slack_profile.pl
+++ b/slack_profile.pl
@@ -90,9 +90,11 @@ sub slack_api {
'Set it with `/set slack_profile_token TOKEN`.' if !$token;
my ($method, $args) = @_;
+ $args ||= {};
+ $args->{'token'} = $token;
my $url = URI->new("https://slack.com/api/$method");
- $url->query_form(token => $token);
+ $url->query_form($args);
my $http = HTTP::Tiny->new(
default_headers => {