aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-03-02 19:32:50 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2020-03-02 21:37:22 +0100
commite7f539527a3510ec04150a54f62b2c97522bfe57 (patch)
tree9f8e6677c6e55287a70064517d0f3cd782b29d21 /wee_slack.py
parenta7ef45db66ade0e96a4ea1cb45102827089cb9ef (diff)
downloadwee-slack-e7f539527a3510ec04150a54f62b2c97522bfe57.tar.gz
Set presence to active when switching buffer or calling /slack back
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/wee_slack.py b/wee_slack.py
index b845105..ae38816 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -851,10 +851,9 @@ def input_text_for_buffer_cb(data, modifier, current_buffer, string):
@utf8_decode
def buffer_switch_callback(signal, sig_type, data):
"""
- incomplete
Every time we change channels in weechat, we call this to:
1) set read marker 2) determine if we have already populated
- channel history data
+ channel history data 3) set presence to active
"""
eventrouter = eval(signal)
@@ -868,6 +867,7 @@ def buffer_switch_callback(signal, sig_type, data):
if new_channel:
if not new_channel.got_history:
new_channel.get_history()
+ set_own_presence_active(new_channel.team)
eventrouter.weechat_controller.set_previous_buffer(data)
return w.WEECHAT_RC_OK
@@ -927,10 +927,7 @@ def typing_update_cb(data, remaining_calls):
def slack_never_away_cb(data, remaining_calls):
if config.never_away:
for team in EVENTROUTER.teams.values():
- slackbot = team.get_channel_map()['Slackbot']
- channel = team.channels[slackbot]
- request = {"type": "typing", "channel": channel.identifier}
- channel.team.send_to_websocket(request, expect_reply=False)
+ set_own_presence_active(team)
return w.WEECHAT_RC_OK
@@ -3567,6 +3564,14 @@ def tag(tagset=None, user=None, self_msg=False, backlog=False, no_log=False, ext
tags |= set(extra_tags)
return ",".join(tags)
+
+def set_own_presence_active(team):
+ slackbot = team.get_channel_map()['Slackbot']
+ channel = team.channels[slackbot]
+ request = {"type": "typing", "channel": channel.identifier}
+ channel.team.send_to_websocket(request, expect_reply=False)
+
+
###### New/converted command_ commands
@@ -4381,6 +4386,7 @@ def command_back(data, current_buffer, args):
team = EVENTROUTER.weechat_controller.buffers[current_buffer].team
s = SlackRequest(team, "users.setPresence", {"presence": "auto"})
EVENTROUTER.receive(s)
+ set_own_presence_active(team)
return w.WEECHAT_RC_OK