Giter Site home page Giter Site logo

slack_applescript's People

Contributors

alexrepty avatar garethrees avatar kilabyte-ea avatar mrsteveheyes avatar ross-mulcahy avatar samknight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slack_applescript's Issues

Set as Away & Set as Active not working

Hello guys,

Hope you are doing all great.

I can't get the two commands to work: "set as away" and "set as active". When I run them, it sends messages in the conversation I'm in on Slack "= away" or "=active", depending on which command I run.

Here is my script:

tell script "Slack"
	set as active
end tell

Thanks in advance and wish you all a great weekend ahead!

Respect hidden Slack during operation

	tell application "System Events"
		set visible of application process "Slack" to false
	end tell

Sending a message in the above context seems to make Slack visible again. Can this be avoided?

Slack's new "Shortcuts" (rolling out now) breaks this

The new "Shortcuts" functionality that's rolling out to orgs now appears to break this.

When sending a command through "Slack" now, it just sends to the channel because the "Shortcuts" are removing the slash functionality and moving them to their own menu.

clear message box or warn before entering commands

I'm not sure if this is even possible, but can a check be added to ensure that the message box is empty before attempting to enter a command, or could I be warned if it's not empty? I use this to simultaneously set myself as away/available on Slack and another application, and if I happen to have a message typed in the message box in Slack, this will send what I had typed with the command appended, like:

Lorem ipsu/Set yourself as away

...which can be a bit embarrassing, particularly when the typed "message" happens to be just a space.

Anyway, it's a nice-to-have, not a need-to-have, for my forgetful moments. Thanks for this though, very nice being able to use AppleScript for this! I'm very inexperienced with AppleScript but would be happy to help out if there's anything I can do.

not a issue but a feature request

Sorry, this is more a feature request, I'm looking for a way to listen for new message using AppleScript.
(the goal would be to auto reply the person or forward the message to iMessage for example)
-- sorry again to be out of topic

Set "Do not disturb" not working for me

Hi,

I'm having issues setting the "do not disturb" mode.

When running:

tell script "Slack"
	focus workspace "myWorkspace"
	set do not disturb
end tell

I get the error: Can’t make «script "Slack"» into type Unicode text.

When running

tell script "Slack"
	focus workspace "myWorkspace"
	set do not disturb until 5pm
end tell

I get the error: Expected end of line, etc. but found “until”.

Am I doing something wrong or the commands are not working?

Thanks!

Status command sometimes malforms

Hello -- thanks for this amazing Applescript!

Occasionally, it seems that Slack malforms the /status command as /s. atus which then results in an error:

image

  • macOS 10.15.7
  • Apple Script Editor Version 2.11 (208)
  • Spotify 1.1.64.561.g71bd09eb-a
  • slack_applescript 2.0.1 Fix

Here is my full Applescript:

repeat
	if application "Spotify" is running then
		tell application "Spotify"
			set currentSong to (get artist of current track) & " – " & (get name of current track)
			tell script "Slack"
				set status currentSong with icon ":headphones:"
			end tell
		end tell
	end if
	delay 60
end repeat

However, if I close and restart Slack, the Apple script will work (just once). Subsequent attempts results in the malformed status.

Would appreciate your guidance here if you're able to shed some light, perhaps a mistake in my syntax -- thank you!

Nothing works

When I run

tell script "Slack"
   focus channel "general"
end tell

it occasionally works (maybe 10% of the time) but usually it pastes "general" into whatever channel I'm currently in (and sends it!) When it does work I can tell it's exec'ing ⌘+K then types the channel into the "Jump to" input. (This is a hack I was using that's been buggy for me, so I was hoping slack_applescript was a better solution.)

Also, when I'm on a call focus call window does absolutely nothing, and the same with focus main window. I gave up trying other commands.

Slack Version: 4.16.2
samknight/slack_applescript version: 2.0.1

Away command clashes with similar hubspot command

The current "set away" command effectively enters "/away" and hits enter. The issue I had was that on my work instance, another command had the name "away" in it, and it was listed higher in the popup for slack commands, which mean it would get picked instead of the built-in "/away" command.

I fixed it by adding a space before hitting enter, as that would get rid of the popup with the other option. The resulting "shortcut" function looks like this:

on shortcut(cmd, msg)
	tell application "Slack"
		activate
		tell application "System Events"
			keystroke "/"
			delay 0.5
			keystroke cmd
			delay 0.5
			if (cmd is equal to "away" or cmd is equal to "active") then
				key code 49
				delay 0.5
				key code 36 using {command down}
			else
				key code 36 using {command down}
			end if
			if (msg is not equal to "") then
				key code 49
				delay 0.5
				keystroke msg
				delay 0.5
				key code 36 using {command down}
			end if
		end tell
	end tell
end shortcut

On another note, "set do not disturb" i.e. shortcut("Pause all your notifications","") didn't work at all for me; it would just leave the text in input field. "set do not disturb for 25 minutes" did work though

Clearing Status is not working

Clearing the Status just prints out -Clear your status on my current Slack window
I'm on BigSur 11.5.2 and Slack Version 4.19.0.
Thats what I've executed
osascript -e 'tell script "Slack"' -e 'clear status' -e 'end tell'

Unable to send message to a channel on first attempt

Hi,

I'm using your script to send a message to a slack channel from an Alfred Workflow.
I've moved to the latest version, following update of Slack to v4.10.3.

My script is simple:

set the_text to the clipboard
tell script "Slack"
	send message "whatis " & the_text in channel "@platform-bot" in workspace "Work"
end tell
return msg

This script is correctly opening Slack, switching workspace, opening the right channel, but then fails to paste and submit the message. If I try a second time, it works (but obviously it's already in the correct context).

Any idea?

mini guide / advice on reverse engineering Slack.app

thanks so much for this awesome project!

this is my first foray into AppleScript and I'd like to help add some functionality to this library; unfortunately, I can't figure out how you figured out the private dictionary / API for Slack.app. Is this something you might be able to explain / point me in the right direction for discovering myself?

I've read a bit into the Script Editor dictionary / library docs and understand that these electron-based apps are a bit of a different animal than native apps, but I'm truly lost as to how you've reverse engineered any of this interface.

thanks again for this excellent project!

Line break in message

Hello, when I try to send a message of the style:

Super List:

  • milk
  • Cereal
  • Beer

The script print:
Super List: - Milk- Cereal- Beer

When trying to use / n / r
I get very strange things, for example:
/ r generates a message for each line instead of just one.

How could I manage to send everything together in one message?

Syntax error

Thanks to your help, I can include the script, however I can't get it to run, it always marks me as a syntax error, could you let me know what I'm doing wrong?
the following example is from the documentation,
However, what I want to do is send a message to a specific channel.
:)
Captura de pantalla 2020-07-08 15 19 50

Can’t get menu item 1 of menu "Workspace"

After the latest Slack UI updates, the command "focus workspace 'Your Workspace'" returns this error:

error "System Events got an error: Can’t get menu item 1 of menu "Workspace" of menu item "Workspace" of menu "File" of menu bar item "File" of menu bar 1 of process "Slack" whose name starts with "Your Workspace". Invalid index." number -1719

error when focusing workspace

First and foremost, I love that you've put this together. Great stuff @samknight — this is going to be super valuable for an automation I'm building.

Second, I'm getting an issue on Big Sur when I run the focus workspace command:

Screen Shot 2021-01-27 at 7 27 11 PM

From the error message, it looks like maybe it's expecting the workspace to be in the Window menu, however in my Slack app it's actually in File → Workspace → {Workspace Name}.

Otherwise though, it's been smooth sailing. Thanks again for releasing this!

Script error when Slack set to French

When I set Slack to French or German and execute

tell application "Slack"
	focus workspace "One Conversation"
end tell

I receive the error

System Events got an error: Can’t get menu bar item "File" of menu bar 1 of process "Slack".

Not a valide command

Hello,

Running the following AppleScript:

tell script "Slack"
	set status "working"
end tell

I see Slack coming up and executing the / but at some point it fails with the following Slackbot message:

/statusworking is not a valid command. In Slack, all messages that start with the "/" character are interpreted as commands.
If you are trying to send a message and not run a command, try preceding the "/" with an empty space.

I see in the Events window:

tell application "Slack"
	activate
end tell
tell application "System Events"
	keystroke "/"
	keystroke "status working"
	key code 36
	key code 36
end tell

I am running the script with the ScriptEditor on macOS Monterey 12.1

Thanks for script, and let me know if there is something I am not using properly.

Should /away be a toggle command

At the moment "set as away" is a toggle command. Executing it will toggle the status between active and away.

This can be tricky if you don't know what your current Slack status is. For example when you run the command from Alfred without Slack focused.

To me it would be more explicit if away would always set yourself as away, independent of what your current status is. For example by first settings yourself to active /active (which is not a toggle command) and then to /away.

[2.0.0-beta.2] shortcuts writing "=" on AZERTY keyboards

I know your still working on the rewrite but here is some input on something I'll probably miss when using a QWERTY keyboard.

When I run this code:

tell script "Slack"
	send message "this is an automated message" in channel "#testjeroen"
	clear status
	set as away
end tell

I get this on Slack:

this is an automated message
=Clear your status
=Set yourself as active

Screenshot:
Screenshot 2020-11-15 at 16 21 17

When I switch my keyboard layout to QWERTY it works better BUT the messages are not send (enter).

Example screenshot:
Screenshot 2020-11-16 at 08 32 47

Can't get script "Slack"

I don't have this folder ~/Library/Script Libraries, and neither ~/Library/Scripting Libraries. (Should I create them by the way?)

I then put the script to /Library/Scripts, and tried

tell script "Slack"
	set stauts "Lunch"
end tell

It told me Can't get script "Slack".

By the way, does your script support searching uses and open the DM window?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.