property blockedList : {"+9735551212", "+6035551212", "+12035551212", "+16615551212"}
property yourEmail : "E:kenxxxx@gmail.com"
property logBlocks : true
property logMessageContents : false
property logFileName : "Macintosh HD:Users:kenv99:Documents:Blocked Messages Log"
using terms from application "Messages"
on buddy authorization requested theAuth
repeat with blockedNumber in blockedList
set blockedBuddy to buddy blockedNumber of service yourEmail
set authBuddy to buddy of theAuth
if authBuddy is equal to blockedBuddy then
decline theAuth
if logBlocks is equal to true then
set this_data to ((current date) as string) & space & "Buddy Auth Declined to: " & ((blockedNumber) as string) & return
set this_file to (logFileName as string)
my write_to_file(this_data, this_file, true)
end if
end if
end repeat
end buddy authorization requested
on received text invitation theMessage from theBuddy for theChat
repeat with blockedNumber in blockedList
set blockedBuddy to buddy blockedNumber of service yourEmail
if theBuddy is equal to blockedBuddy then
decline theChat
if logBlocks is equal to true then
if logMessageContents then
set this_data to ((current date) as string) & space & "Rec'd Text Invite Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
else
set this_data to ((current date) as string) & space & "Rec'd Text Invite Declined to: " & ((blockedNumber) as string) & return
end if
set this_file to (logFileName as string)
my write_to_file(this_data, this_file, true)
end if
end if
end repeat
end received text invitation
on message received theMessage from theBuddy for theChat
repeat with blockedNumber in blockedList
set blockedBuddy to buddy blockedNumber of service yourEmail
if theBuddy is equal to blockedBuddy then
decline theChat
if logBlocks is equal to true then
if logMessageContents then
set this_data to ((current date) as string) & space & "Msg Rec'd Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
else
set this_data to ((current date) as string) & space & "Msg Rec'd Declined to: " & ((blockedNumber) as string) & return
end if
set this_file to (logFileName as string)
my write_to_file(this_data, this_file, true)
end if
end if
end repeat
end message received
on chat room message received theMessage from theBuddy for theChat
repeat with blockedNumber in blockedList
set blockedBuddy to buddy blockedNumber of service yourEmail
if theBuddy is equal to blockedBuddy then
decline theChat
if logBlocks is equal to true then
if logMessageContents then
set this_data to ((current date) as string) & space & "Chat Msg Rec'd Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
else
set this_data to ((current date) as string) & space & "Chat Msg Rec'd Declined to: " & ((blockedNumber) as string) & return
end if
set this_file to (logFileName as string)
my write_to_file(this_data, this_file, true)
end if
end if
end repeat
end chat room message received
on active chat message received theMessage from theBuddy for theChat
repeat with blockedNumber in blockedList
set blockedBuddy to buddy blockedNumber of service yourEmail
if theBuddy is equal to blockedBuddy then
decline theChat
if logBlocks is equal to true then
if logMessageContents then
set this_data to ((current date) as string) & space & "Active Chat Msg Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
else
set this_data to ((current date) as string) & space & "Active Chat Msg Declined to: " & ((blockedNumber) as string) & return
end if
set this_file to (logFileName as string)
my write_to_file(this_data, this_file, true)
end if
end if
end repeat
end active chat message received
on addressed chat room message received theMessage from theBuddy for theChat
repeat with blockedNumber in blockedList
set blockedBuddy to buddy blockedNumber of service yourEmail
if theBuddy is equal to blockedBuddy then
decline theChat
if logBlocks is equal to true then
if logMessageContents then
set this_data to ((current date) as string) & space & "Addressed Chat Msg Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
else
set this_data to ((current date) as string) & space & "Addressed Chat Msg Declined to: " & ((blockedNumber) as string) & return
end if
set this_file to (logFileName as string)
my write_to_file(this_data, this_file, true)
end if
end if
end repeat
end addressed chat room message received
on addressed message received theMessage from theBuddy for theChat
repeat with blockedNumber in blockedList
set blockedBuddy to buddy blockedNumber of service yourEmail
if theBuddy is equal to blockedBuddy then
decline theChat
if logBlocks is equal to true then
if logMessageContents then
set this_data to ((current date) as string) & space & "Addressed Msg Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
else
set this_data to ((current date) as string) & space & "Addressed Msg Declined to: " & ((blockedNumber) as string) & return
end if
set this_file to (logFileName as string)
my write_to_file(this_data, this_file, true)
end if
end if
end repeat
end addressed message received
on received video invitation theText from theBuddy for theChat
repeat with blockedNumber in blockedList
set blockedBuddy to buddy blockedNumber of service yourEmail
if theBuddy is equal to blockedBuddy then
decline theChat
if logBlocks is equal to true then
if logMessageContents then
set this_data to ((current date) as string) & space & "Video Invite Declined to: " & ((blockedNumber) as string) & space & (theText as string) & return
else
set this_data to ((current date) as string) & space & "Video Invite Declined to: " & ((blockedNumber) as string) & return
end if
set this_file to (logFileName as string)
my write_to_file(this_data, this_file, true)
end if
end if
end repeat
end received video invitation
on av chat started
end av chat started
on av chat ended
end av chat ended
on login finished for theService
end login finished
on logout finished for theService
end logout finished
on buddy became available theBuddy
end buddy became available
on buddy became unavailable theBuddy
end buddy became unavailable
on completed file transfer
end completed file transfer
on received audio invitation theText from theBuddy for theChat
end received audio invitation
on received remote screen sharing invitation from theBuddy for theChat
end received remote screen sharing invitation
on received local screen sharing invitation from theBuddy for theChat
end received local screen sharing invitation
on received file transfer invitation theFileTransfer
end received file transfer invitation
on message sent theMessage for theChat
end message sent
end using terms from
on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as string
set the open_target_file to open for access file target_file with write permission
if append_data is false then set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file