applescript:对特定消息的自动响应

applescript:对特定消息的自动响应,applescript,Applescript,我的女朋友试图少用tiktok,所以她启用了一个功能,每次打开应用程序时,它都会在tiktok上给我发短信(她的名字) 我正尝试在mac上使用applescript执行以下操作: 看看我是否收到她发来的信息,告诉我她在戒酒 然后发送消息“you have logged to tiktok x times today”,其中x从1开始,每次我收到她在tiktok上的消息时递增,并每天重置 我的当前脚本返回以下语法错误: 应为“给定”、“插入”、“有”、“无”或其他参数名,但找到标识符 以下是我目前

我的女朋友试图少用tiktok,所以她启用了一个功能,每次打开应用程序时,它都会在tiktok上给我发短信(她的名字)

我正尝试在mac上使用applescript执行以下操作:

  • 看看我是否收到她发来的信息,告诉我她在戒酒
  • 然后发送消息“you have logged to tiktok x times today”,其中x从1开始,每次我收到她在tiktok上的消息时递增,并每天重置
  • 我的当前脚本返回以下语法错误:

    应为“给定”、“插入”、“有”、“无”或其他参数名,但找到标识符

    以下是我目前的代码,我试图从大量资源中拼凑出来:

    using terms from application "Messages"
    
        property today : missing value
        property current_count : 1
        
        on message received theMessage from theBuddy for theChat with eventDescription
            "girlfriend is on Tiktok."
            if name of theBuddy = "my girlfriend's name" then
        
            tell application "Messages"
                send "you have logged into tiktok" & current_count & " times today" to theBuddy
                increment()
            
                on increment()
                    set currentDate to short date string of (current date)
                    if currentDate is not today then
                        set today to currentDate
                        set current_count to 1
                    end if
                    set current_count to current_count + 1
                end increment
        
            end tell
    
        end message received
    
    ... (a bunch of irrelevant code to avoid error -1078)
    

    如果您运行的是macOS 10.13.4,则代码错误出现在“已接收消息…”开头的“已接收消息…”一行。

    。或者更新版本的消息中不再有AppleScript处理程序,因此,如果是这样的话,无论您遇到什么错误都无关紧要。如果看不到其余的代码,您的
    if name
    块似乎缺少
    end if
    ,而
    if name
    块缺少
    end use terms from
    使用应用程序中的术语“Messages”块和
    增量
    处理程序不应该位于收到的消息的
    处理程序中,仅举几件看起来不正确的事情。如果根本没有消息处理程序,有什么方法可以实现这样的功能吗?现在不可能在消息中实现自动化吗?