battle programmers alliance
Would you like to react to this message? Create an account in a few clicks or log in to continue.

battle programmers allianceLog in

the LivinGrimoire Artificial General Intelligence software design pattern forum

descriptionnew alarm skill demo dialarmer Emptynew alarm skill demo dialarmer

more_horiz

Code:

class DiAlarmer(DiSkillV2):
    def __init__(self):
        super().__init__()
        self.off: Responder = Responder("off", "stop", "shut up", "shut it", "alarm off", "cancel alarm")
        self.regexUtil: RegexUtil = RegexUtil()
        self._cron: Cron = Cron("", 3, 3)

    def setCron(self, cron):
        self._cron = cron

    def input(self, ear, skin, eye):
        # Turn off alarm
        if self.off.responsesContainsStr(ear):
            self._cron.turnOff()
            self.setSimpleAlg("alarm is now off")
            return

        temp = self.regexUtil.extractRegex(r"(?<=set alarm to\s)([0-9]{1,2}:[0-9]{1,2})", ear)
        if not len(temp) == 0:
            self._cron.setStartTime(temp)
            self.setSimpleAlg(f"alarm set to {temp}")
            return

        if self._cron.triggerWithoutRenewal():
            self.setSimpleAlg("beep")


https://rumble.com/v4ebrai-livingrimoire-alarm-skill-with-snooze-demo.html

note Cron("", 3, 3)
it sets the interval between snoozes and how many snoozes in total will happen.

cron.triggerWithoutRenewal() means the alarm won't repeat the following day. if you want it to
replace with: cron.trigger()

descriptionnew alarm skill demo dialarmer EmptyRe: new alarm skill demo dialarmer

more_horiz
adding the skill is a walk in the park:
app.brain.logicChobit.addSkill(DiAlarmer())

just one line of code.
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum
power_settings_newLogin to reply