Scripting
Bonjour / Bonsoir,

Bienvenue sur ce forum.

Merci, de vous connectez si vous ne l'êtes pas.

Merci, de vous enregistrez si vous ne l'êtes pas. Ceci prend même pas une minute.

Cordialement,

Dylan

Rejoignez le forum, c’est rapide et facile

Scripting
Bonjour / Bonsoir,

Bienvenue sur ce forum.

Merci, de vous connectez si vous ne l'êtes pas.

Merci, de vous enregistrez si vous ne l'êtes pas. Ceci prend même pas une minute.

Cordialement,

Dylan
Scripting
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Le deal à ne pas rater :
Sortie PlayStation 5 Pro : où précommander la console PS5 Pro ?
Voir le deal

Record

Aller en bas

Record Empty Record

Message  Dylan Mar 29 Déc - 5:03

Code:
#############################################################################
# Audience Recorder v2.0 (21/02/2001)                                      #
#                               #
#############################################################################

# * Description:
#  - Ce script enregistre les audiences de vos channels et annonce lorsqu'il
#    y a un nouveau record. Ces données sont consultables à tout moment.
#  - Fonctionne sur les eggdrop 1.3.x à 1.6.x

# * Commandes et syntaxe:
#  - Pub: !max
#  - Msg: /msg bot max <channel>
#  - DCC: .max <channel>
#

# * Commentaires:
#  - N'hésitez pas à m'envoyer vos idées, vos modifications, et surtout
#    les reports de bugs à chris.neon@bigfoot.com  -Merci!-

#############################################################################
# Configuration du script                                                  #
#############################################################################

# channels dont l'audience sera enregistrée:
set max(chans) "*"

# fichier où les audiences seront stockées:
# si le fichier est dans un sous-répertoire, il faudra le créer manuellement.
set max(file) "max.txt"

# annoncer un nouveau record sur ces channels (0=non, 1=oui):
set max(newrecord) 1

# préfixe de la commande publique du script:
set max(command) "!"

# anti-flood sur les commandes (x:y, où x=lignes et y=secondes):
set max(flood) 5:10

# ignorer l'utilisateur après son flood (0=non, 1=oui):
set max(ignore) 1

# si oui, combien de temps (en minutes):
set max(ignoretime) 1

# laisser faire les utilisateurs ayant certains flags:
set max(ignflags) "fmnov|fmnov"

#############################################################################
# Fin de la configuration                                                  #
#############################################################################

proc max:flood:init {} {
   global max maxflood
   set max(floodnum) [lindex [split $max(flood) :] 0]
   set max(floodtime) [lindex [split $max(flood) :] 1]
   set i [expr $max(floodnum) - 1]
   while {$i >= 0} {
      set maxflood($i) 0
      incr i -1
   }
}
max:flood:init

proc max:flood {nick uhost} {
   global max maxflood botnick
   if {$max(floodnum) == 0} {
      return 0
   }
   set i [expr $max(floodnum) - 1]
   while {$i >= 1} {
      set maxflood($i) $maxflood([expr $i - 1])
      incr i -1
   }
   set maxflood(0) [unixtime]
   if {[expr [unixtime] - $maxflood([expr $max(floodnum) - 1])] <= $max(floodtime)} {
      if {$max(ignore)} {
         newignore [join [maskhost *!*[string trimleft $uhost ~]]] $botnick "Flood" $max(ignoretime)
      }
      return 1
   } {
      return 0
   }
}

if {![file exists $max(file)]} {
   putlog "Fichier des Audiences introuvable! Création d'un nouveau..."
   set maxfile [open $max(file) w]
   close $maxfile
}

bind join -|- * max:join
proc max:join {nick uhost hand channel} {
   global max botnick
   set newdata ""
   set ok 0
   if {(([lsearch -exact [string tolower $max(chans)] [string tolower $channel]] != -1) || ($max(chans) == "*"))} {
      set channel [string tolower $channel]
      set inchannel [llength [chanlist $channel]]
      set maxfile [open $max(file) r]
      if {$nick == "$botnick"} {
         while {![eof $maxfile]} {
            set input [gets $maxfile]
            foreach maxchan $input {
               if {([lindex $maxchan 0] == "$channel") && ($inchannel > [lindex $maxchan 1])} {
                  lappend newdata "$channel $inchannel [clock seconds]"
                  set ok 1
               } elseif {[lindex $maxchan 0] == "$channel"} {
                  lappend newdata "$maxchan"
                  set ok 1
               } else { lappend newdata "$maxchan" }
            }
         }
         if {!$ok} { lappend newdata "$channel $inchannel [clock seconds]" }

      } else {

         while {![eof $maxfile]} {
            set input [gets $maxfile]
            foreach maxchan $input {
               if {([lindex $maxchan 0] == "$channel") && ($inchannel > [lindex $maxchan 1])} {
                  lappend newdata "$channel $inchannel [clock seconds]"
                  set ok 1
                  if {$max(newrecord)} {
                     putserv "PRIVMSG $channel :Yeah! Nouveau record d'audience avec $inchannel personnes !"
                  }
               } elseif {[lindex $maxchan 0] == "$channel"} {
                  lappend newdata "$maxchan"
                  set ok 1
               } else { lappend newdata "$maxchan" }
            }
         }
         if {!$ok} {
            lappend newdata "$channel $inchannel [clock seconds]"
            if {$max(newrecord)} {
               putserv "PRIVMSG $channel :Yeah! Nouveau record d'audience avec $inchannel personnes !"
            }
         }
      }
      close $maxfile
      set maxfile [open $max(file) w]
      puts $maxfile "$newdata"
      close $maxfile
      return 1
   }
}

proc max:time {last} {
   set ans 0
   set jours 0
   set heures 0
   set mins 0
   set time [expr [unixtime] - $last]
   if {$time < 60} {return "$time sec"}
   if {$time >= 31536000} {
      set ans [expr int([expr $time/31536000])]
      set time [expr $time - [expr 31536000*$ans]]
   }
   if {$time >= 86400} {
      set jours [expr int([expr $time/86400])]
      set time [expr $time - [expr 86400*$jours]]
   }
   if {$time >= 3600} {
      set heures [expr int([expr $time/3600])]
      set time [expr $time - [expr 3600*$heures]]
   }
   if {$time >= 60} { set mins [expr int([expr $time/60])] }
   if {$ans == 0} { set output "" } elseif {$ans == 1} { set output "1 an," } { set output "$ans ans," }
   if {$jours == 1} { lappend output "1 jour," } elseif {$jours > 1} { lappend output "$jours jours," }
   if {$heures == 1} { lappend output "1 heure," } elseif {$heures > 1} { lappend output "$heures heures," }
   if {$mins == 1} { lappend output "1 minute" } elseif {$mins > 1} { lappend output "$mins minutes"}

   if {[lindex [ctime $last] 0] == "Mon"} { set jour "Lundi" }
   if {[lindex [ctime $last] 0] == "Tue"} { set jour "Mardi" }
   if {[lindex [ctime $last] 0] == "Wed"} { set jour "Mercredi" }
   if {[lindex [ctime $last] 0] == "Thu"} { set jour "Jeudi" }
   if {[lindex [ctime $last] 0] == "Fri"} { set jour "Vendredi" }
   if {[lindex [ctime $last] 0] == "Sat"} { set jour "Samedi" }
   if {[lindex [ctime $last] 0] == "Sun"} { set jour "Dimanche" }

   if {[lindex [ctime $last] 1] == "Jan"} { set mois "Janvier" }
   if {[lindex [ctime $last] 1] == "Feb"} { set mois "Février" }
   if {[lindex [ctime $last] 1] == "Mar"} { set mois "Mars" }
   if {[lindex [ctime $last] 1] == "Apr"} { set mois "Avril" }
   if {[lindex [ctime $last] 1] == "May"} { set mois "Mai" }
   if {[lindex [ctime $last] 1] == "Jun"} { set mois "Juin" }
   if {[lindex [ctime $last] 1] == "Jul"} { set mois "Juillet" }
   if {[lindex [ctime $last] 1] == "Aug"} { set mois "Août" }
   if {[lindex [ctime $last] 1] == "Sep"} { set mois "Septembre" }
   if {[lindex [ctime $last] 1] == "Oct"} { set mois "Octobre" }
   if {[lindex [ctime $last] 1] == "Nov"} { set mois "Novembre" }
   if {[lindex [ctime $last] 1] == "Dec"} { set mois "Décembre" }

   lappend output "($jour [lindex [ctime $last] 2] $mois [lindex [ctime $last] 4] à [lindex [ctime $last] 3])"
   return [string trimright [join $output] ", "]
}

