samknight/slack_applescript

Add ability to tell it to clear status after x amount of time

Closed this issue · 18 comments

Slack now has auto expiring statuses, would be cool to be able to set that up via this script, thanks for your hard work!

Will take a look - thanks for the idea

I've been looking at doing the same thing, but I believe it's not possible with slash commands. The only option that I could see is instead of using the slash command for setting the status, navigate through the UI with keystrokes.

Something like ⌘⇧Y, text, ⇥, emoji, ⇥, ⇥ and then choose one option from the list with the arrow keys but that's slow, very limited in options and very fragile, as any tiny change in the UI could break it.

I guess we will have to wait for Slack to allow setting expiring statuses through slash commands.

If you are using Alfred, you can add a delay and then call clear status:
Screenshot 2020-04-07 at 09 31 40
but you will lose focus of whatever you were doing when the time to clear the status comes

That's a cool technique - I do have some UI management flows e.g. focussing windows and they do seem to break fairly regularly. I could create an option where if you set the timer it goes through a UI function but if left blank it uses the slash command?

You could do something like this to set a status for 30 minutes:

tell application "System Events"
    keystroke "y" using {command down, shift down}. # Display status change dialog
    delay 0.2
    keystroke "Lunch break"  # Status text
    keystroke tab  # Highlight emoji selection button
    keystroke return
    delay 0.2
    keystroke ":sandwich:"  # Search emoji
    delay 0.2
    keystroke return # Select first result
    keystroke tab  # Emoji selection button
    keystroke tab  # Clear text button
    keystroke tab  # "Clear after" dropdown
    delay 0.2
    key code 126  # 4 hours
    key code 126  # 1 hour
    key code 126  # 30 minutes
    keystroke return
    keystroke tab  # Save button
    keystroke return
end tell

Thanks - I have been looking into it. My struggle at the moment is designing a nice usable dictionary definition for this.

I could create a definition for each one
set status x for 1 hour
set status x for 4 hours
set status x and bring up date picker

but it doesn't feel user friendly to me yet. Have you got any ideas?

Hi!

I would also love to have this feature 😄 I actually need to clear the slack status after 25min (I'm working with the pomodoro technique and it divides time in chunks of 25min, I'm trying to communicate it to my colleagues with my slack status).

I don't know why do you think that set status x for 1 hour or set status x for 4 hours is not user friendly, I found them pretty clear and readable. I would really appreciate having the minutes version:

set status x for x minutes

Thanks!

Hi Julia,

The difficulty I was having was communicating the the preset values slack offers (1 hour, 4 hours etc).

They do have a custom option but it presents a calendar view which could be a little more brittle to code against the UI. Also trying to surface the options clear after today/this week isn't easily revealed.

I think there's enough demand now though for me to give this a go and use the custom method by default perhaps, but I think it will be one of the trickier items to build robustly.

I'll keep this thread updated

Sorry Julia

A further update. It seems 25 minutes isn't really an option within slack - you can only choose a specific date and time at half hour intervals.

Perhaps we are heading into the area of needing this to become more of a background app that can run using this library as the core library.

Are you running any other tools such as Alfred/Keyboard Maestro?

Thanks a lot for the explanations, now I understand what you meant 😄

A further update. It seems 25 minutes isn't really an option within slack - you can only choose a specific date and time at half hour intervals.

I would say that 30min instead of 25min would be acceptable already for my use case.

Are you running any other tools such as Alfred/Keyboard Maestro?

No, I'm running the script using the automator as explained here. I have Alfred installed (only free version for now) but I don't see how it would help because it only executes the scripts right?

Ok I'll see what I can produce and get some feedback from everyone (pomodoro timings would've been ideal though!)

@josebama preview his Alfred set up here (I think requires premium) #4 (comment)

Essentially you can have one workflow that sets the status, runs a timer and then clears the status. Not ideal as it will interrupt your screen to perform the changes but an interim solution possibly

Just as heads up, I ended up deleting the timer in Alfred to disable the status. I ended up sending unintended messages in slack because I would be typing when the timer would go off and switch the focus to the slack window.

What I’m doing now is set the status for 30 minutes through the UI navigation that I mentioned previously and I set do not disturb for 25 minutes through the slash command. And in the status I briefly explain that if I’m in DND I’m focusing, otherwise I’m in a break.

Hi all,

I think I have something working now. This is very much a test carefully feature right now as the UI part makes it very brittle. There are issues I've not been able to overcome yet where if my mouse is in the position on screen where the dialog pops up it ruins the tab ordering.

Any help to overcome this would be appreciated.

set status "on lunch" until "8:30 pm"
set status "on lunch" with icon ":knife_fork_plate:" until "20:30"

Note that you can use a 12 hour clock or a 24 hour clock. I am only support same day status clearances currently but should be enough for most pomodoro cases.

I won't be working out the in X minutes or in Y hours just yet as that adds some more complications I don't think the library is ready for just yet. Once this is stable then I'll look to add some of that functionality

I should also add that you can be as precise with the time as you like. Not limited to half hour intervals i.e 6:51 pm is perfectly valid

Hi @samknight,

Thanks a lot for the effort 😄 I've been trying the new until functionality and it works like a charm! I found an issue when using it with the icon though.

This command sets the status and the clear time perfectly:
set status statusMessage until endTime

But when I add the icon it fails:
set status statusMessage with icon ":tomato:" until endTime

Error: "The variable icon is not defined." number -2753 from "icon"
The status of slack after running the script:

image

Thanks - all fixed now in v1.3.1

@samknight I pulled the current master version and I still have the icon issue I commented. Thanks!

Once more for luck! v1.3.2

It is working now, thanks a lot!