我有以下小程序。当我收到即时消息时,我已将它设置为在 ichat 中运行。它通过新消息的咆哮通知我:
on notify_growl(theName, theTitle, theDescription, theImage)
display dialog theImage
tell application "Growl"
notify with name theName title theTitle description theDescription application name "iChat" image theImage
end tell
end notify_growl
using terms from application "iChat"
-- register the app with growl
tell application "Growl"
set the allNotificationsList to {"Message Received"}
set the enabledNotificationsList to {"Message Received"}
register as application "iChat" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "iChat"
end tell
-- handle the iChat events
on message received theMessage from theBuddy for theChat
if ((application "iChat" is not frontmost) or (status of application "iChat" is equal to away)) then
notify_growl("Message Received", name of theBuddy, theMessage, image of theBuddy)
end if
end message received
on received text invitation theMessage from theBuddy for theChat
accept theChat
if ((application "iChat" is not frontmost) or (status of application "iChat" is equal to away)) then
notify_growl("Message Received", name of theBuddy, theMessage, image of theBuddy)
end if
end received text invitation
end using terms from
问题是,如果我的好友没有关联图像,我会收到错误消息。所以我想在 notify_growl 中添加一个 if 语句,如果 theImage 为空白、null 或其他任何内容,则可以咆哮 sans 图像。显示对话框 theImage,当为空时显示一个显示“msng”的对话框