inherit "module"; |
|
|
constant cvs_version = "$Id: common_api.pike,v 1.2 2000/08/24 10:56:10 jhs Exp $"; |
|
|
|
|
|
|
|
constant module_name = "Tamaroxchi"; |
|
|
|
|
|
constant module_type = MODULE_ZERO; |
|
|
|
|
constant module_doc = "This module does nothing, but its inlined " |
"documentation gets imported into the roxen " |
"programmer manual. You really don't want to " |
"add this module to your virtual server, promise!"; |
|
|
|
|
constant module_unique = 1; |
|
|
|
constant thread_safe = 0; |
|
|
|
|
|
|
|
|
|
|
int itching = 0; |
|
|
|
void create(Configuration|void conf) |
|
|
|
|
|
|
|
|
{ |
report_debug("tamagotchi(%O)\n", conf); |
set_module_creator("Johan Sundström <jhs@roxen.com>"); |
set_module_url("https://jhs.user.roxen.com/examples/common_api.html"); |
} |
|
mapping(string:function(RequestID:void)) query_action_buttons( RequestID id ) |
|
|
|
|
|
|
|
|
|
|
{ |
return ([ "Scratch me!" : scratch_me ]); |
} |
|
void scratch_me() |
|
{ |
if(itching) |
{ |
itching = 0; |
report_notice("Aah, that's good.\n"); |
} else |
report_warning("Ouch!\n"); |
} |
|
string info( Configuration|void conf ) |
|
|
|
|
|
|
|
{ |
string mp = query_internal_location(); |
return "This string overrides the documentation string given in " |
"module_doc, but only once the module is added to a server. " |
"The module's internal mountpoint is found at <tt>" + |
mp + "</tt>."; |
} |
|
string|void check_variable(string variable, mixed set_to) |
|
|
|
|
|
|
|
|
|
{ |
|
if(variable=="variable1") |
{ |
|
if(set_to=="whatevervalueweaccept") |
return; |
else |
return "Sorry, we don't accept that value...\n"; |
} |
} |
|
void start(int occasion, Configuration conf) |
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
report_notice("Wow, I feel good!\n"); |
} |
|
void stop() |
|
|
|
|
|
{ |
report_notice("'Guess that's what I get for all this itching. *sigh*\n"); |
} |
|
string status() |
|
|
|
|
|
|
{ |
string how_much; |
itching += !random(3); |
|
switch(itching) |
{ |
case 0: return "Feelin' fine."; |
case 1: how_much = "a bit."; break; |
case 2: how_much = "noticeably."; break; |
case 3: how_much = "quite a bit."; break; |
case 4: how_much = "really much."; break; |
case 5: how_much = "a lot."; break; |
case 6: how_much = "unbearably!"; break; |
default: how_much = "more than any sane person could stand!"; |
} |
return sprintf("I'm itching %s Please scratch me!", how_much); |
} |
|
mapping|int|Stdio.File|void find_internal(string file, RequestID id) |
|
|
|
|
|
|
|
|
|
|
{ |
return Roxen.http_string_answer(status()); |
} |
|
|