dialog OperView {
title "Oper View"
size -1 -1 630 420
option dbu
tab "Clients", 1, 5 5 620 410
list 11, 10 20 610 395, tab 1
tab "Oper View", 5
list 51, 10 20 610 395, tab 5
tab "Kills", 2
list 21, 10 20 610 395, tab 2
tab "Whois", 3
list 31, 10 20 610 395, tab 3
tab "xLine", 4
list 41, 10 20 610 395, tab 4
button "OK/Save", 100, 5 5 35 10, hide default ok
}
;
on *:DIALOG:OperView:init:0:{
;*** Save and clear dialog list items every 1 hour ***
.timerOVSave 0 $calc(60 * 60) OVsave
}
;
on *:DIALOG:OperView:close:0:{
;*** Stop saving timer if dialog is closed ***
.timerOVSave off
}
;
menu * {
&OperView : dialog $iif(!$dialog(OperView),-mid,-ev) OperView OperView
}
;
on *:CONNECT:{
if ($server == Matrix.Maximum-IRC.org) {
.os
}
}
;
on *:START:{ dialog $iif(!$dialog(OperView),-mid,-e) OperView OperView }
;
on ^*:SNOTICE:*:OVsnotice $1-
alias OVsnotice {
if (!$dialog(OperView)) return
;
var %notice = client kill whois xline operview
var %a = 0, %b = $numtok(%notice,32)
while (%a < %b) {
inc %a
if ($wildtok($1-,$+(*,$gettok(%notice,%a,32),*),0,32)) {
if ($hget(OperView,~logging)) {
hinc OperView ~log.id 1
hadd OperView $+(store.,$hget(OperView,~log.id)) $calc((10 * %a) + 1) $timestamp $1-
}
else { did -a OperView $calc((10 * %a) + 1) $timestamp $1- }
}
haltdef
}
}
;
alias OVsave {
if (!$dialog(operview)) return
if ($hget(OperView,~logging)) {
echo -at Already saving logs. Try again later.
return
}
;
;*** Create storage hash table ***
if ($hget(OperView)) hdel OperView
hmake OperView 5
;
;*** Set switch to indicate we are busy ***
hadd OperView ~log.id 0
hadd OperView ~logging 1
.timerOV 1 10 hfree -s OperView
;
;*** Save each dialog list item to the appropriate file ***
var %d = $date(dd-mm-yyyy), %c = 0, %cc = 5, %i = 0
;** Prefixes for files **
var %fn = clients,kills,whois,xline,operview
while (%c < %cc) {
inc %c
%i = $calc((%c * 10) + 1)
filter -if Operview %i $+(OV.,$gettok(%fn,%c,44),.,%d,.txt) *
did -r OperView %i
;
;######## These lines simulate snotices that were ##########
;######## received while the logs were being written #######
OVsnotice blah blah client blah blah %c
OVsnotice blah blah kill blah blah %c
OVsnotice blah blah whois blah blah %c
OVsnotice blah blah xline blah blah %c
OVsnotice blah blah operview blah blah %c
;###########################################################
}
;
;*** Write stored snotices to dialog ***
var %c = 0, %cc = $hget(OperView,~log.id)
while (%c < %cc) {
inc %c
did -a OperView $hget(OperView,$+(store.,%c))
}
;
;*** Delete storage hash table ***
hfree OperView
.timerOV off
}
;
;
;
;################ Test aliases #################
alias OVtest {
dialog $iif(!$dialog(OperView),-mid,-e) OperView OperView
;
OVsnotice this is a client test line 11
OVsnotice this is a client test line 12
OVsnotice this is a client test line 13
OVsnotice this is a client test line 14
OVsnotice this is a client test line 15
;
OVsnotice this is a kill test line 21
OVsnotice this is a kill test line 22
OVsnotice this is a kill test line 23
OVsnotice this is a kill test line 24
OVsnotice this is a kill test line 25
;
OVsnotice this is a whois test line 31
OVsnotice this is a whois test line 32
OVsnotice this is a whois test line 33
OVsnotice this is a whois test line 34
OVsnotice this is a whois test line 35
;
OVsnotice this is a xline test line 41
OVsnotice this is a xline test line 42
OVsnotice this is a xline test line 43
OVsnotice this is a xline test line 44
OVsnotice this is a xline test line 45
;
OVsnotice this is a operview test line 51
OVsnotice this is a operview test line 52
OVsnotice this is a operview test line 53
OVsnotice this is a operview test line 54
OVsnotice this is a operview test line 55
}