Mail.appから自分宛のメールはim.kayac.comに通知
取り急ぎ、というか、手探りでつくってみた。でも、スクリプトの基本部分はid:NeoCatさまのid:NeoCat:20071211:1197387735のエントリそのまんまです。すいません><ありがとうございます><
(* messageパラメータ作成用スクリプト ここでは ~/make_msg.pl に置いてある ------------------------------------ #!/usr/bin/perl use strict; use warnings; use URI; use URI::Escape qw/uri_escape_utf8/; my $text = shift; my $sender = shift; my $rule = shift; my $uri = URI->new; $uri->query_form(message => "[$rule] $text / from $sender"); print uri_escape_utf8($uri->query, "'()"); ------------------------------------ *) using terms from application "Mail" on perform mail action with messages messageList for rule theRule set ruleName to name of theRule set ruleName to quoted form of ruleName set imUser to {YourName} set perlScriptPath to "~/make_msg.pl" repeat with thisMessage in messageList try if junk mail status of thisMessage is false then set theSender to sender of thisMessage set theSubject to subject of thisMessage set theSender to quoted form of theSender set theSubject to quoted form of theSubject set msg to do shell script perlScriptPath & " " & theSubject & " " & theSender & " " & ruleName do shell script "curl -d " & msg & " http://im.kayac.com/api/post/" & imUser end if on error X end try end repeat end perform mail action with messages end using terms from
スーパーpre記法のシンタックスハイライトはAppleScriptには対応してないのか…。まあいいや。
あとはフィルタのルール名も取り出せれば、メッセージヘッダも変えられて、もうちょっと汎用的になるんだけど。
(追記)
フィルタルールの取得方法がわかったので、書き換えました。yksk++
スクリプトエディタにリファレンスがごっそりあった(自分的メモ)。
(追記)
とりあえず現状が最新ですが、タイトルにシングルクォートが入ると通知されないバグ付き。
(追記)
URI::Escapeで回避してみた。