<feed xmlns='http://www.w3.org/2005/Atom'>
<title>irssi-slack-profile/slack_profile.pl, branch v1.00</title>
<subtitle>Get whois information about Slack users in Irssi</subtitle>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/irssi-slack-profile/'/>
<entry>
<title>Add comment header documentation to all subroutines</title>
<updated>2016-09-18T03:12:39+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-09-18T03:12:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/irssi-slack-profile/commit/?id=467772933cb1fba2b9a78435e20b46d14ee03fa9'/>
<id>467772933cb1fba2b9a78435e20b46d14ee03fa9</id>
<content type='text'>
Provide descriptions of what all subroutines do along with examples in
some cases.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Provide descriptions of what all subroutines do along with examples in
some cases.
</pre>
</div>
</content>
</entry>
<entry>
<title>Document `slack_profile_sync` &amp; `slack_profile_set` in script header</title>
<updated>2016-09-18T02:31:48+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-09-18T02:31:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/irssi-slack-profile/commit/?id=bf4a20ee7e4611d48b65e78a1cb73d48d7f94753'/>
<id>bf4a20ee7e4611d48b65e78a1cb73d48d7f94753</id>
<content type='text'>
Add brief information about these two commands to the script's comment
header as an additional documentation resource. This also builds on the
brief documentation of the `/swhois` command here.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add brief information about these two commands to the script's comment
header as an additional documentation resource. This also builds on the
brief documentation of the `/swhois` command here.
</pre>
</div>
</content>
</entry>
<entry>
<title>help: Add built-in help for `slack_profile_sync` &amp; `slack_profile_set`</title>
<updated>2016-09-18T02:28:30+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-09-18T02:28:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/irssi-slack-profile/commit/?id=e61989c9d9e251642dd361832181c4a9494aedae'/>
<id>e61989c9d9e251642dd361832181c4a9494aedae</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>print_whois: Pad labels to vertically align colons</title>
<updated>2016-09-18T01:10:17+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-09-18T01:10:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/irssi-slack-profile/commit/?id=fac1321b1b459fb885fa1a49f84a803d61ad998e'/>
<id>fac1321b1b459fb885fa1a49f84a803d61ad998e</id>
<content type='text'>
Previously, if field labels were longer than five charaters, they
wouldn't be aligned with the colons `:` of the other fields in WHOIS
output.

The lack of alignment didn't look good.

This change pads the field labels with spaces on their right side to
make the colons line up visually and vertically.

We also make a more fundamental change to how the subroutine works.
Instead of trying to print fields immediately using `maybe_print_field`,
they are instead added to an array of hashes. When we want to print
fields, we loop over this array and only print those fields that contain
non-blank values.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, if field labels were longer than five charaters, they
wouldn't be aligned with the colons `:` of the other fields in WHOIS
output.

The lack of alignment didn't look good.

This change pads the field labels with spaces on their right side to
make the colons line up visually and vertically.

We also make a more fundamental change to how the subroutine works.
Instead of trying to print fields immediately using `maybe_print_field`,
they are instead added to an array of hashes. When we want to print
fields, we loop over this array and only print those fields that contain
non-blank values.
</pre>
</div>
</content>
</entry>
<entry>
<title>complete_profile_field: Correctly get current nick</title>
<updated>2016-09-17T22:17:51+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-09-17T22:17:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/irssi-slack-profile/commit/?id=11b0f2589004d78841f249deaa3a9b0390d91a9f'/>
<id>11b0f2589004d78841f249deaa3a9b0390d91a9f</id>
<content type='text'>
Previously we tried getting the current nick as `$server-&gt;{'nick'}`.
This was, however, just a placeholder. Sure, it's how we got the current
nick in an `Irssi::command_bind`, but we don't have a `$server` argument
passed to us in the `complete word` signal.

Instead, we get the current server from the active window passed to the
signal, and from that server then obtain the current nick.

This allows us to add custom field labels to the completion list.

We also wrap all of this in an `if` statement that checks whether there
is an active server on the window object. If not, then we don't add
custom fields to the completion list. Without this condition, trying to
use `$window-&gt;{'active_server'}` would prevent _all_ completions from
working. Instead, we still want default Slack profile fields to continue
working because they don't depend on an API call. We just want to
disable completions for custom fields because they depend on a request
to the user profile API endpoint.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously we tried getting the current nick as `$server-&gt;{'nick'}`.
This was, however, just a placeholder. Sure, it's how we got the current
nick in an `Irssi::command_bind`, but we don't have a `$server` argument
passed to us in the `complete word` signal.

Instead, we get the current server from the active window passed to the
signal, and from that server then obtain the current nick.

This allows us to add custom field labels to the completion list.

