WP Comment Notification with AppleScript

A more primitive alternative to using a python script for notification about new comments is to just use good ol’ AppleScript. Apparently, it can do XML-RPC calls and Growl notifications out-of-the-box (with Growl installed, at least). The script below will go out and check for new comments on your blog. It’ll only do it once as I didn’t want to dig into this too much, but maybe it’s also possible to sleep in AppleScript.

set BLOG_ID to 1
set USERNAME to ""
set MY_PASSWORD to ""

tell application "GrowlHelperApp"
	set the allNotificationsList to {"Comments"}
	set the enabledNotificationsList to {"Comments"}
	register as application "WordPress Comment Notifier AS" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Script Editor"
end tell

tell application "http://localhost/wordpress/xmlrpc.php"
	set comment_count to call xmlrpc {method name:"geek.getCommentModerationCount", parameters:{BLOG_ID, USERNAME, MY_PASSWORD}}
end tell

if comment_count is not "0" then
	if comment_count is "1" then
		set msg to comment_count & " new comment"
	else
		set msg to comment_count & " new commens"
	end if

	tell application "GrowlHelperApp"
		notify with name "Comments" title "WordPress Comment Notifier" description msg application name "WordPress Comment Notifier AS"
	end tell
end if

Possibly Related Posts

Comments are closed.