RosettaCodeData/Task/Magic-8-ball/CFEngine/magic-8-ball.cfengine

48 lines
1.5 KiB
Plaintext

#!/var/cfengine/bin/cf-agent --no-lock
bundle agent __main__
{
methods: "rosettacode_org:magic_8_ball";
}
body file control
{
namespace => "rosettacode_org";
}
bundle agent magic_8_ball
{
vars:
"_responses"
slist => {
"It is certain", "It is decidedly so", "Without a doubt",
"Yes definitely", "You may rely on it", "As I see it yes",
"Most likely", "Outlook good", "Signs point to yes", "Yes",
"Reply hazy try again", "Ask again later",
"Better not tell you now", "Cannot predict now",
"Concentrate and ask again", "Don't bet on it",
"My reply is no", "My sources say no", "Outlook not so good",
"Very doubtful",
};
"_selected_response"
int => randomint( 0, length( _responses) ),
unless => isvariable( "$(this.namespace):$(this.promiser)" );
"_consideration_time"
int => randomint( 3, 5),
unless => isvariable( "$(this.namespace):$(this.promiser)" );
commands:
"/bin/sleep $(_consideration_time)"
inform => "false",
handle => "consider",
depends_on => { "think" },
comment => "This magic 8 ball takes a few seconds to consider the answer
after you bring your question to mind.";
reports:
"Think about your question ..."
handle => "think";
"Response: $(with)"
with => nth( _responses, $(_selected_response) ),
depends_on => { "consider" };
}