• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Messages Event Handler fired twice.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Messages Event Handler fired twice.


  • Subject: Messages Event Handler fired twice.
  • From: Alberto Gonzalez Ramirez <email@hidden>
  • Date: Tue, 08 Aug 2017 11:59:52 +0200

I´m working on a script to automate a Messages chat.
Everything’s works fine but an issue that, after googling a lot seems to be
unresolved.
It is the “active chat room message received” event. It is fired twice.
There are two entries that shows these same issue:

https://stackoverflow.com/questions/34800851/duplicate-firing-of-active-chat-message-received-handler

<https://stackoverflow.com/questions/34800851/duplicate-firing-of-active-chat-message-received-handler>
http://macscripter.net/viewtopic.php?id=44582
<http://macscripter.net/viewtopic.php?id=44582>

This is my script:

property chat_target : "iMessage;+;chat278029391754081049" --Prueba mensajes
property ruta_libro_numbers : "Macintosh HD:Users:algonra:Library:Mobile
Documents:com~apple~Numbers:Documents:actividad-grupo-prueba-mensajes.numbers"


using terms from application "Messages"

        on actualizar_numbers(grupo_mensajes, remitente, mensaje)
                if grupo_mensajes is chat id chat_target then
                        set nombre_cuenta_remitente to my
obtener_nombre_online_cuenta_remitente(remitente)
                        set fecha_corta_actual to my
obtener_fecha_actual_formato_corto()
                        my anadir_nuevo_registro(nombre_cuenta_remitente,
fecha_corta_actual, mensaje)
                else
                        display notification "Error: " & class of grupo_mensajes
                end if
        end actualizar_numbers

        on obtener_fecha_actual_formato_corto()
                set fecha_actual to current date
                return short date string of fecha_actual
        end obtener_fecha_actual_formato_corto

        on obtener_nombre_online_cuenta_remitente(remitente)
                return get handle of remitente
        end obtener_nombre_online_cuenta_remitente

        on anadir_nuevo_registro(cuenta_online, fecha, mensaje_remitente)
                tell application "Numbers"
                        launch
                        delay 1
                        set libro to open ruta_libro_numbers
                        tell libro
                                tell first sheet
                                        tell first table
                                                if value of cell "A2" is
missing value then
                                                        set value of cell "A2"
to cuenta_online
                                                        set value of cell "B2"
to fecha
                                                        set value of cell "C2"
to mensaje_remitente
                                                else
                                                        set num_filas to count
of rows
                                                        set nueva_fila to add
row below row num_filas
                                                        set num_fila_a_rellenar
to num_filas + 1
                                                        set value of cell ("A"
& num_fila_a_rellenar) to cuenta_online
                                                        set value of cell ("B"
& num_fila_a_rellenar) to fecha
                                                        set value of cell ("C"
& num_fila_a_rellenar) to mensaje_remitente
                                                end if
                                        end tell
                                end tell
                        end tell

                end tell
        end anadir_nuevo_registro


        on received text invitation theText from theBuddy for theChat with
withParam
                display notification "received text invitation"
        end received text invitation

        on received audio invitation theText from theBuddy for theChat with
withParam
                display notification "received audio invitation"
        end received audio invitation

        on received video invitation theText from theBuddy for theChat with
withParam
                display notification "received video invitation"
        end received video invitation

        on received file transfer invitation theFileTransfer with withParam
                display notification "received file transfer invitation"
        end received file transfer invitation

        on buddy authorization requested theRequest with withParam
                display notification "buddy authorization requested"
        end buddy authorization requested

        on message sent theMessage for theChat with withParam
                display notification "message sent"
        end message sent

        on message received theMessage from theBuddy for theChat with withParam
                display notification "message received"
        end message received

        on chat room message received theMessage from theBuddy for theChat with
withParam
                display notification "chat room message received"
                my actualizar_numbers(theChat, theBuddy, theMessage)
        end chat room message received

        on active chat message received theMessage from theBuddy for theChat
with withParam
                display notification "active chat message received"
                my actualizar_numbers(theChat, theBuddy, theMessage)
        end active chat message received

        on addressed chat room message received theMessage from theBuddy for
theChat with withParam
                display notification "addressed chat room message received"
        end addressed chat room message received

        on addressed message received theMessage from theBuddy for theChat with
withParam
                display notification "addressed message received"
        end addressed message received

        on av chat started with withParam
                display notification "av chat started"
        end av chat started

        on av chat ended with withParam
                display notification "av chat ended"
        end av chat ended

        on login finished for theService with withParam
                display notification "login finished"
        end login finished

        on logout finished for theService with withParam
                display notification "logout finished"
        end logout finished

        on buddy became available theBuddy with withParam
                display notification "buddy became available"
        end buddy became available

        on buddy became unavailable theBuddy with withParam
                display notification "buddy became unavailable"
        end buddy became unavailable

        on completed file transfer with withParam
                display notification "completed file transfer"
        end completed file transfer
end using terms from


Is this a bug?

Thanks in advanced.




















































Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Mail Rule To Open Message
  • Next by Date: Mount Hard Drive Script help needed
  • Previous by thread: Re: Mail Rule To Open Message
  • Next by thread: Mount Hard Drive Script help needed
  • Index(es):
    • Date
    • Thread