diff options
| author | Teddy Wing | 2016-09-17 06:28:00 -0400 |
|---|---|---|
| committer | Teddy Wing | 2016-09-17 06:28:00 -0400 |
| commit | 27bccdc42ad093f75b60d56f71651d6b6d0bc8a7 (patch) | |
| tree | a5893ddcb1312756de563149f0ada09a1102e8fe | |
| parent | e0fa2d455da59a40710f87c6f20b8ea891857411 (diff) | |
| download | irssi-slack-profile-27bccdc42ad093f75b60d56f71651d6b6d0bc8a7.tar.bz2 | |
Add completion of default Slack profile fields
When using the `/slack_profile_set` command, complete the key names of
default Slack profile fields. This obviates the need for users to
remember and type the full key name.
Based on:
https://github.com/irssi/scripts.irssi.org/blob/22060fc4669627a9859c92efa2d6651e3673d494/scripts/go.pl
Doesn't work for Slack custom profile fields yet.
Also should probably consolidate repeated `@profile_fields` array.
| -rw-r--r-- | slack_profile.pl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/slack_profile.pl b/slack_profile.pl index 14e96dd..fa00ad2 100644 --- a/slack_profile.pl +++ b/slack_profile.pl @@ -166,6 +166,22 @@ sub underscorize { return $result; } +sub complete_profile_field { + my ($complist, $window, $word, $linestart, $want_space) = @_; + my $slash = Irssi::parse_special('$k'); + + return unless $linestart =~ /^\Q${slash}\Eslack_profile_set\b/i; + + my @profile_fields = qw(first_name last_name email phone skype title); + @$complist = (); + + for my $field (@profile_fields) { + push @$complist, $field; + } + + Irssi::signal_stop(); +} + sub update_user_profile { my ($key, $value) = @_; @@ -290,5 +306,7 @@ Irssi::command_bind('slack_profile_set', 'cmd_set'); Irssi::command_bind('help', 'help'); +Irssi::signal_add('complete word', 'complete_profile_field'); + Irssi::settings_add_str('slack_profile', 'slack_profile_token', ''); |
