diff options
| author | Teddy Wing | 2016-09-12 21:55:11 -0400 |
|---|---|---|
| committer | Teddy Wing | 2016-09-12 21:55:11 -0400 |
| commit | 632756c840db15dfc64aa3a3e7c19d0b68bacca1 (patch) | |
| tree | 5841424d7db34924e461f7b2b6edd1e5b6e6e675 | |
| parent | b2adb8415387659671290a7bbe4be6bad10cbf7e (diff) | |
| download | irssi-slack-profile-632756c840db15dfc64aa3a3e7c19d0b68bacca1.tar.bz2 | |
Start of a subroutine to update profile fields
This doesn't work, but includes some rough code to allow updating of
profile fields.
A key and value are passed to the sub. These will be sent to the API as
the field to update. We get the user by querying with the current nick
(we'll have to get the `$server` from somewhere). Then a sample API call
using `slack_api`.
Also include some ideas on how we can update custom fields more easily
because their non-human-readable ids must be used as a key in order to
update them.
| -rw-r--r-- | slack_profile.pl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/slack_profile.pl b/slack_profile.pl index 706da77..d4ddae2 100644 --- a/slack_profile.pl +++ b/slack_profile.pl @@ -156,6 +156,22 @@ sub fetch_user_presence { return $resp->{'presence'}; } +sub update_user_profile { + my ($key, $value) = @_; + + my $user = find_user($server->{'nick'}); + +# Normalize labels s/ /_/g and lowercase +# if $key is not a key in $user, then look for it in $user{fields} +# then set 'name' to the id of the custom field + + my $resp = slack_api('users.profile.set', { + user => $user->{'id'}, + name => $key, + value => $value, + }); +} + sub find_user { my ($username) = @_; |
