mIRC Home    About    Download    Register    News    Help

Print Thread
#146104 31/03/06 08:21 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The following code works for all parts except the OperView tab, which currently never shows anything, but should show any snotices that don't go to one of the other tabs.
Code:
 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
}
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:*:{
  if $dialog(OperView) {
    set %notice Client Kill whois
    var %a = 1, %b = $numtok(%notice,32)
    while %a <= %b {
      if $wildtok($1-,$+(*,$gettok(%notice,%a,32),*),0,32) {
        did -a OperView $calc((10 * %a) + 1) $timestamp $1-
      }
      inc %a
    }
    haltdef
  }
}
 

#146105 31/03/06 03:24 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
You don't have enough tokens in your %notice variable to add anything to the "Oper View" or "xLine" tabs. The calculation is ((<token #> * 10) + 1). You have 3 tokens in your variable, so it will add to these tabs: 11, 21, 31. You need to add the appropriate keywords to the %notices variable.

One other thing.. This line:

if $wildtok($1-,$+(*,$gettok(%notice,%a,32),*),0,32) {

is unnecessarily complex. It could simply be this:

if $gettok(%notice,%a,32) isin $1- {

-genius_at_work

#146106 01/04/06 02:08 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Thanks again Genius..lol I seem to be saying that alot. Now one more thing that I woudl like to add, just not sure what the best way to handle this is, is something that will log all the entries from the dialog to a file and then clear the dialog. I was thinking something about a once a day writing to a file, however, if you (or someone else) has another suggestion that would be better, I'd be pleased to consider it.

This is what I've got at the moment, and I'm not entirely happy with it, mainly due to the amount of writing to the hard drive that's required, plus I'm also finding that the not all of the information written references the correct date, especially if there's information written to the dialog while the data is being written to the file.
Code:
 alias log.view {
  $iif(!$dir(OperView),mkdir OperView)
  var %a = 1, %b = $did(OperView,11).lines
  while %a &lt;= %b {
    .writeini -n $+(OperView\,$+($date(dd-mm-yyyy),.ini)) $did(OperView,1) %a $did(OperView,11,%a)
    inc %a
  }
  var %a = 1, %b = $did(OperView,21).lines
  while %a &lt;= %b {
    .writeini -n $+(OperView\,$+($date(dd-mm-yyyy),.ini)) $did(OperView,2) %a $did(OperView,21,%a)
    inc %a
  }
  var %a = 1, %b = $did(OperView,31).lines
  while %a &lt;= %b {
    .writeini -n $+(OperView\,$+($date(dd-mm-yyyy),.ini)) $did(OperView,3) %a $did(OperView,31,%a)
    inc %a
  }
  var %a = 1, %b = $did(OperView,41).lines
  while %a &lt;= %b {
    .writeini -n $+(OperView\,$+($date(dd-mm-yyyy),.ini)) $did(OperView,4) %a $did(OperView,41,%a)
    inc %a
  }
  var %a = 1, %b = $did(OperView,51).lines
  while %a &lt;= %b {
    .writeini -n $+(OperView\,$+($date(dd-mm-yyyy),.ini)) $did(OperView,5) %a $did(OperView,51,%a)
    inc %a
  }
  did -r Operview 11,21,31,41,51
}
 

Last edited by RusselB; 01/04/06 02:21 PM.
#146107 01/04/06 05:19 PM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
I don't know if it would work or not, but maybe you could try using the /filter command to write all the lines from the dialog to a file. It doesn't seem like it can write to an ini file, but I think that you would have to overfill ini files (64k 'limit') if you write all the snotices to them. Looking at my snotice files, they are much larger than 64k. You might be better off using text files for each different section.

This might be a possible /filter syntax for what you want to do:

/filter -if Operview 11 $+(operview.11.,$ctime,.txt) *

(untested)

-genius_at_work

Last edited by genius_at_work; 01/04/06 05:20 PM.
#146108 01/04/06 06:52 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The number of notices is part of the reason I'm wanting to clear the dialog each time the files are written, and also why I'm going to be putting this on a timer so that it goes automatically once a day (for example)...but I'll give your suggestion a try and let you know what happens.

#146109 01/04/06 09:51 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
plus I'm also finding that the not all of the information written references the correct date, especially if there's information written to the dialog while the data is being written to the file.


The cause of this might be something else, becuase no info can be written to the dialog while the files are being written to (using your alias) since mirc cant multithread tasks of this nature, so all the dialogs must be written out and cleared, before the next entry is added.

#146110 01/04/06 10:56 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Any suggestions? The only thing I've been able to think of, is to write the file in (for example) one hour increments, rather than one day, although I would prefer to have the information stored on a day to day basis, like the logs already do (in the logging section from Options).

#146111 02/04/06 04:12 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
I hope this code will solve the problem:
Code:
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 * {
  &amp;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 &lt; %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 &lt; %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 &lt; %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
}


When the command is given to save the log files, a switch is set to indicate that it is in process. That switch is checked in the snotice event (/OVsnotice alias) and if the switch is set, the snotices are stored in a hash table until the saving is complete. After all the dialog list items have been saved and cleared, the snotices stored in the hash table are transferred to the dialog list items. That way, nothing is missed. Since the dialogs list items are cleared after being saved, the /OVsave alias can be called at any time.

I made a timer start when the dialog is opened. It calls the save alias every hour. This can be changed to whatever length of time you desire. The timer is automatically stopped when the dialog is closed.

You can write test lines to the dialog by using the /OVtest command. It sends lines through the /OVsnotice alias which parses the lines into the appropriate dialog list item. To test the saving command, just type /OVsave . The /OVsave command has some test lines in it that simulate snotices that were received while the logs are being saved. After running the /OVsave alias, you will notice the existing lines are gone, and the new test lines were saved in the hash and then loaded into the dialog automatically.

Any questions, just ask.

-genius_at_work


Link Copied to Clipboard