Channel Monitor

By IllogicTC on Feb 13, 2011

A silly little dialog that watches a channel and will provide you with statistics on activity.

To use, in the channel you would like to monitor, enter "/chanmon" and a dialog will appear. On the left is the total numbers, and on the right is the average per selected time unit (default is minute). You can also click Show Max in the middle to show the maximum recorded average.

Hitting reset, of course, resets everything except the channel being monitored, and changing the time unit will reset the max average recorded.

To change the channel being monitored, close Channel Monitor and then use the /chanmon command in the new channel you would like to monitor.

Note: I don't expect this to be terribly useful to anyone, except maybe to observe average use habits to adjust a channel limit or delay on their bot or something accordingly, so I may or may not care about comments or criticism on this snippet.

;Channel Monitor 1.0
;by IllogicTC

dialog lime_cm {
  title "Channel Monitor"
  size -1 -1 170 122
  option dbu
  edit "", 1, 1 3 65 10, read center
  button "RESET", 2, 8 23 50 10
  box "Totals", 3, 1 15 65 104
  box "Per...", 4, 104 15 65 104
  combo 5, 111 23 50 50, size drop
  text "Lines", 6, 66 40 37 8, center
  text "Words", 7, 66 53 37 8, center
  text "Characters", 8, 66 66 37 8, center
  text "Joins", 9, 66 79 37 8, center
  text "Parts", 10, 66 92 37 8, center
  text "Nicks Seen", 11, 66 105 37 8, center
  edit "", 12, 3 39 60 10, read center
  edit "", 13, 3 52 60 10, read center
  edit "", 14, 3 65 60 10, read center
  edit "", 15, 3 78 60 10, read center
  edit "", 16, 3 91 60 10, read center
  edit "", 17, 3 104 60 10, read center
  edit "", 18, 106 39 60 10, read center
  edit "", 19, 106 52 60 10, read center
  edit "", 20, 106 65 60 10, read center
  edit "", 21, 106 78 60 10, read center
  edit "", 22, 106 91 60 10, read center
  edit "", 23, 106 104 60 10, read center
  edit "", 24, 104 3 65 10, read center
  button "Show Max", 25, 68 24 33 12
}

alias chanmon {
  set %cm.channel $active
  set %cm.active 1
  dialog -md lime_cm lime_cm
}

on *:dialog:lime_cm:*:*: {
  if ($devent == init) {
    .enable #chanmon
    did -a $dname 1 %cm.channel
    did -a $dname 5 Hour
    did -a $dname 5 Minute
    did -a $dname 5 Second
    did -c $dname 5 2
    did -a $dname 12-23 0
    .timercmupd 0 1 chanmon_upd
    set %cm.upd 0
    inc -c %cm.upd
    set %cm.nick
  }
  if ($devent == sclick) {
    if ($did == 2) {
      did -ra $dname 12-23 0
      set %cm.upd 0
      inc -c %cm.upd
      set %cm.nick
      set %cm.linemax 0
      set %cm.wordmax 0
      set %cm.charmax 0
      set %cm.joinmax 0
      set %cm.partmax 0
      set %cm.nickmax 0
      set %cm.linecur 0
      set %cm.wordcur 0
      set %cm.charcur 0
      set %cm.joincur 0
      set %cm.partcur 0
      set %cm.nickcur 0
    }
    if ($did == 25) set -u5 %cm.maxshow 1
  }
  if ($devent == close) {
    .timercmupd off
    unset %cm.upd
    unset %cm.nick
    unset %cm.channel
    unset %cm.linemax
    unset %cm.wordmax
    unset %cm.charmax
    unset %cm.joinmax
    unset %cm.partmax
    unset %cm.nickmax
    unset %cm.active
    unset %cm.curshow
    .disable #chanmon
  }
}

