Browse Source

Quota timer, in prompt, reset on new login

pull/2/head
Brandon Cornejo 6 years ago
parent
commit
0c549bf3de
  1. 3
      config.tin
  2. 3
      src/gmcp.tin
  3. 11
      src/prompt.tin
  4. 142
      src/quota.tin

3
config.tin

@ -21,6 +21,7 @@
#READ {src/xpmonitor.tin}; #READ {src/xpmonitor.tin};
#READ {src/tpamonitor.tin}; #READ {src/tpamonitor.tin};
#READ {src/spottimers.tin}; #READ {src/spottimers.tin};
#READ {src/quota.tin};
#READ {src/combat.tin}; #READ {src/combat.tin};
#READ {src/deadletter.tin}; #READ {src/deadletter.tin};
@ -28,7 +29,7 @@
#READ {src/magic.tin}; #READ {src/magic.tin};
#READ {src/missions.tin}; #READ {src/missions.tin};
#READ{src/group.tin};
#READ {src/group.tin};
#SESSION {discworld} {discworld.starturtle.net} {4242}; #SESSION {discworld} {discworld.starturtle.net} {4242};

3
src/gmcp.tin

@ -47,6 +47,9 @@
{ {
#IF {"$debug" == "1"} { #SHOWME %1 }; #IF {"$debug" == "1"} { #SHOWME %1 };
#VAR GMCP[charinfo] {%0}; #VAR GMCP[charinfo] {%0};
#nop New login, invalidate stale info;
#unvar {quota};
} }
#EVENT {IAC SB GMCP room.info IAC SE} #EVENT {IAC SB GMCP room.info IAC SE}

11
src/prompt.tin

@ -17,15 +17,22 @@
#ALIAS {update_prompt} { #ALIAS {update_prompt} {
#nop XP monitor details;
xp_monitor; xp_monitor;
#format {prompt_xp} {%Gxp in %s (%Gk/h)} {$session_xp} {$uptime[display]} {$xprate}; #format {prompt_xp} {%Gxp in %s (%Gk/h)} {$session_xp} {$uptime[display]} {$xprate};
#nop TPA monitor details;
#var {prompt_tpa} {}; #var {prompt_tpa} {};
#if {$tpa_status == 1} { #if {$tpa_status == 1} {
#format {prompt_tpa} {%cTPA%c} {@tpa_col{$tpa_color}} {<098>}; #format {prompt_tpa} {%cTPA%c} {@tpa_col{$tpa_color}} {<098>};
}; };
#format {prompt_line} {%+5s %+40s} {$prompt_tpa} {$prompt_xp};
#nop Quota monitor details;
#var {prompt_quota} {};
#if {&quota} {
#format {prompt_quota} {Quota: %s} {@quota_time_left{}};
};
#format {prompt_line} {%+5s %+40s %+15s} {$prompt_tpa} {$prompt_xp} {$prompt_quota};
#showme {$prompt_line} {-1}; #showme {$prompt_line} {-1};
} }

142
src/quota.tin

@ -0,0 +1,142 @@
#CLASS {QUOTA} {KILL};
#CLASS {QUOTA} {OPEN};
#unvar quota;
#nop ==[ Parse 'read quota brief' output ]==;
#action {^ Receipts received: A\$%1.$}
{
#var quota[reciepts] %1;
}
#action {^ Receipts received: %1p.$}
{
#math quota[reciepts] {%1 * 0.01};
}
#action {^ Min quota: A\$%1.$}
{
#var quota[min] %1;
}
#action {^ Max quota: A\$%1.$}
{
#var quota[max] %1;
}
#action {^ Amount owed: A\$%1.$}
{
#var quota[owed] %1;
}
#action {^ Amount owed: %1p.$}
{
#math quota[owed] {%1 * 0.01};
}
#action {^ Amount paid: A\$%1.$}
{
#var quota[paid] %1;
}
#action {^ Amount paid: %1p.$}
{
#math quota[paid] {%1 * 0.01};
}
#action {^ Time left: %1.$} {
#regex {%1} {%d hour{s?}} {
#var {quota[time][hour]} {&1};
} { #var {quota[time][hour]} {0} };
#regex {%1} {%d minute{s?}} {
#var {quota[time][min]} {&1};
} { #var {quota[time][min]} {0} };
#regex {%1} {%d second{s?}} {
#var {quota[time][sec]} {&1};
} { #var {quota[time][sec]} {0} };
#var {quota[who]} {$GMCP[charinfo][capname]};
#var {quota[alert]} {on};
}
#tick {quota_time}
{
#nop If we have no quota info, do nothing;
#if {!&{quota[time]}} {
#return;
};
#nop Subtract a second, calculate new times;
#math {quota[time][sec]} {$quota[time][sec] - 1};
#if {$quota[time][sec] < 0} {
#math {quota[time][min]} {$quota[time][min] - 1};
#math {quota[time][sec]} {$quota[time][sec] + 60};
#nop Update prompt;
update_prompt;
};
#if {$quota[time][min] < 0} {
#math {quota[time][hour]} {$quota[time][hour] - 1};
#math {quota[time][min]} {$quota[time][min] + 60};
};
#if {$quota[time][hour] < 0} {
#math {quota[time][hour]} {$quota[time][hour] + 12};
#var {quota[reciepts]} {0};
#nop Quota period is over, announce it.;
#format {quota_display_line} {%c[Quota] %c*%c %s's quota has %creset%c.} {bold blue} {bold yellow} {bold blue} {$quota[who]} {bold red} {bold blue};
#showme {$quota_display_line};
};
#nop Alert when quota is ending;
#if {"$quota[alert]" == "on"} {
#nop Message an hour before;
#if {$quota[time][hour] == 0 && $quota[time][min] == 59 && $quota[time][sec] == 59} {
#format {quota_display_line} {%c[Quota] %c*%c %s's quota flips over in %cone hour%c.} {bold blue} {bold yellow} {bold blue} {$quota[who]} {bold red} {bold blue};
#echo {$quota_display_line \a};
};
#nop Message 30 minutes before;
#if {$quota[time][hour] == 0 && $quota[time][min] == 29 && $quota[time][sec] == 59} {
#format {quota_display_line} {%c[Quota] %c*%c %s's quota flips over in %chalf an hour%c.} {bold blue} {bold yellow} {bold blue} {$quota[who]} {bold red} {bold blue};
#echo {$quota_display_line \a};
};
#nop Message 10 minutes before;
#if {$quota[time][hour] == 0 && $quota[time][min] == 9 && $quota[time][sec] == 59} {
#format {quota_display_line} {%c[Quota] %c*%c %s's quota flips over in %cten minutes%c.} {bold blue} {bold yellow} {bold blue} {$quota[who]} {bold red} {bold blue};
#echo {$quota_display_line \a};
};
};
} {1};
#alias {quota alert %1} {
#if {"%1" == "on"} {
#var {quota[alert]} {on};
} {
#var {quota[alert]} {off};
};
};
#function {zero_pad} {
#if {%1 < 10} {
#format {result} {0%d} {%0};
};
#else {
#format {result} {%d} {%0};
};
#return $result;
};
#function {quota_time_left} {
#if {$quota[time][hour] == 0 && $quota[time][min] < 60} {
#format {result} {<eac> %s:%s<099>} {@zero_pad{$quota[time][hour]}} {@zero_pad{$quota[time][min]}};
} {
#format {result} {%s:%s<099>} {$quota[time][hour]} {@zero_pad{$quota[time][min]}};
};
#return $result;
};
#CLASS {QUOTA} {CLOSE};
Loading…
Cancel
Save