Mise en forme de code: pensez à utiliser les balises [ tcl ] et [ /tcl ] (sans les espaces bien sûr) autour de vos codes tcl afin d'avoir un meilleur rendu et une coloration syntaxique. x


Retourner le max users dans un channel
#1
Voici un script qui vous permet de retourner chaque jour à minuit, le maximum d'utilisateurs qu'il y a eu dans une journée, ainsi vous pourrez avoir un suivi sur vos statistiques et savoir les heures de pointe ou vous réunissez le plus d'utilisateurs.

Pour activer le script dans un channel : .chanset #channel +dstats

Modifier la variable "backlog" par votre channel de log.

Info: Le script est multi channel.


tcl
namespace eval daily {
 
  variable dcur
  variable dmax
  variable hmax
  variable backlog "#votre-chan-de-log"
 
  setudef flag dstats
 
  proc join {nick uhost handle chan} {
      if {![channel get $chan dstats]} { return }
      ::daily::init $chan 1
      incr ::daily::dcur($chan)
      if {$::daily::dcur($chan) > $::daily::dmax($chan)} {
            set ::daily::dmax($chan) $::daily::dcur($chan)
            set ::daily::hmax($chan) [clock seconds]
            putlog "$chan :Nouveau record quotidien : $::daily::dcur($chan) (enregistré: $::daily::dmax($chan)) à [clock format $::daily::hmax($chan) -format "%T" -locale fr] "
      }
  }
 
  proc part {nick uhost handle chan text} {
      ::daily::leave $chan $nick exited
  }
 
  proc quit {nick uhost handle chan text} {
      ::daily::leave $chan $nick quit
  }
 
  proc kick {nick uhost handle chan target text} {
      ::daily::leave $chan $target kicked
  }
 
  proc leave {chan nick mode} {
      if {![channel get $chan dstats]} { return }
      ::daily::init $chan 0
      incr ::daily::dcur($chan) -1
  }
 
  proc init {chan join} {
      if {![info exists ::daily::dcur($chan)]} {
        set ::daily::dcur($chan) [llength [chanlist $chan]]
        if {$join == 1} {
            incr ::daily::dcur($chan) -1
        }
      }
      if {![info exists ::daily::dmax($chan)]} {
        set ::daily::dmax($chan) $::daily::dcur($chan)
      }
  }
 
  proc cron {mi ho da mo dw} {
      putserv "PRIVMSG $::daily::backlog :Max utilisateurs le \002[clock format [clock scan "yesterday"] -format "%A %d %B %Y" -locale fr]\002:"
      foreach chan [channels] {
        if {![channel get $chan dstats]} { continue }
        if {![info exists ::daily::dmax($chan)]} {
            putserv "PRIVMSG $::daily::backlog :Pas de stats pour $chan aujourd'hui."
        } else {
            putserv "PRIVMSG $::daily::backlog :$chan :\002 $::daily::dmax($chan)\002 users à [clock format $::daily::hmax($chan) -format "%T" -locale fr]"
        }
        unset ::daily::dmax($chan)
        unset ::daily::dcur($chan)
        ::daily::init $chan 0
      }
  }
 
 
  bind join - * ::daily::join
  bind part - * ::daily::part
  bind sign - * ::daily::quit
  bind kick - * ::daily::kick
  bind cron - "00 00 * * *" ::daily::cron
}


Un exemple de ce que vous retournera votre eggdrop chaque jour à minuit :

Quote:<Eggdrop> Max utilisateurs le dimanche 02 avril 2023:
<Eggdrop> #Home : 19 users à 22:18:42
  Reply
#2
Sachant qu'un record de fréquentation ne peut être battu que sur un join, on doit pouvoir restreindre le script à :

tcl
namespace eval daily {
 
  variable dcur
  variable dmax
  variable hmax
  variable backlog "#votre-chan-de-log"
 
  setudef flag dstats
 
  proc join {nick uhost handle chan} {
      if {![channel get $chan dstats]} { return }
      set ::daily::dcur($chan) [llength [chanlist $chan]]
      if {![info exists ::daily::dmax($chan)]} {
         set ::daily::dmax($chan) $::daily::dcur($chan)
         set ::daily::hmax($chan) [clock seconds]
      }
      if {$::daily::dcur($chan) > $::daily::dmax($chan)} {
            set ::daily::dmax($chan) $::daily::dcur($chan)
            set ::daily::hmax($chan) [clock seconds]
            putlog "$chan :Nouveau record quotidien : $::daily::dcur($chan) (enregistré: $::daily::dmax($chan)) à [clock format $::daily::hmax($chan) -format "%T" -locale fr] "
      }
  }
 
  proc cron {mi ho da mo dw} {
      putserv "PRIVMSG $::daily::backlog :Max utilisateurs le \002[clock format [clock scan "yesterday"] -format "%A %d %B %Y" -locale fr]\002:"
      foreach chan [channels] {
        if {![channel get $chan dstats]} { continue }
        if {![info exists ::daily::dmax($chan)]} {
            putserv "PRIVMSG $::daily::backlog :Pas de stats pour $chan aujourd'hui."
        } else {
            putserv "PRIVMSG $::daily::backlog :$chan :\002 $::daily::dmax($chan)\002 users à [clock format $::daily::hmax($chan) -format "%T" -locale fr]"
        }
        unset ::daily::dmax($chan)
        unset ::daily::dcur($chan)
      }
  }
 
  bind join - * ::daily::join
  bind cron - "00 00 * * *" ::daily::cron
}


My 2 cents
zeolia: tchat gratuit, sans inscription ni publicité
Merci de ne pas demander d'aide en MP
Away
  Reply
#3
Ça fonctionne beaucoup mieux, avec ma version , il y avait quelques bugs d'incrémentation, merci.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Détecter une langue étrangère dans un channel Amand 10 137 24/04/2023, 23:15
Last Post: ZarTek

Forum Jump:


Users browsing this thread: 1 Guest(s)