alias chanmon_upd {
  did -ra lime_cm 24 $duration(%cm.upd,3)
  if (%cm.curshow != $did(lime_cm,5).seltext) {
    set %cm.linemax 0
    set %cm.wordmax 0
    set %cm.charmax 0
    set %cm.joinmax 0
    set %cm.partmax 0
    set %cm.nickmax 0
  }
  set %cm.curshow $did(lime_cm,5).seltext
  if (%cm.curshow == Second) {
    if ($did(lime_cm,12) > 0) set %cm.linecur $round($calc($did(lime_cm,12) / %cm.upd),3)
    if ($did(lime_cm,13) > 0) set %cm.wordcur $round($calc($did(lime_cm,13) / %cm.upd),3)
    if ($did(lime_cm,14) > 0) set %cm.charcur $round($calc($did(lime_cm,14) / %cm.upd),3)
    if ($did(lime_cm,15) > 0) set %cm.joincur $round($calc($did(lime_cm,15) / %cm.upd),3)
    if ($did(lime_cm,16) > 0) set %cm.partcur $round($calc($did(lime_cm,16) / %cm.upd),3)
    if ($did(lime_cm,17) > 0) set %cm.nickcur $round($calc($did(lime_cm,17) / %cm.upd),3)
  }
  elseif (%cm.curshow == Minute) {
    if ($did(lime_cm,12) > 0) set %cm.linecur $round($calc($did(lime_cm,12) / (%cm.upd / 60)),3)
    if ($did(lime_cm,13) > 0) set %cm.wordcur $round($calc($did(lime_cm,13) / (%cm.upd / 60)),3)
    if ($did(lime_cm,14) > 0) set %cm.charcur $round($calc($did(lime_cm,14) / (%cm.upd / 60)),3)
    if ($did(lime_cm,15) > 0) set %cm.joincur $round($calc($did(lime_cm,15) / (%cm.upd / 60)),3)
    if ($did(lime_cm,16) > 0) set %cm.partcur $round($calc($did(lime_cm,16) / (%cm.upd / 60)),3)
    if ($did(lime_cm,17) > 0) set %cm.nickcur $round($calc($did(lime_cm,17) / (%cm.upd / 60)),3)
  }
  elseif (%cm.curshow == Hour) {
    if ($did(lime_cm,12) > 0) set %cm.linecur $round($calc($did(lime_cm,12) / (%cm.upd / 3600)),3)
    if ($did(lime_cm,13) > 0) set %cm.wordcur $round($calc($did(lime_cm,13) / (%cm.upd / 3600)),3)
    if ($did(lime_cm,14) > 0) set %cm.charcur $round($calc($did(lime_cm,14) / (%cm.upd / 3600)),3)
    if ($did(lime_cm,15) > 0) set %cm.joincur $round($calc($did(lime_cm,15) / (%cm.upd / 3600)),3)
    if ($did(lime_cm,16) > 0) set %cm.partcur $round($calc($did(lime_cm,16) / (%cm.upd / 3600)),3)
    if ($did(lime_cm,17) > 0) set %cm.nickcur $round($calc($did(lime_cm,17) / (%cm.upd / 3600)),3)
  }
  if (%cm.linecur > %cm.linemax) set %cm.linemax %cm.linecur
  if (%cm.wordcur > %cm.wordmax) set %cm.wordmax %cm.wordcur
  if (%cm.charcur > %cm.charmax) set %cm.charmax %cm.charcur
  if (%cm.joincur > %cm.joinmax) set %cm.joinmax %cm.joincur
  if (%cm.partcur > %cm.partmax) set %cm.partmax %cm.partcur
  if (%cm.nickcur > %cm.nickmax) set %cm.nickmax %cm.nickcur
  if (!%cm.maxshow) {
    did -ra lime_cm 18 %cm.linecur
    did -ra lime_cm 19 %cm.wordcur
    did -ra lime_cm 20 %cm.charcur
    did -ra lime_cm 21 %cm.joincur
    did -ra lime_cm 22 %cm.partcur
    did -ra lime_cm 23 %cm.nickcur
  }
  else {
    did -ra lime_cm 18 %cm.linemax
    did -ra lime_cm 19 %cm.wordmax
    did -ra lime_cm 20 %cm.charmax
    did -ra lime_cm 21 %cm.joinmax
    did -ra lime_cm 22 %cm.partmax
    did -ra lime_cm 23 %cm.nickmax
  } 
}

#chanmon off
on *:TEXT:*:%cm.channel: {
  did -ra lime_cm 12 $calc($did(lime_cm,12) + 1)
  did -ra lime_cm 13 $calc($did(lime_cm,13) + $numtok($1-,32))
  did -ra lime_cm 14 $calc($did(lime_cm,14) + $len($1-))
  if (!$istok($nick,%cm.nick,32)) {
    set %cm.nick $addtok(%cm.nick,$nick,32)
    did -ra lime_cm 17 $numtok(%cm.nick,32)
  }
}

on *:ACTION:*:%cm.channel: {
  did -ra lime_cm 12 $calc($did(lime_cm,12) + 1)
  did -ra lime_cm 13 $calc($did(lime_cm,13) + $numtok($1-,32))
  did -ra lime_cm 14 $calc($did(lime_cm,14) + $len($1-))
  if (!$istok($nick,%cm.nick,32)) {
    set %cm.nick $addtok(%cm.nick,$nick,32)
    did -ra lime_cm 17 $numtok(%cm.nick,32)
  }
}

on *:INPUT:%cm.channel: {
  if ($active != %cm.channel) goto end
  did -ra lime_cm 12 $calc($did(lime_cm,12) + 1)
  did -ra lime_cm 13 $calc($did(lime_cm,13) + $numtok($1-,32))
  did -ra lime_cm 14 $calc($did(lime_cm,14) + $len($1-))
  :end
}

on *:JOIN:%cm.channel: {
  did -ra lime_cm 15 $calc($did(lime_cm,15) + 1)
  if (!$istok($nick,%cm.nick,32)) {
    set %cm.nick $addtok(%cm.nick,$nick,32)
    did -ra lime_cm 17 $numtok(%cm.nick,32)
  }
}

on *:PART:%cm.channel: {
  did -ra lime_cm 16 $calc($did(lime_cm,16) + 1)
  if (!$istok($nick,%cm.nick,32)) {
    set %cm.nick $addtok(%cm.nick,$nick,32)
    did -ra lime_cm 17 $numtok(%cm.nick,32)
  }
}
#chanmon end

Comments

Sign in to comment.
IllogicTC   -  Feb 19, 2011

I could probably do the sets under one line two, couldn't I? I will see what I can do to integrate improvements, but I've been quite busy lately so I cannot promise punctuality.

 Respond  
Jethro   -  Feb 13, 2011

I've added the rest of events together as one sharing one alias.

 Respond  
Jethro   -  Feb 13, 2011

This is the first time I see a snippet uses goto command to negate. :P That's rather novel.

if ($active != %cm.channel) return

a /return command will get the job done nicely. For your join, part, text, action and input event, use $replace and the $event identifier to save the repetitions:

#chanmon off
on *:JOIN:%cm.channel:chatmon
on *:PART:%cm.channel:chatmon
on *:INPUT:%cm.channel:chatmon
on *:TEXT:*:%cm.channel:chatmon
on *:ACTION:*:%cm.channel:chatmon
alias -l chatmon {
  if ($istok(text action,$event,32)) {
    did -ra lime_cm 12 $calc($did(lime_cm,12) + 1)
    did -ra lime_cm 13 $calc($did(lime_cm,13) + $numtok($1-,32))
    did -ra lime_cm 14 $calc($did(lime_cm,14) + $len($1-))
    if (!$istok($nick,%cm.nick,32)) {
      set %cm.nick $addtok(%cm.nick,$nick,32)
      did -ra lime_cm 17 $numtok(%cm.nick,32)
    }
  }
  elseif ($event == input) {
    if ($active != %cm.channel) return
    did -ra lime_cm 12 $calc($did(lime_cm,12) + 1)
    did -ra lime_cm 13 $calc($did(lime_cm,13) + $numtok($1-,32))
    did -ra lime_cm 14 $calc($did(lime_cm,14) + $len($1-))
  }
  else {
    var %chatmon = $replace($event,join,15,part,16)
    did -ra lime_cm %chatmon $calc($did(lime_cm,%chatmon) + 1)
    if (!$istok($nick,%cm.nick,32)) {
      set %cm.nick $addtok(%cm.nick,$nick,32)
      did -ra lime_cm 17 $numtok(%cm.nick,32)
    }
  }
}
#chanmon end

This saves you about 200 plus bytes. And for the unset command, you can do it with one /unset

unset %var1 %var2 %var3 etc...
 Respond  
_Dean_   -  Feb 13, 2011

probably, cause i tested here, into a new remote page, and it worked

 Respond  
LadySorien   -  Feb 13, 2011

Sighs and grumbles at her script CHANMON Unknown command. I seriously need a new script.

 Respond  
_Dean_   -  Feb 13, 2011

if you read the description:

To use, in the channel you would like to monitor, enter "/chanmon" and a dialog will appear.

 Respond  
LadySorien   -  Feb 13, 2011

How would on go about opening this? I keep getting an UNKNOWN COMMAND: LIME_CM every time I try to open it no matter what I do

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.