diff options
| author | Teddy Wing | 2016-09-12 19:24:16 -0400 |
|---|---|---|
| committer | Teddy Wing | 2016-09-12 19:26:04 -0400 |
| commit | ccb58bce6a0bef02ebdc238cace78b4a8cd1a0c9 (patch) | |
| tree | f216a3a25a4c91e86373534ec244be815b5a170a | |
| parent | ef0ac1da4b67c679ddf431bf25bf32b2305fd2a1 (diff) | |
| download | irssi-slack-profile-ccb58bce6a0bef02ebdc238cace78b4a8cd1a0c9.tar.bz2 | |
print_whois: Make field printing more generic
Don't rely on specific custom fields. Instead, just attach all of them
to the `$user` object that gets passed to `print_whois` and print the
lot in a generic way.
| -rw-r--r-- | slack_profile.pl | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/slack_profile.pl b/slack_profile.pl index 43a3e24..f6eadff 100644 --- a/slack_profile.pl +++ b/slack_profile.pl @@ -182,8 +182,13 @@ sub print_whois { maybe_print_field('phone', $user->{'profile'}->{'phone'}); maybe_print_field('skype', $user->{'profile'}->{'skype'}); maybe_print_field('tz ', $user->{'tz_label'}); - maybe_print_field('gh ', $user->{'GitHub'}); - maybe_print_field('karma', $user->{'Karma'}); + + foreach my $key (keys %{$user->{'fields'}}) { + my $label = $user->{'fields'}->{$key}->{'label'}; + my $value = $user->{'fields'}->{$key}->{'value'}; + + maybe_print_field($label, $value); + } Irssi::print('End of SWHOIS'); } @@ -205,11 +210,7 @@ sub swhois { if (my $user = find_user($username)) { my $profile = fetch_user_profile($user); - foreach my $key (keys %{$profile->{'fields'}}) { - my $label = $profile->{'fields'}->{$key}->{'label'}; - my $value = $profile->{'fields'}->{$key}->{'value'}; - $user->{$label} = $value; - } + $user->{'fields'} = $profile->{'fields'}; print_whois($user); } |
