diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-03-02 19:14:42 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2020-03-02 21:37:22 +0100 |
commit | a7ef45db66ade0e96a4ea1cb45102827089cb9ef (patch) | |
tree | f9bbfc7102870865f597c3a0464a53c66bd99507 /wee_slack.py | |
parent | 5c4fc0b9e9a00f46bb8d069b5f584c69108b1828 (diff) | |
download | wee-slack-a7ef45db66ade0e96a4ea1cb45102827089cb9ef.tar.gz |
Show away in away bar item when presence is away
This shows it in the standard away bar item, and also adds a specific
one for wee-slack. The reason for including the specific one is that if
multiple scripts in the same plugin define the same bar item, only one
of them will work[0]. So people that have another python script which
also defines the away bar item can use the slack_away bar item instead.
[0]: https://github.com/weechat/weechat/issues/1348
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py index 2239ccd..b845105 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -969,6 +969,19 @@ def typing_bar_item_cb(data, item, current_window, current_buffer, extra_info): @utf8_decode +def away_bar_item_cb(data, item, current_window, current_buffer, extra_info): + channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer) + if not channel: + return '' + + if channel.team.is_user_present(channel.team.myidentifier): + return '' + else: + away_color = w.config_string(w.config_get('weechat.color.item_away')) + return colorize_string(away_color, 'away') + + +@utf8_decode def channel_completion_cb(data, completion_item, current_buffer, completion): """ Adds all channels on all teams to completion list @@ -2817,6 +2830,9 @@ def process_presence_change(message_json, eventrouter, team, channel, metadata): users.append(metadata["user"]) for user in users: team.update_member_presence(user, message_json["presence"]) + if team.myidentifier in users: + w.bar_item_update("away") + w.bar_item_update("slack_away") process_manual_presence_change = process_presence_change @@ -4452,6 +4468,8 @@ def load_emoji(): def setup_hooks(): w.bar_item_new('slack_typing_notice', '(extra)typing_bar_item_cb', '') + w.bar_item_new('away', '(extra)away_bar_item_cb', '') + w.bar_item_new('slack_away', '(extra)away_bar_item_cb', '') w.hook_timer(5000, 0, 0, "ws_ping_cb", "") w.hook_timer(1000, 0, 0, "typing_update_cb", "") |