if (type >= 3) {
sp_channel = "" # channel to play in
sp_log = "" # Log file name
+ sp_sock = "" # UDP log socket
delete sp_notify # [p] E-mail notification address
}
}
{
print strftime("%Y-%m-%d %H:%M:%S | ") msg >> "logs/" sp_log
fflush("logs/" sp_log)
- say(sp_channel, msg);
+ say(sp_channel, msg)
+ print msg |& sp_sock
}
function sp_pretty(cards, who)
sp_reset(2)
} else {
- if (sp_scores[0] == sp_scores[1] &&
+ if (sp_scores[0] == sp_scores[1] &&
sp_scores[0] >= sp_playto)
sp_say("It's tie! Playing an extra round!");
sp_reset(1)
{
return (sec > 60*60*24 ? int(sec/60/60/24) "d " : "") \
(sec > 60*60 ? int(sec/60/60)%24 "h " : "") \
- int(sec/60)%60 "m"
+ int(sec/60)%60 "m"
}
function sp_max(list, i, max)
return sum / length(list)
}
-function sp_stats(file, line, arr, time, user, turn, start, delay)
+function sp_cur(list)
+{
+ return list[length(list)-1]
+}
+
+function sp_stats(file, line, arr, time, user, turn, start, delay, extra)
{
# Process log file
while ((stat = getline line < file) > 0) {
delay[turn][length(delay[turn])] = time - start
turn = 0
}
- if (match(arr[2], /^it is your.*$/, arr)) {
+ if (match(arr[2], /^(it is your|you .*(first|lead)!$)/, arr)) {
turn = user
start = time
- }
+ }
}
close(file)
+ # Add current latency
+ if (turn) {
+ delay[turn][length(delay[turn])] = systime() - start
+ debug("time: " (systime() - start))
+ }
+
# Check for error
if (stat < 0)
reply("File does not exist: " file);
# Output statistics
for (user in delay) {
+ extra = (user != turn) ? "" : \
+ ", " sp_delay(sp_cur(delay[user])) " (cur)";
say("latency for " user \
": " sp_delay(sp_avg(delay[user])) " (avg)" \
- ", " sp_delay(sp_max(delay[user])) " (max)")
+ ", " sp_delay(sp_max(delay[user])) " (max)" extra)
}
}
srand(seed)
sp_init()
sp_reset(2)
- sp_load("var/sp_cur.json");
+ sp_load("var/sp_cur.json")
+ sp_sock = "/inet/udp/0/localhost/6173"
+ print "starting rhawk" |& sp_sock
#if (sp_channel)
# sp_say("Game restored.")
}