We also wrap all of this in an `if` statement that checks whether there
is an active server on the window object. If not, then we don't add
custom fields to the completion list. Without this condition, trying to
use `$window-&gt;{'active_server'}` would prevent _all_ completions from
working. Instead, we still want default Slack profile fields to continue
working because they don't depend on an API call. We just want to
disable completions for custom fields because they depend on a request
to the user profile API endpoint.
</pre>
</div>
</content>
</entry>
<entry>
<title>find_user: Only request custom fields &amp; presence if not already there</title>
<updated>2016-09-17T22:11:33+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-09-17T22:11:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/irssi-slack-profile/commit/?id=5290854d1dfa9c6750c153574b6dcca40e41121e'/>
<id>5290854d1dfa9c6750c153574b6dcca40e41121e</id>
<content type='text'>
Previously we would make API requests for user profile information and
presence information every time we invoked `find_user($nick)`.

Since we store all users in memory in `@users_list`, once that data is
requested the first time, it's saved for future use.

If the data is already there locally in memory, there's no point in
wasting time and network to request the data again. So only make the API
requests if we don't already have the data.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously we would make API requests for user profile information and
presence information every time we invoked `find_user($nick)`.

Since we store all users in memory in `@users_list`, once that data is
requested the first time, it's saved for future use.

If the data is already there locally in memory, there's no point in
wasting time and network to request the data again. So only make the API
requests if we don't already have the data.
</pre>
</div>
</content>
</entry>
<entry>
<title>update_user_profile: Use correct nick</title>
<updated>2016-09-17T22:00:45+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-09-17T22:00:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/irssi-slack-profile/commit/?id=cabbb06d4f9b4d6a527698e17481402c2084a66c'/>
<id>cabbb06d4f9b4d6a527698e17481402c2084a66c</id>
<content type='text'>
Previously the subroutine tried to use a nonexistent `$server` variable
to get the current user's nick.

To fix that, we get the server nick in `cmd_set` where we have access to
it and then pass the nick to `update_user_profile`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously the subroutine tried to use a nonexistent `$server` variable
to get the current user's nick.

To fix that, we get the server nick in `cmd_set` where we have access to
it and then pass the nick to `update_user_profile`.
</pre>
</div>
</content>
</entry>
<entry>
<title>complete_profile_field: Add custom fields to completion list</title>
<updated>2016-09-17T21:54:07+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-09-17T21:54:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/irssi-slack-profile/commit/?id=735ffb157c4201b92ede11edd2fd1461cf8c8e85'/>
<id>735ffb157c4201b92ede11edd2fd1461cf8c8e85</id>
<content type='text'>
In addition to the Slack defaults, add custom fields as completions to
give users an easy way to modify those as well.

We move the requests for the custom fields (profile endpoint) and
presence information into `find_user` instead of `swhois` because
otherwise the custom fields aren't available to `complete_profile_field`
or `update_user_profile` unless an `/swhois` has previously been run for
the current nick. That was a bug.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In addition to the Slack defaults, add custom fields as completions to
give users an easy way to modify those as well.

We move the requests for the custom fields (profile endpoint) and
presence information into `find_user` instead of `swhois` because
otherwise the custom fields aren't available to `complete_profile_field`
or `update_user_profile` unless an `/swhois` has previously been run for
the current nick. That was a bug.
</pre>
</div>
</content>
</entry>
<entry>
<title>cmd_set: Only call `update_user_profile` if `$key` is set</title>
<updated>2016-09-17T10:51:09+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-09-17T10:51:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/irssi-slack-profile/commit/?id=fbcd0dce92f8fb57d85893b68cd85c9c7466ec6a'/>
<id>fbcd0dce92f8fb57d85893b68cd85c9c7466ec6a</id>
<content type='text'>
If the `/slack_profile_set` command is called with no arguments (in this
case, no key), then don't call this subroutine because it requests the
Slack API. We should only make remote requests when we have enough
information.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If the `/slack_profile_set` command is called with no arguments (in this
case, no key), then don't call this subroutine because it requests the
Slack API. We should only make remote requests when we have enough
information.
</pre>
</div>
</content>
</entry>
<entry>
<title>complete_profile_field: Fill in rest of field name</title>
<updated>2016-09-17T10:48:34+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-09-17T10:48:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/irssi-slack-profile/commit/?id=586fabf96c50c5aa8e6811dab136b8d7d0318054'/>
<id>586fabf96c50c5aa8e6811dab136b8d7d0318054</id>
<content type='text'>
Previously we would replace the argument with the completion regardless
of what the user typed.

With this change, if they started to type one of the available fields
(e.g. `/slack_profile_set ph&lt;TAB&gt;`), then the argument will complete
with the rest of the field name.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously we would replace the argument with the completion regardless
of what the user typed.

With this change, if they started to type one of the available fields
(e.g. `/slack_profile_set ph&lt;TAB&gt;`), then the argument will complete
with the rest of the field name.
</pre>
</div>
</content>
</entry>
</feed>
