Alarms are a special case at the moment. These alarms are usually implemented using the general notifications functionality in botengine. That notifications functionality is not documented at the moment because the implementation is not done yet.
So we take a different path today to implement an alarm sound.
To play the alarm sound, you derive a notification from the app status text. Mid-term, there is probably a graphical user interface to configure this. Today, you configure notifications by adding a function that takes the status text as input and returns that list of beeps.
As a reminder: The status text includes the parts that you returned from decideNextStep
as well as statusTextFromDecisionContext
. You can use the output of any of these to trigger a notification.
To include your notifications function, you switch your app configuration from the usual EveOnline.AppFrameworkSeparatingMemory.processEvent
to EveOnline.AppFrameworkSeparatingMemory.processEventWithNotificationsShim
That variant takes one more field in the configuration record, named notificationsBeepSequenceFromStatusText
Here is the type of the function you need to provide for notificationsBeepSequenceFromStatusText
:
String -> List EveOnline.AppFramework.ConsoleBeepStructure
You can return an empty list here not to play any sound. However, in any case, this wrapper adds a line in the status text. This line starts with notifications-shim:
and shows the number of elements you returned in your function. This should help with inspection in cases where audio output is not available, for example, when running a simulation.
EveOnline.AppFrameworkSeparatingMemory.processEventWithNotificationsShim
was added here: Support EVE Online developers adding alarm sounds to their apps · Viir/bots@885938e · GitHub
To trigger from decideNextStep
, add the triggering text using describeBranch
.
In the code you posted above, you have already done that. Now you can code your alarms like this:
myAlarms : String -> List EveOnline.AppFramework.ConsoleBeepStructure
myAlarms statusText =
if String.contains "Run away to avoid potential ganks." statusText then
[ { frequency = 700, durationInMs = 100 }
, { frequency = 0, durationInMs = 100 }
, { frequency = 700, durationInMs = 500 }
]
else
[]