Skip to content

Instantly share code, notes, and snippets.

@masak
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masak/12c9f8f79be29ad3f1b2 to your computer and use it in GitHub Desktop.
Save masak/12c9f8f79be29ad3f1b2 to your computer and use it in GitHub Desktop.
Workflows for mishu

Propose to clean a room

expect EVERY_DAY;
expect ONE_HOUR_OF_ACTIVITY;

my $header = "";
my $points = 10;

utter "{$header}You get $points points if you go clean the kitchen for 10 minutes.";
loop {
    given expect RESPONSE("ok" | "postpone" | "done") {
        when "ok" {
            utter "Go go go!";
            expect RESPONSE("postpone" | "done");
            proceed;
        }

        when "postpone" {
            if $header {
                utter "Sorry, won't postpone again";
                succeed;
            }

            utter "Ok, postponing 5 hours or until you say 'clean'"
            alarm(FIVE_HOURS_LATER, 5\hour);
            expect RESPONSE("clean") | FIVE_HOURS_LATER;

            $header = "Ok, second and last chance: ";
            $points = 7;
            next;
        }

        when "done" {
            utter "Well done! $points points to Gryffindor!";
            last;
        }
    }
}

Learn new characters

expect EVERY_DAY;
expect WAKEUP;

my ($char, $pron, $mean) = random_character();
utter "Today's random character is $char. It's pronounced $pron and its meaning is $mean.";

expect BEFORE_DINNER;
utter "Ok, today's character was $char. Do you remember how it's pronounced and what it means?";

my $response = expect RESPONSE;
my $score = score_character_guess($response, $pron, $mean);

if $score {
    utter "Well done! $score points to you!";
}
else {
    utter "No, 'fraid not. It's pronounced $pron and its meaning is $mean.";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment