diff options
| author | Brock Wilcox | 2014-10-02 17:39:52 -0400 |
|---|---|---|
| committer | John Morrissey | 2014-10-02 17:39:52 -0400 |
| commit | c9ac55a2a507fbf738e169d7b37a13aeba89fa2c (patch) | |
| tree | 8713ce0eeacbc858d72be43f84c48b1917ff2386 /scripts | |
| parent | f79b1a4f9ee0a04aac923a2687c089ad95711150 (diff) | |
| download | scripts.irssi.org-c9ac55a2a507fbf738e169d7b37a13aeba89fa2c.tar.bz2 | |
use hipchat v2 api via WebService::HipChat
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/hipchat_complete.pl | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/scripts/hipchat_complete.pl b/scripts/hipchat_complete.pl index 094b9a6..54a3c52 100644 --- a/scripts/hipchat_complete.pl +++ b/scripts/hipchat_complete.pl @@ -1,4 +1,5 @@ # hipchat_complete.pl - (c) 2013 John Morrissey <jwm@horde.net> +# (c) 2014 Brock Wilcox <awwaiid@thelackthereof.org> # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -46,11 +47,11 @@ # To use # ====== # -# 1. Install the HTTP::Message, JSON, and LWP Perl modules. +# 1. Install the WebService::HipChat module from CPAN. # # 2. /script load hipchat_completion.pl # -# 3. Get a Hipchat auth token (hipchat.com -> Account settings -> API +# 3. Get a Hipchat auth v2 token (hipchat.com -> Account settings -> API # access). In irssi: # # /set hipchat_auth_token some-hex-value @@ -63,12 +64,10 @@ use strict; -use HTTP::Request; use Irssi; -use JSON; -use LWP::UserAgent; +use WebService::HipChat; -my $VERSION = '1.0'; +my $VERSION = '2.0'; my %IRSSI = ( authors => 'John Morrissey', contact => 'jwm@horde.net', @@ -81,18 +80,13 @@ my %NICK_TO_MENTION; my $LAST_MAP_UPDATED = 0; sub get_hipchat_people { - my $ua = LWP::UserAgent->new; - $ua->timeout(5); - my $auth_token = Irssi::settings_get_str('hipchat_auth_token'); if (!$auth_token) { return; } - my $r = HTTP::Request->new('GET', - "https://api.hipchat.com/v1/users/list?auth_token=$auth_token"); - my $response = $ua->request($r); + my $hc = WebService::HipChat->new(auth_token => $auth_token); - my $hipchat_users = from_json($response->decoded_content)->{users}; + my $hipchat_users = $hc->get_users->{items}; foreach my $user (@{$hipchat_users}) { my $name = $user->{name}; $name =~ s/[^A-Za-z]//g; |
