aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-09-10 20:18:48 -0400
committerTeddy Wing2016-09-10 20:18:48 -0400
commit1731ac8887bd685d0ca49d9d947016e1a4075b6c (patch)
tree70914b95c830274768aafa7609f897234d159b8d
parenta5b4ebac0b35bf7ff873b58e68754d3c70df04cf (diff)
downloadirssi-slack-profile-1731ac8887bd685d0ca49d9d947016e1a4075b6c.tar.bz2
Add 'swhois' Irssi command
Create a command that will retrieve 'whois' information about a given user. This command takes a username argument and searches our users.list database for a match. It then prints out a field from the user hash. We'll want to print out more information in a more structured display, but this is just for testing within Irssi. The server conditional check is commented out so I can test this without connecting to a server. Running `/swhois` without an argument should print whois information for the current user/nick. Will have to look up how to get that information.
-rw-r--r--slack-profile.pl25
1 files changed, 25 insertions, 0 deletions
diff --git a/slack-profile.pl b/slack-profile.pl
index 5a654d0..f94c4d8 100644
--- a/slack-profile.pl
+++ b/slack-profile.pl
@@ -54,3 +54,28 @@ sub find_user {
}
}
}
+
+sub swhois {
+ my ($data, $server, $window_item) = @_;
+
+ # if (!$server || !$server->{connected}) {
+ # Irssi::print("Not connected to server");
+ # return;
+ # }
+
+ if ($data) {
+ # If $data starts with @, strip it
+ $data =~ s/^@//;
+
+ # my $user = find_user($data);
+
+ if (my $user = find_user($data)) {
+ Irssi::print($user->{'real_name'});
+ }
+ }
+ else {
+ # find_user(current user nick);
+ }
+}
+
+Irssi::command_bind('swhois', 'swhois');