收到消息的AppleScript处理器主动聊天获取运行两次,有人知道为什么吗? [英] Active Chat Received Message Applescript Handler gets runs twice, anybody know why?
问题描述
请任何人能帮助我的问题如下:
主动聊天消息处理程序中的AppleScript的消息应用程序中运行两次,看起来像它接收到该消息的两倍,已经没有其他人看到这个问题?
下面是我的code:
全球myBuddysName
全球textmsg在ReadFile的(unixPath)
集富来(开放存取(POSIX文件unixPath))
集TXT改为段落(读富(EOF获得富))
紧邻富
返回TXT
结束READFILE在msgImage(unixPath)
告诉应用程序发现者
设置randomFile为(文件夹unixPath的一些文件)
设置剪贴板(randomFile为«类卷起»)
告诉结束
告诉应用程序系统事件
按键V使用命令下来
关键code 36
告诉结束
结束msgImage
用术语从申请消息
在消息中收到theMessage从theBuddy为theChat
集myBuddysName对ReadFile(用户/用户名/桌面/ AutomatedTextReply / BuddyName.txt)的第一个项目
设置textmsg对ReadFile的一些项目(用户/用户名/桌面/ AutomatedTextReply / Texts.txt)
如果theBuddy的名字是myBuddysName然后
如果theMessage包含文字,然后
发送textmsg到theBuddy
万一
如果theMessage包含形象或theMessage包含IMG,然后
msgImage(麦金塔HD:用户:用户名:桌面:AutomatedTextReply:图像)
延迟(5)
万一
如果theMessage包含视频,然后
msgImage(麦金塔HD:用户:usernameDesktop:AutomatedTextReply:视频)
万一
万一
收到结束消息 在消息发送theMessage与eventDescription
结束消息发送 与eventDescription收到聊天室的消息
终端在收到聊天室的消息 主动聊天消息中收到theMessage从theBuddy
集myBuddysName对ReadFile(用户/用户名/桌面/ AutomatedTextReply / BuddyName.txt)的第一个项目
设置textmsg对ReadFile的一些项目(用户/用户名/桌面/ AutomatedTextReply / Texts.txt)
如果theBuddy的名字是myBuddysName然后
如果theMessage包含文字,然后
发送textmsg到theBuddy
万一
如果theMessage包含形象或theMessage包含IMG,然后
msgImage(麦金塔HD:用户:用户名:桌面:AutomatedTextReply:图像)
延迟(5)
万一
如果theMessage包含视频,然后
msgImage(麦金塔HD:用户:用户名:桌面:AutomatedTextReply:视频)
万一
万一
终端在收到主动聊天消息 在处理收到的消息从theMessage为theBuddy与theChat eventDescription
到底处理了所收到的消息 与eventDescription收到的文字邀请
最终收到的文字邀请 从theBuddy为theChat与eventDescription接收到的音频邀请theText
最终接收到的音频邀请 在接收到的视频邀请theText从theBuddy为theChat与eventDescription
最终接收到的视频邀请 从theBuddy收到本地屏幕共享邀请theChat与eventDescription
最终获得本地屏幕共享邀请 在好友的授权要求与eventDescription
最终哥们授权请求 在解决与eventDescription收到聊天室的消息
到底处理了所收到的聊天室的消息 与eventDescription收到远程屏幕共享邀请
最终获得远程屏幕共享邀请 在登录完成了eventDescription
结束完登录 在注销完成了eventDescription
年底完成注销 对好友成为可与eventDescription
最终哥们面世 对好友成了eventDescription不可用
最终哥们变得不可用 接收到的文件传输邀请theFileTransfer与eventDescription
最终收到的文件传输邀请 在AV聊天开始eventDescription
结束AV聊天开始 在AV聊天eventDescription结束
结束AV聊天结束 与eventDescription完成文件传输
年底完成文件传输结束使用条款从
看起来像两个处理器在消息中收到theMessage从theBuddy为theChat
和 主动聊天消息从theBuddy收到theMessage
被调用。注释使用(*
和。*)的第二个处理器
,然后再试一次。如果它的工作原理是想保留更改; - )
玩得开心,迈克尔/汉堡
Please can anyone help me with the below issue:
Active Chat Message Handler in Applescript for Messages app runs twice, looks like it receives the message twice, has anyone else seen this issue? below is my code:
global myBuddysName
global textmsg
on readFile(unixPath)
set foo to (open for access (POSIX file unixPath))
set txt to paragraphs of (read foo for (get eof foo))
close access foo
return txt
end readFile
on msgImage(unixPath)
tell application "Finder"
set randomFile to (some file of folder unixPath)
set the clipboard to (randomFile as «class furl»)
end tell
tell application "System Events"
keystroke "v" using command down
key code 36
end tell
end msgImage
using terms from application "Messages"
on message received theMessage from theBuddy for theChat
set myBuddysName to 1st item of readFile("Users/username/Desktop/AutomatedTextReply/BuddyName.txt")
set textmsg to some item of readFile("Users/username/Desktop/AutomatedTextReply/Texts.txt")
if name of theBuddy is myBuddysName then
if theMessage contains "text" then
send textmsg to theBuddy
end if
if theMessage contains "image" or theMessage contains "img" then
msgImage("Macintosh HD:Users:username:Desktop:AutomatedTextReply:Images")
delay (5)
end if
if theMessage contains "video" then
msgImage("Macintosh HD:Users:usernameDesktop:AutomatedTextReply:Videos")
end if
end if
end message received
on message sent theMessage with eventDescription
end message sent
on chat room message received with eventDescription
end chat room message received
on active chat message received theMessage from theBuddy
set myBuddysName to 1st item of readFile("Users/username/Desktop/AutomatedTextReply/BuddyName.txt")
set textmsg to some item of readFile("Users/username/Desktop/AutomatedTextReply/Texts.txt")
if name of theBuddy is myBuddysName then
if theMessage contains "text" then
send textmsg to theBuddy
end if
if theMessage contains "image" or theMessage contains "img" then
msgImage("Macintosh HD:Users:username:Desktop:AutomatedTextReply:Images")
delay (5)
end if
if theMessage contains "video" then
msgImage("Macintosh HD:Users:username:Desktop:AutomatedTextReply:Videos")
end if
end if
end active chat message received
on addressed message received theMessage from theBuddy for theChat with eventDescription
end addressed message received
on received text invitation with eventDescription
end received text invitation
on received audio invitation theText from theBuddy for theChat with eventDescription
end received audio invitation
on received video invitation theText from theBuddy for theChat with eventDescription
end received video invitation
on received local screen sharing invitation from theBuddy for theChat with eventDescription
end received local screen sharing invitation
on buddy authorization requested with eventDescription
end buddy authorization requested
on addressed chat room message received with eventDescription
end addressed chat room message received
on received remote screen sharing invitation with eventDescription
end received remote screen sharing invitation
on login finished with eventDescription
end login finished
on logout finished with eventDescription
end logout finished
on buddy became available with eventDescription
end buddy became available
on buddy became unavailable with eventDescription
end buddy became unavailable
on received file transfer invitation theFileTransfer with eventDescription
end received file transfer invitation
on av chat started with eventDescription
end av chat started
on av chat ended with eventDescription
end av chat ended
on completed file transfer with eventDescription
end completed file transfer
end using terms from
Looks like the both handlers on message received theMessage from theBuddy for theChat
and on active chat message received theMessage from theBuddy
are called. Comment the second handler using (*
and *)
and try again. If it works as wanted keep the changes ;-)
Have fun, Michael / Hamburg
这篇关于收到消息的AppleScript处理器主动聊天获取运行两次,有人知道为什么吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!