aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-09-12 20:12:15 -0400
committerTeddy Wing2016-09-12 20:12:15 -0400
commit2010943f30ccddf5e206e82074a118f296a50075 (patch)
treed5dce8f096f6f744949a98c8ba830bf36a5403ae
parent2b5f32064be5d7482b91e214f533970f86a54538 (diff)
downloadirssi-slack-profile-2010943f30ccddf5e206e82074a118f296a50075.tar.bz2
Add user presence to WHOIS output
Display whether the requested user is online or away.
-rw-r--r--slack_profile.pl15
1 files changed, 15 insertions, 0 deletions
diff --git a/slack_profile.pl b/slack_profile.pl
index 6d5b9d2..91a4c7a 100644
--- a/slack_profile.pl
+++ b/slack_profile.pl
@@ -140,6 +140,16 @@ sub fetch_user_profile {
return $resp->{'profile'};
}
+sub fetch_user_presence {
+ my ($user) = @_;
+
+ my $resp = slack_api('users.getPresence', {
+ user => $user->{'id'}
+ });
+
+ return $resp->{'presence'};
+}
+
sub find_user {
my ($username) = @_;
@@ -190,6 +200,8 @@ sub print_whois {
maybe_print_field($label, $value);
}
+ maybe_print_field('status', $user->{'presence'});
+
Irssi::print('End of SWHOIS');
}
@@ -212,6 +224,9 @@ sub swhois {
my $profile = fetch_user_profile($user);
$user->{'fields'} = $profile->{'fields'};
+ my $presence = fetch_user_presence($user);
+ $user->{'presence'} = $presence;
+
print_whois($user);
}
}