bind pub -|- $max(command)max max:pub
proc max:pub {nick uhost hand channel arg} {
   global max botnick
   if {![matchattr $nick $max(ignflags) $channel]} { if {[max:flood $nick $uhost]} { return 0 } }
   set ok 0
   if {(([lsearch -exact [string tolower $max(chans)] [string tolower $channel]] != -1) || ($max(chans) == "*")) && ($nick != $botnick)} {
      set maxfile [open $max(file) r]
      while {![eof $maxfile]} {
         set input [gets $maxfile]
         foreach maxchan $input {
            if {[lindex $maxchan 0] == "[string tolower $channel]"} {
               puthelp "NOTICE $nick :L'audience maximale de $channel a été de [lindex $maxchan 1] personnes il y a [max:time [lindex $maxchan 2]]."
               set ok 1
            }
         }
      }
      if {!$ok} { puthelp "NOTICE $nick :Aucune donnée pour $channel." }
      close $maxfile
      return 1
   } else {
      puthelp "NOTICE $nick :Je ne gère pas $channel."
      return 0
   }
}

bind msg -|- max max:msg
proc max:msg {nick uhost hand arg} {
   global max botnick
   set channel [string tolower [lindex $arg 0]]
   if {![string length $channel]} {
      puthelp "NOTICE $nick :Usage: /msg $botnick max <channel>"
      return 0
   }
   set ok 0
   if {(([lsearch -exact [string tolower $max(chans)] [string tolower $channel]] != -1) || ($max(chans) == "*")) && ($nick != $botnick)} {
      set maxfile [open $max(file) r]
      while {![eof $maxfile]} {
         set input [gets $maxfile]
         foreach maxchan $input {
            if {[lindex $maxchan 0] == "[string tolower $channel]"} {
               puthelp "NOTICE $nick :L'audience maximale de $channel a été de [lindex $maxchan 1] personnes il y a [max:time [lindex $maxchan 2]]."
               set ok 1
            }
         }
      }
      if {!$ok} { puthelp "NOTICE $nick :Aucune donnée pour $channel." }
      close $maxfile
      return 1
   } else {
      puthelp "NOTICE $nick :Je ne gère pas $channel."
      return 0
   }
}

bind dcc -|- max max:dcc
proc max:dcc {hand idx arg} {
   global max botnick
   set channel [string tolower [lindex $arg 0]]
   if {![string length $channel]} {
      putdcc $idx "Usage: .max <channel>"
      return 0
   }
   set ok 0
   if {(([lsearch -exact [string tolower $max(chans)] [string tolower $channel]] != -1) || ($max(chans) == "*"))} {
      set maxfile [open $max(file) r]
      while {![eof $maxfile]} {
         set input [gets $maxfile]
         foreach maxchan $input {
            if {[lindex $maxchan 0] == "[string tolower $channel]"} {
               putdcc $idx "L'audience maximale de $channel a été de [lindex $maxchan 1] personnes il y a [max:time [lindex $maxchan 2]]."
               set ok 1
            }
         }
      }
      if {!$ok} { putdcc $idx "Aucune donnée pour $channel." }
      close $maxfile
      return 1
   } else {
      putdcc $idx "Je ne gère pas $channel."
      return 0
   }
}

putlog "Audience Recorder v2.0"
Dylan
Dylan
Administrateur

Messages : 221
Date d'inscription : 23/11/2009
Age : 29
Localisation : Chez moi ...

https://scripting.forumactif.com

Revenir en haut Aller en bas

Revenir en haut


 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum