Skip to content

Instantly share code, notes, and snippets.

@soapdog
Last active April 22, 2021 14:32
Show Gist options
  • Save soapdog/0011aa07cdcad5eda5bf345938fe3aa0 to your computer and use it in GitHub Desktop.
Save soapdog/0011aa07cdcad5eda5bf345938fe3aa0 to your computer and use it in GitHub Desktop.
on ssbRoom2Check(cmd)
tell application "Terminal"
activate
delay 1
do script "npx ssb-room2-check " & cmd in front window
end tell
end ssbRoom2Check
display dialog "SSB Room2 Gizmo. What do you want to do?" buttons {"Claim Invite", "Sign In", "Set Alias"}
set cmd to button returned of the result
if cmd is "Claim Invite" then
-- Claim invite handler
-- ssb-room2-check claim <invite>
display dialog "What is the invite code" default answer "" buttons {"Claim invite", "Cancel"} default button 1
copy the result as list to {button_returned, text_returned}
if button_pressed is "Claim invite" then
my ssbRoom2Check("claim " & quote & text_returned & quote)
end if
else if cmd is "Sign In" then
-- Sign In Handler
-- ssb-room2-check sign-in <roomid>
display dialog "What is the Room ID?" default answer "" buttons {"Sign In", "Cancel"} default button 1
copy the result as list to {button_returned, text_returned}
if button_pressed is "Sign In" then
my ssbRoom2Check("sign-in " & quote & text_returned & quote)
end if
else if cmd is "Set Alias" then
-- Set Alias
-- ssb-room2-check alias-register <roomid> <alias>
display dialog "What is the Room ID?" default answer "" buttons {"Continue", "Cancel"} default button 1
copy the result as list to {button_returned, text_returned}
if button_returned is "Continue" then
set room_id to text_returned
display dialog "What is the alias?" default answer "" buttons {"Set Alias", "Cancel"} default button 1
copy the result as list to {button_returned, text_returned}
set my_alias to text_returned
if button_returned is "Set Alias" then
my ssbRoom2Check("alias-register " & quote & room_id & quote & " " & quote & my_alias & quote)
end if
end if
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment