## channels you want to keep a count file for
## do the following: .chanset #channel +trackcount
## on your partyline


namespace eval ::ChanCount {

   ## settings ##

   variable uninterval 3;
   ## update interval in minutes

   variable savepath "/home/you/eggdrop/text/"
   ## path INCLUDING the trailing slash
   ## files will be the lowercase channel name
   ## special chars will be replaced with an underscore '_'

   ## do not change below here ##
   variable uinterval2 0
   setudef flag trackcount

   proc doCount {chan} {
      set fid [open $::ChanCount::savepath[::ChanCount::fixFile $chan] w]
      puts $fid [llength [chanlist $chan]]; close $fid
   }

   proc fixFile {text} {
      string map {
         {~} {_} {`} {_} {!} {_} {$} {_}
         {%} {_} {^} {_} {&} {_} {*} {_}
         {:} {_} {;} {_} {|} {_} {/} {_}
         {"} {_} {'} {_} {?} {_} {<} {_}
         {>} {_} \\ {_}} $text
   }

   proc getCount {minute hour day month year} {
      if {[incr ::ChanCount::uinterval2] >= $::ChanCount::uinterval} {
         foreach chan [channels] {
            if {[channel get $chan trackcount]} {
               ::ChanCount::doCount $chan
            }
         }
         set ::ChanCount::uinterval2 0
      }
   }
   bind time - "* * * * *" ::ChanCount::getCount
}
