Let's Make Robots!

Shoutbox Invocation Script for Mac Users (Now with Merser's Python Interpretation)

First off, sorry-I realize that very few people are Mac users and can make use of this.  Also, it's kind of useless if you have a bot or other project on page one, but if you need you can really work around that I guess.

Let's say that you want to work at the soldering station for a while but you want to know when they start talking about you in the Shout Box, or that you want to concentrate on an IDE for a while but have Safari in the background.  Alternatively, let's say you're waiting for another LMRian to show up in the Shout Box under the same circumstances.  This AppleScript will run every 5 minutes and let you know by speaking to you that someone is talking about you or that they are there.

Obviously, this one is set up for me on LMR using Safari and the voice says "You have been invoked!"  If you are an Mac user but you've never used AppleScript, it's easier than Arduino or AxePad.  Just open the AppleScript Editor (which should either be in your Applications folder or its Utilities subfolder) and paste the code below into it, make your changes, then click on the Compile hammer to make sure there aren't any accidental artefacts, then hit "Run" and it will be off.  You can save it as an Application on your desktop that you can launch at any time and leave running ad infinitum, as a script that you can edit later and run from the Script Editor, as text... you get the idea.

This could probably be adjusted to Python rather easily, but I like the fact that it talks to me.  I don't know if Python accesses that.

 

on idle

set pagURL to "http://letsmakerobots.com/"

if application "Safari" is not running then

quit

return

end if

tell application "Safari"

set URL of document 1 of window 1 to "http://letsmakerobots.com/"

delay 5

-- delay to let page load. 

if source of document 1 of window 1 contains "Max" then

say "You have been invoked."

end if

return 300 --five minutes

end tell

end idle

 

 

*Tested on OS X.5.8, PPC.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Ok I've been looking into this and there are a number of issues in python. Windows uses a program called Narrator for text to voice but I had a devil of a time getting it to work nicely just in the gui.
Birdmun suggested using a .wav file instead which simplifies it, so I was investigating the playing of a .wav file regardless of platform. If you google this a lot of people seem to have a favourite module they recommend to use but as long as your os uses file associations there are a few standard module functions that can open a file with the associated program.

os.system(filepath)
subprocess.call([exepath,filepath])
os.startfile(filepath)

On windows you can also use winsound.playsound(filepath)
One could launch Narrator with these calls but I'm not sure how to get Narrator to speak a line of text in a string variable or text file without reading all the friggin punctuation and system information.

Finally I found you can access the shoutbox page without a cookie with the following address http://letsmakerobots.com/shoutbox?page=0

However it doesn't seem to update correctly. I monitored it and can't see the pattern. Of course if you just wanted to search the last few days of shoutbox for boob pictures or links or particular words it should be easy to read each page by
shoutbox = urllib2.urlopen("http://letsmakerobots.com/shoutbox?page=",variable) incrementing variable to go deeper into history.

Thats as far as I've got so far.

Wow, great work merser!  I'm glad I'm not the only one who sees this as a useful script.

That is a very nice scripting language. Almost like plain English and easy to follow. I know a little Python but probably not enough to figure this one out. At a guess I think you'd need to use one of the web extensions for python to do this. Maybe you could just create an executable that does it too but it wouldn't be the same as just running a script. I have a feeling it will not be as easy in Python as your script looks.
Always wondered why mac users are such dedicated fans, this sheds some light.