Aide pour modifier un script de quote
#1
Bonjour,
Alors voila, j'ai réussi à choper sur votre forum un script tcl de quote.
Actuellement, on doit etre connecter à un channel définie (#Aldea) et taper les commandes sur ce même channel pour pouvoir interagir avec le bot. (ex: !quote 3 : pour voir la quote numéro 3)

Maintenant, j'aimerais que le Bot réponde aux commandes qu'on lui envoie aussi en /msg et non plus que dans le channel.
Et la par contre, je bloque méchamment.
Je vous demande de l'aide donc ^^

Les commandes qui DOIVENT pouvoir être effectuées en /msg sont principalement :

!quote
!addquote
!quoteinfo
!randquote
!lastquote
!findquote
Le reste ce n'est pas obligatoire voir même inutile.

En vous remerciant par avance pour toute aide, quelle qu'elle soit
tcl
###############################################
#                                               #
#    P U B L I C   Q U O T E S   S Y S T E M    #
#      v1.32fr (04/09/2008) par MenzAgitat      #
#                                               #
#        http://www.boulets-roxx.com            #
#        IRC:  irc.teepi.net    #boulets        #
#              irc.epiknet.org  #boulets        #
#                                               #
#     Mes scripts sont téléchargeables sur      #
#            http://www.egghelp.org             #
#        ou  http://www.eggdrop.fr              #
#                                               #
#-----------------------------------------------#
# Remerciements à Galdinx pour les nombreux     #
# coups de main et à tous les autres pour le    #
# beta testing.                                 #
 ###############################################

#
# Changelog :
#  0.01a (pre-release alpha)
#  0.02b (pre-release beta)
#    - ajout d'un antiflood individuel (sur chaque commande publique)
#    - ajout d'un antiflood global (toutes commandes publiques confondues)
#    - ajout d'un antiflood sur les messages d'avertissement de l'antiflood  8]
#    - correction de failles de sécurité
#  0.03RC1 (release candidate 1)
#    - ajout d'une fonction de backup automatique des bases de données
#    - ajout d'une fonction de restauration automatique d'un backup
#      si la base de données est manquante et qu'un backup existe.
#  1.0
#    - ajout d'une option de recherche globale pour la commande findquote
#      (paramètre -all)
#  1.1
#    - correction d'une faille de sécurité
#  1.2
#    - reconnaissance du mode +c (filtrage de la couleur, gras, souligné) :
#      tous les affichages passent automatiquement en monochromie et tous
#      les codes de contrôle sont éliminés si ce mode est détecté sur un chan.
#  1.21 (ne concerne que la version anglaise)
#  1.22
#    - correction d'un bug mineur dans le message de log lors du backup des
#      bases de données.
#  1.3
#    - quelques corrections esthétiques
#    - correction d'un bug avec !findquote : le caractère pipe faisait
#      malencontreusement partie des caractères interdits.
#    - ajout de la commande !cancelquote qui permet d'annuler la dernière citation
#      enregistrée.
#    - ajout de nouveaux paramètres réglables dans la section configuration.
#  1.31
#    - correction d'un bug empêchant la procédure de désinstallation avant rehash
#      de fonctionner.
#  1.32
#    - la commande !deletedquoteinfo envoie maintenant les informations en notice.
#		 - les chans dont le nom comporte des caractères spéciaux sont maintenant
#			 supportés.

#
# Description :
# Ce script ajoute les commandes suivantes :
#     !addquote <citation> :
#        Enregistrer une citation.
#     !quote <n° de citation> [#chan] :
#        Afficher une citation.
#     !quoteinfo <n° de citation> [#chan] :
#        Afficher des informations sur une citation.
#     !delquote <n° de citation> :
#        Effacer une citation.
#     !randquote [#chan] :
#        Afficher une citation aléatoire.
#     !lastquote [#chan] :
#        Afficher la dernière citation enregistrée.
#     !findquote [-all/#chan] <argument(s) de recherche> :
#        Rechercher une citation.
#        Mettez des " " autour de vos arguments de recherche pour rechercher
#        l'expression exacte.
#        Utilisez le paramètre -all pour effectuer une recherche globale
#        dans les bases de données de TOUS les chans OU précisez le chan
#        sur lequel vous souhaitez effectuer la recherche.
#     !deletedquoteinfo <n° de citation> : afficher des informations sur une citation
#       effacée (commande admin)
#     !undelquote <n° de citation> : restaure une citation effacée (commande admin)
#     !forcedelquote <n° de citation> : efface une citation même si vous n'en êtes pas
#       l'auteur (commande admin)
#     !cancelquote <n° de la dernière citation> : annule la dernière quote ajoutée sur
#        le chan en cours (n'en laisse aucune trace dans la base de données)
#        (commande admin)
#
# Inutile de préciser que les commandes !forcedelquote et !cancelquotes doivent être
# utilisées avec éthique, pour des opérations de maintenance ou pour faire face à un
# abus de la part des usagers notamment.
#
# Un répertoire nommé quotes.db va être automatiquement créé dans le répertoire de
# l'eggdrop. Il contiendra les bases de données de citations.
#

#
# LICENCE:
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A RTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
 
namespace eval pubqsys {
 
############################
#      CONFIGURATION       #
############################

	# Chans sur lesquels les citations sont activées (séparés par un espace).
	# exemple : {#chan1 #chan2 #chan3} ou {#chan1}
	# attention, si le nom du chan contient le caractère } ou { , vous devez
	# le remplacer par \} ou \{. exemple : si votre chan s'appelle #mon{chan},
	# mettez #mon\{chan\}.
	variable allowed_chans {#Aldea}

 
	#### COMMANDES PUBLIQUES ET AUTORISATIONS
   
	# Commande utilisée pour afficher une citation
	# ex. : "!quote"
	variable quotecmd "!quote"
	# autorisations pour la commande !quote
	variable quoteauth "-|-"
   
	# Commande utilisée pour ajouter une citation 
	# ex. : "!addquote"
	variable addquotecmd "!addquote"
	# autorisations pour la commande !addquote
	variable addquoteauth "-|-"
   
	# Commande utilisée pour afficher des informations sur une citation 
	# ex. : "!quoteinfo"
	variable quoteinfocmd "!quoteinfo"
	# autorisations pour la commande !quoteinfo
	variable quoteinfoauth "-|-"
   
	# Commande utilisée pour effacer une citation
	# ex. : "!delquote"
	variable delquotecmd "!delquote"
	# autorisations pour la commande !delquote
	variable delquoteauth "-|-"
   
	# Commande utilisée pour afficher une citation aléatoire
	# ex. : "!randquote"
	variable randquotecmd "!randquote"
	# autorisations pour la commande !randquote
	variable randquoteauth "-|-"
   
	# Commande utilisée pour afficher la dernière citation en date
	# ex. : "!lastquote"
	variable lastquotecmd "!lastquote"
	# autorisations pour la commande !lastquote
	variable lastquoteauth "-|-"
   
	# Commande utilisée pour rechercher une citation
	# ex. : "!findquote"
	variable findquotecmd "!findquote"
	# autorisations pour la commande !findquote
	variable findquoteauth "-|-"

 
	#### COMMANDES D'ADMINISTRATION ET AUTORISATIONS
   
	# Commande utilisée pour afficher des informations sur une citation effacée
	# ex. : "!deletedquoteinfo"
	variable deletedquoteinfocmd "!deletedquoteinfo"
	# autorisations pour la commande !deletedquoteinfo
	variable deletedquoteinfoauth "nm|nm"
   
	# Commande utilisée pour restaurer une citation effacée
	# ex. : "!undelquote"
	variable undelquotecmd "!undelquote"
	# autorisations pour la commande !undelquote
	variable undelquoteauth "nm|nm"
   
	# Commande utilisée pour effacer une citation (modération administrateur)
	# ex. : "!forcedelquote"
	variable forcedelquotecmd "!forcedelquote"
	# autorisations pour la commande !forcedelquote
	variable forcedelquoteauth "nm|nm"
   
	# Commande utilisée pour annuler la dernière citation enregistrée
	# ex. : "!cancelquote"
	variable cancelquotecmd "!cancelquote"
	# autorisations pour la commande !cancelquote
	variable cancelquoteauth "nm|nm"

 
	#### PARAMETRES DE RECHERCHE

  # Nombre maximum de citations récentes à afficher pour !findquote
  variable maxfindquote 2
  # Nombre maximum de résultats que le la commande !findquote est
  # autorisée à gérer. Si vous limitez par exemple à 100 et qu'une
  # recherche renvoie plus de 100 résultats, il sera demandé à
  # l'utilisateur de préciser sa recherche en raison du trop grand
  # nombre de résultats. Si vous ne souhaitez pas imposer de limite,
  # mettez 0.
  variable maxfindquotetotal 100

 
	#### PARAMETRES DE L'ANTI-FLOOD
  
  # Anti-flood (0 = désactivé, 1 = activé)
  variable antiflood 1
  # Contrôle anti-flood individuel
  # "6:30" = 6 commandes maximum en 30 secondes; les suivantes seront ignorées.
  variable cmdflood_addquote "3:80"
  variable cmdflood_quote "5:80"
  variable cmdflood_quoteinfo "5:80"
  variable cmdflood_delquote "2:60"
  variable cmdflood_randquote "5:80"
  variable cmdflood_lastquote "2:60"
  variable cmdflood_findquote "3:80"
  # Contrôle anti-flood global (toutes commandes confondues)
  # remarque : pour le nombre de commandes, spécifiez une valeur supérieure à
  #            la plus grande valeur définie pour le contrôle de flood
  #            individuel.
  variable cmdflood_global "10:120"
  # Intervalle de temps minimum entre l'affichage de 2 messages
  # avertissant que l'anti-flood a été déclenché (ne réglez pas
  # cette valeur trop bas afin de ne pas être floodé par les messages
  # d'avertissement de l'anti-flood...)
  variable antiflood_msg_interval 20

 
	#### PARAMETRES DE SAUVEGARDE

  # Heure de la sauvegarde quotidienne des bases de données.
  variable backuptime "00:00"

 
 
####################################################################
#                                                                  #
#   DO NOT MODIFY ANYTHING BELOW THIS BOX IF YOU DON'T KNOW TCL    #
#                                                                  #
# NE MODIFIEZ RIEN APRES CE CADRE SI VOUS NE CONNAISSEZ PAS LE TCL #
#                                                                  #
####################################################################
 
  variable version "1.32.20080904fr"
  variable floodsettingsstring [split "global $cmdflood_global addquote $cmdflood_addquote quote $cmdflood_quote quoteinfo $cmdflood_quoteinfo delquote $cmdflood_delquote randquote $cmdflood_randquote lastquote $cmdflood_lastquote findquote $cmdflood_findquote"]
  variable floodsettings ; array set floodsettings $floodsettingsstring
  variable instance ; array set instance {}
  variable antiflood_msg ; array set antiflood_msg {}
  variable backuptime [split $backuptime ":"]
  variable allowed_chans [split $allowed_chans]
  array unset quoteslist
  bind pub $pubqsys::quoteauth $pubqsys::quotecmd pubqsys::quote
  bind pub $pubqsys::addquoteauth $pubqsys::addquotecmd pubqsys::addquote
  bind pub $pubqsys::quoteinfoauth $pubqsys::quoteinfocmd pubqsys::quoteinfo
  bind pub $pubqsys::delquoteauth $pubqsys::delquotecmd pubqsys::delquote
  bind pub $pubqsys::randquoteauth $pubqsys::randquotecmd pubqsys::randquote
  bind pub $pubqsys::lastquoteauth $pubqsys::lastquotecmd pubqsys::lastquote
  bind pub $pubqsys::findquoteauth $pubqsys::findquotecmd pubqsys::findquote
  bind pub $pubqsys::deletedquoteinfoauth $pubqsys::deletedquoteinfocmd pubqsys::deletedquoteinfo
  bind pub $pubqsys::undelquoteauth $pubqsys::undelquotecmd pubqsys::undelquote
  bind pub $pubqsys::forcedelquoteauth $pubqsys::forcedelquotecmd pubqsys::forcedelquote
  bind pub $pubqsys::cancelquoteauth $pubqsys::cancelquotecmd pubqsys::cancelquote
  bind evnt - prerehash pubqsys::uninstall 
  bind time - "[lindex $pubqsys::backuptime 1] [lindex $pubqsys::backuptime 0] * * *" pubqsys::backup_db
  proc uninstall {args} {
		putlog "Désallocation des ressources de \002Public Quotes System...\002"
	  unbind pub $pubqsys::quoteauth $pubqsys::quotecmd pubqsys::quote
  	unbind pub $pubqsys::addquoteauth $pubqsys::addquotecmd pubqsys::addquote
  	unbind pub $pubqsys::quoteinfoauth $pubqsys::quoteinfocmd pubqsys::quoteinfo
  	unbind pub $pubqsys::delquoteauth $pubqsys::delquotecmd pubqsys::delquote
  	unbind pub $pubqsys::randquoteauth $pubqsys::randquotecmd pubqsys::randquote
  	unbind pub $pubqsys::lastquoteauth $pubqsys::lastquotecmd pubqsys::lastquote
  	unbind pub $pubqsys::findquoteauth $pubqsys::findquotecmd pubqsys::findquote
  	unbind pub $pubqsys::deletedquoteinfoauth $pubqsys::deletedquoteinfocmd pubqsys::deletedquoteinfo
  	unbind pub $pubqsys::undelquoteauth $pubqsys::undelquotecmd pubqsys::undelquote
  	unbind pub $pubqsys::forcedelquoteauth $pubqsys::forcedelquotecmd pubqsys::forcedelquote
  	unbind pub $pubqsys::cancelquoteauth $pubqsys::cancelquotecmd pubqsys::cancelquote
    unbind evnt - prerehash pubqsys::uninstall 
    unbind time - "[lindex $pubqsys::backuptime 1] [lindex $pubqsys::backuptime 0] * * *" pubqsys::backup_db
    namespace delete ::pubqsys
  }
}
 
proc pubqsys::quote {nick host hand chan arg} {
  variable quoteslist
  if {[pubqsys::channel_check $chan] == 0} {
    return
  } elseif {($pubqsys::antiflood == 1) && (([pubqsys::antiflood $chan "global"] == "flood") || ([pubqsys::antiflood $chan "quote"] == "flood"))} {
    return
  } elseif {([regexp {^[0-9]+$} $arg] == 0) && ([string first # [join [lindex $arg 1]]] != 0)} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La syntaxe correcte est [code bold $chan]!quote[code bold $chan] [code 14 $chan]<[code endcolor $chan]n° de la citation[code 14 $chan]> \[[code endcolor $chan]#chan[code 14 $chan]\][code endcolor $chan]"
    return
  } elseif {([string first # [join [lindex $arg 1]]] == 0) && ([pubqsys::channel_check [lindex $arg 1]] == 0)} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Les citations ne sont pas activées sur le chan [join [lindex $arg 1]]."
    return
  } else {
    if {[lindex $arg 1] == ""} {
      set channame [string replace $chan 0 0]
      set quotenumber [string trimleft $arg "0"]
    } else {
      set channame [string replace [join [lindex $arg 1]] 0 0]
      set quotenumber [string trimleft [join [lindex $arg 0]] "0"]
    }
    if {(![info exists quoteslist($channame)]) || ($quoteslist($channame) == "")} {
      if { [pubqsys::read_quotes $chan $channame "quote"] == "missing" } { return }
    }
    set numquotes [llength $quoteslist($channame)]
    if { $quotenumber > $numquotes } {
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La citation n°$quotenumber n'existe pas encore. ($numquotes citations dans la base de données à ce jour)."
      return
    }   
    set quote [split [lindex $quoteslist($channame) [expr $quotenumber - 1]]]
  }
  if {[set index1 [lindex $quote 0]] == $quotenumber} {
    puthelp "PRIVMSG $chan :\[[code bold $chan][code underline $chan]$quotenumber[code underline $chan][code bold $chan]\] [filtercodes [join [lrange $quote 5 end]] $chan]"
  } elseif {$index1 == "-deleted-"} {
    if {[string match *(admin)* [set whodel [join [split [lindex $quote 1]]]]] == 1} { set whodel "un administrateur" }
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La citation n°$quotenumber n'existe plus, elle a été supprimée le [lindex $quote 2] à [lindex $quote 3] par $whodel sur [join [split [lindex $quote 4]]]."
  } else {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Incohérence détectée dans la base de données."
  }
  return
}
 
proc pubqsys::addquote {nick host hand chan arg} {
  if {[pubqsys::channel_check $chan] == 0} {
    return
  } elseif {($pubqsys::antiflood == 1) && (([pubqsys::antiflood $chan "global"] == "flood") || ([pubqsys::antiflood $chan "addquote"] == "flood"))} {
    return
  } elseif {$arg == ""} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La syntaxe correcte est [code bold $chan]!addquote[code bold $chan] [code 14 $chan]<[code endcolor $chan]citation[code 14 $chan]>[code endcolor $chan]"
  } elseif {([string length $arg] < 10) || ([llength [split $arg]] < 3)} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Vous ne pouvez pas enregistrer des citations de moins de 10 caractères ni de moins de 3 mots."
  } else {
    set channame [string replace $chan 0 0]
    variable quoteslist
    if { (![info exists quoteslist($channame)]) || ($quoteslist($channame) == "")} { pubqsys::read_quotes $chan $channame "addquote" }
    set numquotes [llength $quoteslist($channame)]
    set quote "[expr $numquotes + 1] [strftime %d/%m/%Y [unixtime]] [strftime %H:%M:%S [unixtime]] $chan $nick $arg"
    lappend quoteslist($channame) $quote
    pubqsys::write_quotes $channame
    puthelp "PRIVMSG $chan :Citation n°[expr $numquotes + 1] ajoutée."
  }
  return
}
 
proc pubqsys::quoteinfo {nick host hand chan arg} {
  if {[pubqsys::channel_check $chan] == 0} {
    return
  } elseif {($pubqsys::antiflood == 1) && (([pubqsys::antiflood $chan "global"] == "flood") || ([pubqsys::antiflood $chan "quoteinfo"] == "flood"))} {
    return
  } elseif {([regexp {^[0-9]+$} $arg] == 0) && ([string first # [join [lindex $arg 1]]] != 0)} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La syntaxe correcte est [code bold $chan]!quoteinfo[code bold $chan] [code 14 $chan]<[code endcolor $chan]n° de la citation[code 14 $chan]> \[[code endcolor $chan]#chan[code 14 $chan]\][code endcolor $chan]"
    return
  } elseif {([string first # [join [lindex $arg 1]]] == 0) && ([pubqsys::channel_check [lindex $arg 1]] == 0)} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Les citations ne sont pas activées sur le chan [join [lindex $arg 1]]."
    return
  } else {
    if {[lindex $arg 1] == ""} {
      set channame [string replace $chan 0 0]
      set quotenumber [string trimleft $arg "0"]
    } else {
      set channame [string replace [join [lindex $arg 1]] 0 0]
      set quotenumber [string trimleft [join [lindex $arg 0]] "0"]
    }
    variable quoteslist
    if {(![info exists quoteslist($channame)]) || ($quoteslist($channame) == "")} {
      if { [pubqsys::read_quotes $chan $channame "quoteinfo"] == "missing" } { return }
    }
    set numquotes [llength $quoteslist($channame)]
    if { $quotenumber > $numquotes } {
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La citation n°$quotenumber n'existe pas encore. ($numquotes citations dans la base de données à ce jour)."
      return
    }   
    set quote [split [lindex $quoteslist($channame) [expr $quotenumber - 1]]]
  }
  if {[set index1 [lindex $quote 0]] == $quotenumber} {
    puthelp "PRIVMSG $chan :La citation n°$quotenumber a été enregistrée sur [join [split [lindex $quote 3]]] le [lindex $quote 1] à [lindex $quote 2] par [join [split [lindex $quote 4]]]."
  } elseif {$index1 == "-deleted-"} {
    if {[string match *(admin)* [set whodel [join [split [lindex $quote 1]]]]] == 1} { set whodel "un administrateur" }
    puthelp "PRIVMSG $chan :La citation n°$quotenumber n'existe plus, elle a été supprimée le [lindex $quote 2] à [lindex $quote 3] par $whodel sur [join [split [lindex $quote 4]]]."
  } else {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Incohérence détectée dans la base de données."
  }
  return
}
 
proc pubqsys::delquote {nick host hand chan arg} {
  if {[pubqsys::channel_check $chan] == 0} {
    return
  } elseif {($pubqsys::antiflood == 1) && (([pubqsys::antiflood $chan "global"] == "flood") || ([pubqsys::antiflood $chan "delquote"] == "flood"))} {
    return
  } elseif {[regexp {^[0-9]+$} $arg] == 0} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La syntaxe correcte est [code bold $chan]!delquote[code bold $chan] [code 14 $chan]<[code endcolor $chan]n° de la citation[code 14 $chan]>[code endcolor $chan]  (vous devez en être l'auteur)"
    return
  } else {
    set channame [string replace $chan 0 0]
    set quotenumber [string trimleft $arg "0"]
    variable quoteslist
    if {(![info exists quoteslist($channame)]) || ($quoteslist($channame) == "")} {
      if { [pubqsys::read_quotes $chan $channame "delquote"] == "missing" } { return }
    }
    set numquotes [llength $quoteslist($channame)]
    if { $quotenumber > $numquotes } {
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La citation n°$quotenumber n'existe pas encore. ($numquotes citations dans la base de données à ce jour)."
      return
    }   
    set quote [lindex $quoteslist($channame) [expr $quotenumber - 1]]
  }
  if {[set index1 [lindex [split $quote] 0]] == $quotenumber} {
    if {[set author [join [lindex [split $quote] 4]]] != $nick} {
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Vous n'êtes pas autorisé à effacer cette citation. Son auteur est [code bold $chan]$author[code bold $chan]."
      return
    }
    set deletedquote "-deleted- $nick [strftime %d/%m/%Y [unixtime]] [strftime %H:%M:%S [unixtime]] $chan -------- $nick!$host a effacé : $quote"
    set quoteslist($channame) [lreplace $quoteslist($channame) [set index2 [expr $quotenumber - 1]] $index2 $deletedquote]
    pubqsys::write_quotes $channame
    puthelp "PRIVMSG $chan :Citation n°$quotenumber effacée."
  } elseif {$index1 == "-deleted-"} {
    if {[string match *(admin)* [set whodel [join [split [lindex $quote 1]]]]] == 1} { set whodel "un administrateur" }
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La citation n°$quotenumber n'existe plus, elle a déjà été supprimée le [lindex $quote 2] à [lindex $quote 3] par $whodel sur [join [split [lindex $quote 4]]]."
  } else {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Incohérence détectée dans la base de données."
  }
  return
}
 
proc pubqsys::randquote {nick host hand chan arg} {
  if {[pubqsys::channel_check $chan] == 0} {
    return
  } elseif {($pubqsys::antiflood == 1) && (([pubqsys::antiflood $chan "global"] == "flood") || ([pubqsys::antiflood $chan "randquote"] == "flood"))} {
    return
  } elseif {($arg != "") && (([string first # [join $arg]] != 0) || ([llength $arg] > 1))} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La syntaxe correcte est [code bold $chan]!randquote[code bold $chan] [code 14 $chan]\[[code endcolor $chan]#chan[code 14 $chan]\][code endcolor $chan]"
  } elseif {($arg != "") && ([string first # [join $arg]] == 0) && ([pubqsys::channel_check [join $arg]] == 0)} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Les citations ne sont pas activées sur le chan [join $arg]."
    return
  } else {
    if {[lindex $arg 0] == ""} {
      set channame [string replace $chan 0 0]
    } else {
      set channame [string replace [join [lindex $arg 0]] 0 0]
    }
    variable quoteslist
    if {(![info exists quoteslist($channame)]) || ($quoteslist($channame) == "")} {
      if { [pubqsys::read_quotes $chan $channame "randquote"] == "missing" } { return }
    }
    set existingquotes [lsearch -all -inline -regexp $pubqsys::quoteslist($channame) {^(?!-deleted-(.*))}]
    set numquotes [llength $existingquotes]
    if {$numquotes == 0} {
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Aucune citation valide n'a été trouvée."
      return
    }
    set quote [split [lindex $existingquotes [rand $numquotes]]]
    puthelp "PRIVMSG $chan :\[[code bold $chan][code underline $chan][lindex $quote 0][code underline $chan][code bold $chan]\] [filtercodes [join [lrange $quote 5 end]] $chan]"
    return    
  }
}
 
proc pubqsys::lastquote {nick host hand chan arg} {
  if {[pubqsys::channel_check $chan] == 0} {
    return
  } elseif {($pubqsys::antiflood == 1) && (([pubqsys::antiflood $chan "global"] == "flood") || ([pubqsys::antiflood $chan "lastquote"] == "flood"))} {
    return
  } elseif {($arg != "") && (([string first # [join $arg]] != 0) || ([llength $arg] > 1))} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La syntaxe correcte est [code bold $chan]!lastquote[code bold $chan] [code 14 $chan]\[[code endcolor $chan]#chan[code 14 $chan]\][code endcolor $chan]"
  } elseif {($arg != "") && ([string first # [join $arg]] == 0) && ([pubqsys::channel_check [join $arg]] == 0)} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Les citations ne sont pas activées sur le chan [join $arg]."
    return
  } else {
    if {[lindex $arg 0] == ""} {
      set channame [string replace $chan 0 0]
    } else {
      set channame [string replace [join [lindex $arg 0]] 0 0]
    }
    variable quoteslist
    if {(![info exists quoteslist($channame)]) || ($quoteslist($channame) == "")} {
      if { [pubqsys::read_quotes $chan $channame "lastquote"] == "missing" } { return }
    }
    set existingquotes [lsearch -all -inline -regexp $pubqsys::quoteslist($channame) {^(?!-deleted-(.*))}]
    set numexistingquotes [llength $existingquotes]
    set numquotes [llength $quoteslist($channame)]
    set lastrawquote [split [lindex $quoteslist($channame) [expr $numquotes - 1]]]
    if {$numquotes == 0} {
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Aucune citation valide n'a été trouvée."
      return
    }
    if {[lindex $lastrawquote 0] == "-deleted-"} {
      if {[string match *(admin)* [set whodel [join [split [lindex $lastrawquote 1]]]]] == 1} { set whodel "un administrateur" }
      puthelp "PRIVMSG $chan :[code 14 $chan]La dernière citation en date (n°$numquotes) n'existe plus, elle a été supprimée le [lindex $lastrawquote 2] à [lindex $lastrawquote 3] par $whodel sur [join [split [lindex $lastrawquote 4]]]. Recherche de la dernière citation valide...[code endcolor $chan]"
    }
    set quote [split [lindex $existingquotes [expr $numexistingquotes - 1]]]
    puthelp "PRIVMSG $chan :\[[code bold $chan][code underline $chan][lindex $quote 0][code underline $chan][code bold $chan]\] [filtercodes [join [lrange $quote 5 end]] $chan]"
    return    
  }
}
 
proc pubqsys::findquote {nick host hand chan {arg}} {
  if {[pubqsys::channel_check $chan] == 0} {
    return
  } elseif {($pubqsys::antiflood == 1) && (([pubqsys::antiflood $chan "global"] == "flood") || ([pubqsys::antiflood $chan "findquote"] == "flood"))} {
    return
  } elseif {[pubqsys::isargclean $chan $arg] == "dirty"} {
    return
  } elseif {($arg == "") || (([lindex $arg 0] == "-all") && ([lindex $arg 1] == ""))} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La syntaxe correcte est [code bold $chan]!findquote[code bold $chan] [code 14 $chan]\[[code endcolor $chan]-all[code 14 $chan]/[code endcolor $chan]#chan[code 14 $chan]\] <[code endcolor $chan]critères de recherche[code 14 $chan]>  [code 07 $chan]|[code endcolor $chan] Utilisez des guillemets pour faire une recherche exacte. [code underline $chan]Exemples[code underline $chan] : [code bold $chan]!findquote un test[code bold $chan] (trouve toutes les citations qui contiennent le mot [code bold $chan]un[code bold $chan] [code underline $chan]et[code underline $chan] le mot [code bold $chan]test[code bold $chan]).  [code bold $chan]!findquote \"un test\"[code bold $chan] (trouve toutes les citations qui contiennent exactement \"[code bold $chan]un test[code bold $chan]\").[code endcolor $chan]"
    return
  } elseif {([string first # [join $arg]] == 0) && ([lindex $arg 1] != "") && ([pubqsys::channel_check [join [lindex $arg 0]]] == 0)} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Les citations ne sont pas activées sur le chan [join [lindex $arg 0]]."
    return
  } elseif {([string length [join $arg]] < 3) || ((([string first # [join $arg]] == 0) || ([lindex $arg 0] == "-all")) && ([lindex $arg 1] != "") && ([string length [join [lrange $arg 1 end]]] < 3))} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Votre recherche doit comporter au moins 3 caractères."
    return
  } else {
    if {([string first # [join $arg]] == 0) && ([lindex $arg 1] != "")} {
      set channame [string replace [join [lindex $arg 0]] 0 0]
      set searcharguments [pubqsys::cleanarg [join [lrange $arg 1 end]]]
    } elseif {[lindex $arg 0] == "-all"} {
      if {[llength $pubqsys::allowed_chans] == 1} {
        puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Remarque[code underline $chan] : Le paramètre -all est superflu car les citations ne sont activées que sur un seul chan."
        set channame [string replace $chan 0 0]
      } else {
        set channame "-all"
      }
      set searcharguments [pubqsys::cleanarg [join [lrange $arg 1 end]]]
    } else {
      set channame [string replace $chan 0 0]
      set searcharguments [pubqsys::cleanarg $arg]
    }
    variable quoteslist
    if {$channame != "-all"} {
      if {(![info exists quoteslist($channame)]) || ($quoteslist($channame) == "")} {
        if { [pubqsys::read_quotes $chan $channame "findquote"] == "missing" } { return }
      }
    } else {
      set quoteslist(-all) ""
      foreach channameall $pubqsys::allowed_chans {
        set channameall [string replace $channameall 0 0]
        if {[file exists "quotes.db/quotes.$channameall"]} {
          variable quotesfile [open "quotes.db/quotes.$channameall" r]
          set quoteslist(-all) "$quoteslist(-all) [split [read -nonewline $quotesfile] \n]"
          close $quotesfile
        }
      }
      if {$quoteslist(-all) == ""} {
        puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Aucune base de données n'est disponible pour effectuer la recherche."
        return
      }
    }
    set filter_quotes $quoteslist($channame)
    foreach element $searcharguments {
      set filter_quotes [lsearch -all -inline -regexp $filter_quotes "(?i)^\[0-9\]+ \[^\ \]+ \[^\ \]+ \[^\ \]+ \[^\ \]+ .*($element).*$"]
    }
    set numresults [llength $filter_quotes]
    if {$numresults == 0} {
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] La recherche n'a rien donné."
      return
    } elseif {$numresults == "1"} {
      if {$channame != "-all"} {
        puthelp "PRIVMSG $chan :[code underline $chan]$numresults résultat a été trouvé[code underline $chan] :"
      } else {
        puthelp "PRIVMSG $chan :[code underline $chan]$numresults résultat a été trouvé sur [lindex [split [join $filter_quotes]] 3][code underline $chan] :"
      }
    } elseif {($numresults > $pubqsys::maxfindquotetotal) && ($pubqsys::maxfindquotetotal != 0)} {
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] La recherche a donné plus de $pubqsys::maxfindquotetotal résultats ($numresults précisément). Essayez d'être plus précis afin d'en limiter le nombre."
      return
    } else {
      if {$channame != "-all"} {
        set foundquotenumbers "[code underline $chan]$numresults résultats ont été trouvés[code underline $chan] : "
        foreach element $filter_quotes {
          set foundquotenumbers "$foundquotenumbers[code bold $chan][code bold $chan][lindex [split $element] 0][code 14 $chan]|[code endcolor $chan]"
          if {[string length [join $foundquotenumbers]] >= 440} {
            puthelp "PRIVMSG $chan :$foundquotenumbers"
            set foundquotenumbers ""
          }
        }
        if {$foundquotenumbers != ""} {
          puthelp "PRIVMSG $chan :$foundquotenumbers"
        }
      } else {
        set resultchanlist ""
        set chronolist ""
        foreach element $filter_quotes {
          set element [split $element]
          set resultchanlist "$resultchanlist [lindex $element 3]"
          lappend chronolist "[lindex [set date [split [lindex $element 1] "/"]] 2][lindex $date 1][lindex $date 0][join [split [lindex $element 2] ":"] ""] [lindex $element 0] [join [lrange $element 3 end]]"
          set chronolist [lsort $chronolist]
        }
        set resultchanlist [join [lsort -unique $resultchanlist]]
        puthelp "PRIVMSG $chan :[code underline $chan]$numresults résultats ont été trouvés sur les chans suivants[code underline $chan] : $resultchanlist"
        puthelp "PRIVMSG $chan :[code underline $chan]Citations récentes[code underline $chan] :"
        for { set counter 0 } { ($counter < $pubqsys::maxfindquote) && ($counter < $numresults) } { incr counter } {
          set quote [split [lindex $chronolist [expr $numresults - ($counter + 1)]]]
          puthelp "PRIVMSG $chan :[code 14 $chan][join [lindex $quote 2]][code endcolor $chan] \[[code bold $chan][code underline $chan][lindex $quote 1][code underline $chan][code bold $chan]\] [filtercodes [join [lreplace $quote 0 3]] $chan]"
        }
        return
      }
      puthelp "PRIVMSG $chan :[code underline $chan]Citations récentes[code underline $chan] :"
    }
    for { set counter 0 } { ($counter < $pubqsys::maxfindquote) && ($counter < $numresults) } { incr counter } {
      set quote [split [lindex $filter_quotes [expr $numresults - ($counter + 1)]]]
      puthelp "PRIVMSG $chan :\[[code bold $chan][code underline $chan][lindex $quote 0][code underline $chan][code bold $chan]\] [filtercodes [join [lreplace $quote 0 4]] $chan]"
    }
    return
  }
}
 
proc pubqsys::deletedquoteinfo {nick host hand chan arg} {
  if {[pubqsys::channel_check $chan] == 0} {
    return
  } elseif {[regexp {^[0-9]+$} $arg] == 0} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La syntaxe correcte est [code bold $chan]!deletedquoteinfo[code bold $chan] [code 14 $chan]<[code endcolor $chan]n° de la citation[code 14 $chan]>[code endcolor $chan]"
    return
  } else {
    set channame [string replace $chan 0 0]
    set quotenumber [string trimleft $arg "0"]
    variable quoteslist
    if {(![info exists quoteslist($channame)]) || ($quoteslist($channame) == "")} {
      if { [pubqsys::read_quotes $chan $channame "deletedquoteinfo"] == "missing" } { return }
    }
    set numquotes [llength $quoteslist($channame)]
    if { $quotenumber > $numquotes } {
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La citation n°$quotenumber n'existe pas encore. ($numquotes citations dans la base de données à ce jour)."
      return
    }   
    set quote [split [lindex $quoteslist($channame) [expr $quotenumber - 1]]]
  }
  if {[set index1 [lindex $quote 0]] == $quotenumber} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La citation n°$quotenumber existe."
  } elseif {$index1 == "-deleted-"} {
    if {[lindex $quote 6] == ""} {
      puthelp "PRIVMSG $chan :Les informations ne sont pas disponibles."
    } else {
      puthelp "NOTICE $nick :La citation n°$quotenumber a été supprimée le [lindex $quote 2] à [lindex $quote 3] par [join [split [lindex $quote 1]]] ([join [split [lindex $quote 6]]]) sur [join [split [lindex $quote 4]]]. Cette citation avait été enregistrée par [join [split [lindex $quote 14]]] sur [join [split [lindex $quote 13]]] le [lindex $quote 11] à [lindex $quote 12]. Voici la citation effacée :"
      puthelp "NOTICE $nick :\[[code bold $chan][code underline $chan][lindex $quote 10][code underline $chan][code bold $chan]\] [filtercodes [join [lrange $quote 15 end]] $chan]"
    }
  } else {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Incohérence détectée dans la base de données."
  }
  return
}
 
proc pubqsys::undelquote {nick host hand chan arg} {
  if {[pubqsys::channel_check $chan] == 0} {
    return
  } elseif {[regexp {^[0-9]+$} $arg] == 0} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La syntaxe correcte est [code bold $chan]!undelquote[code bold $chan] [code 14 $chan]<[code endcolor $chan]n° de la citation[code 14 $chan]>[code endcolor $chan]"
    return
  } else {
    set channame [string replace $chan 0 0]
    set quotenumber [string trimleft $arg "0"]
    variable quoteslist
    if {(![info exists quoteslist($channame)]) || ($quoteslist($channame) == "")} {
      if { [pubqsys::read_quotes $chan $channame "undelquote"] == "missing" } { return }
    }
    set numquotes [llength $quoteslist($channame)]
    if { $quotenumber > $numquotes } {
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La citation n°$quotenumber n'existe pas encore. ($numquotes citations dans la base de données à ce jour)."
      return
    }   
    set quote [lindex $quoteslist($channame) [expr $quotenumber - 1]]
  }
  if {[set index1 [lindex [split $quote] 0]] == $quotenumber} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La citation existe et n'a pas besoin d'être restaurée."
  } elseif {$index1 == "-deleted-"} {
    set restoredquote [join [lrange [split $quote] 10 end]]
    set quoteslist($channame) [lreplace $quoteslist($channame) [set index2 [expr $quotenumber - 1]] $index2 $restoredquote]
    pubqsys::write_quotes $channame
    puthelp "PRIVMSG $chan :Citation n°$quotenumber restaurée."
  } else {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Incohérence détectée dans la base de données."
  }
  return
}
 
proc pubqsys::forcedelquote {nick host hand chan arg} {
  if {[pubqsys::channel_check $chan] == 0} {
    return
  } elseif {[regexp {^[0-9]+$} $arg] == 0} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La syntaxe correcte est [code bold $chan]!forcedelquote[code bold $chan] [code 14 $chan]<[code endcolor $chan]n° de la citation[code 14 $chan]>[code endcolor $chan]"
    return
  } else {
    set channame [string replace $chan 0 0]
    set quotenumber [string trimleft $arg "0"]
    variable quoteslist
    if {(![info exists quoteslist($channame)]) || ($quoteslist($channame) == "")} {
      if { [pubqsys::read_quotes $chan $channame "forcedelquote"] == "missing" } { return }
    }
    set numquotes [llength $quoteslist($channame)]
    if { $quotenumber > $numquotes } {
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La citation n°$quotenumber n'existe pas encore. ($numquotes citations dans la base de données à ce jour)."
      return
    }   
    set quote [split [lindex $quoteslist($channame) [expr $quotenumber - 1]]]
  }
  if {[set index1 [lindex $quote 0]] == $quotenumber} {
    set deletedquote "-deleted- $nick[code 04 $chan]\(admin\)[code endcolor $chan] [strftime %d/%m/%Y [unixtime]] [strftime %H:%M:%S [unixtime]] $chan -------- $nick!$host a effacé : $quote"
    set quoteslist($channame) [lreplace $quoteslist($channame) [set index2 [expr $quotenumber - 1]] $index2 $deletedquote]
    pubqsys::write_quotes $channame
    puthelp "PRIVMSG $chan :Citation n°$quotenumber effacée."
  } elseif {$index1 == "-deleted-"} {
    if {[string match *(admin)* [set whodel [join [split [lindex $quote 1]]]]] == 1} { set whodel "un administrateur" }
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La citation n°$quotenumber n'existe plus, elle a déjà été supprimée le [lindex $quote 2] à [lindex $quote 3] par $whodel sur [join [split [lindex $quote 4]]]."
  } else {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Incohérence détectée dans la base de données."
  }
  return
}
 
proc pubqsys::cancelquote {nick host hand chan arg} {
  if {[pubqsys::channel_check $chan] == 0} {
    return
  } elseif {[regexp {^[0-9]+$} $arg] == 0} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : La syntaxe correcte est [code bold $chan]!cancelquote[code bold $chan] [code 14 $chan]<[code endcolor $chan]n° de la dernière citation[code 14 $chan]>[code endcolor $chan]"
    return
  } else {
    set channame [string replace $chan 0 0]
    variable quoteslist
    if {(![info exists quoteslist($channame)]) || ($quoteslist($channame) == "")} {
      if { [pubqsys::read_quotes $chan $channame "cancelquote"] == "missing" } { return }
    }
    set numquotes [llength $quoteslist($channame)]
		if { $arg != $numquotes } {
    	puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Le numéro de citation que vous avez tapé ne correspond pas à la dernière citation en date. Afin de réduire les risques d'effacement accidentel, vous devez donner le n° de la dernière citation."
			return	
		}
    set quote [split [lindex $quoteslist($channame) [expr $numquotes - 1]]]
  }
  if {([lindex $quote 0] == $numquotes) || (([lindex $quote 0] == "-deleted-") && ([lindex $quote 10] == $numquotes))} {
    set quoteslist($channame) [lreplace $quoteslist($channame) [set index2 [expr $numquotes - 1]] $index2]
    pubqsys::write_quotes $channame
    puthelp "PRIVMSG $chan :La dernière citation enregistrée a été annulée."
    puthelp "PRIVMSG $chan :[code 14 $chan]\[[code bold $chan][code underline $chan]$numquotes[code underline $chan][code bold $chan]\] [filtercodes [join [lrange $quote 5 end]] $chan][code endcolor $chan]"
  } else {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Incohérence détectée dans la base de données."
  }
  return
}
 
proc pubqsys::read_quotes {chan channame command} {
  variable quoteslist
  if {(![file exists "quotes.db/quotes.$channame"]) && ($command != "addquote") && ($command != "findquoteall")} {
    if {[file exists "quotes.db/quotes.$channame.bak"]} {
      file copy "quotes.db/quotes.$channame.bak" "quotes.db/quotes.$channame"
      puthelp "PRIVMSG $chan :[code 04 $chan]::: [code underline $chan]Problème critique[code underline $chan][code endcolor $chan] : La base de données de citations de #$channame est introuvable. Une sauvegarde a été trouvée et restaurée automatiquement."
      putlog "[code 04 $chan]\[Public Quotes System] [code underline $chan]Problème critique[code underline $chan][code endcolor $chan] : La base de données de citations de #$channame est introuvable. Une sauvegarde a été trouvée et restaurée automatiquement."
    } else {
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Base de données inexistante pour le chan #$channame."
      return "missing"
    }
  }
  if {[file exists "quotes.db/quotes.$channame"] != 0} {
    set quotesfile [open "quotes.db/quotes.$channame" r]
    set quoteslist($channame) [split [read -nonewline $quotesfile] \n]
    close $quotesfile
    if {([llength $quoteslist($channame)] == 0) && ($command != "addquote") && ($command != "findquoteall")} { 
      puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Il n'y a aucune citation dans la base de données pour l'instant."
      return "missing"
    }
  } else {
    set quoteslist($channame) ""
  }
  return
}
 
proc pubqsys::write_quotes {channame} {
  variable quoteslist
  if {![file exists "quotes.db"]} { file mkdir "quotes.db" }
  set quotesfile [open "quotes.db/quotes.$channame" w]
  puts $quotesfile [join $quoteslist($channame) \n]
  close $quotesfile
  return
}
 
proc pubqsys::cleanarg {data} {
  regsub -all {\?} $data {\\\?} data
  regsub -all {\*} $data {\\\*} data
  regsub -all {\[} $data {\\\[} data
  regsub -all {\]} $data {\\\]} data
  regsub -all {\$} $data {\\\$} data
  regsub -all {\|} $data {\\\|} data
  return $data
}
 
proc pubqsys::isargclean {chan data} {
  if {[regexp {[\{\}\\]} $data] != 0} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Vous ne pouvez pas utiliser les caractères suivants dans les arguments de recherche de la commande !findquote : [code bold $chan]\{ \} \\[code bold $chan]"
    return "dirty"
  } elseif {[expr ([set is_even [regsub -all {\"} $data "" isargcleantmp]] / 2) * 2] != $is_even} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Vous utilisez un nombre impair de guillemets dans vos arguments de recherche. Les guillemets permettent de faire une recherche exacte et doivent s'utiliser par paires. [code underline $chan]Exemple[code underline $chan] : [code bold $chan]!findquote \"un test\"[code bold $chan]"
    return "dirty"
  } elseif {[regexp {""} $data] != 0} {
    puthelp "PRIVMSG $chan :[code 04 $chan]:::[code endcolor $chan] [code underline $chan]Erreur[code underline $chan] : Vous avez utilisé [code bold $chan]\"\"[code bold $chan] dans vos arguments de recherche; cela représente une recherche exacte vide et la commande [code bold $chan]!findquote[code bold $chan] ne le permet pas. Vous devez inclure du texte entre les guillemets. [code underline $chan]Exemple[code underline $chan] : [code bold $chan]!findquote \"un test\"[code bold $chan]"
    return "dirty"
  } else {
    return "clean"
  }
}
 
proc pubqsys::channel_check {chan} {
  if {[lsearch -exact $pubqsys::allowed_chans $chan] != -1} { return 1 } { return 0 }
}
 
proc pubqsys::antiflood {chan type} {
  variable antiflood_msg
  if {![info exists antiflood_msg($chan$type)]} { set antiflood_msg($chan$type) 0 }
  variable instance
  if {![info exists instance($chan$type)]} { set instance($chan$type) 0 }
  set max_instances [lindex [split $pubqsys::floodsettings($type) ":"] 0]
  set instance_length [lindex [split $pubqsys::floodsettings($type) ":"] 1]
  if { $instance($chan$type) >= $max_instances } {
    if { $antiflood_msg($chan$type) == 0 } {
      set antiflood_msg($chan$type) 1
      if {$type != "global"} {
        putquick "privmsg $chan :[code 04 $chan]:::[code 14 $chan] Contrôle de flood activé pour la commande [code bold $chan]!$type[code bold $chan] : pas plus de $max_instances requête(s) toutes les $instance_length secondes.[code endcolor $chan]"
      } else {
        putquick "privmsg $chan :[code 04 $chan]:::[code 14 $chan] Contrôle de flood sur les commandes du système de quotes : pas plus de $max_instances commandes toutes les $instance_length secondes.[code endcolor $chan]"
      }
      utimer $pubqsys::antiflood_msg_interval "pubqsys::antiflood_msg_reset [split $chan] $type"
    }
    return "flood"
  } else {
    incr instance($chan$type)
    utimer $instance_length "pubqsys::antiflood_close_instance [split $chan] $type"
    return "no flood"
  }
}
proc pubqsys::antiflood_close_instance {chan type} {
  variable instance
  if { $instance([set chan [join $chan]]$type) > 0 } { incr instance($chan$type) -1 }
}
proc pubqsys::antiflood_msg_reset {chan type} {
  variable antiflood_msg
  set antiflood_msg([join $chan]$type) 0
}
 
proc pubqsys::backup_db {min hour day month year} {
	putlog "\00314\[Public Quotes System\]\003 Sauvegarde des bases de données..."
  foreach channame $pubqsys::allowed_chans {
    set channame [string replace $channame 0 0]
    file copy -force "quotes.db/quotes.$channame" "quotes.db/quotes.$channame.bak"
  }
}
 
proc pubqsys::code {code chan} {
  if {$code == "bold"} {
    if {![string match *c* [lindex [split [getchanmode $chan]] 0]]} { return "\002" } { return "" }
  } elseif {$code == "underline"} {
    if {![string match *c* [lindex [split [getchanmode $chan]] 0]]} { return "\037" } { return "" }
  } elseif {$code == "endcolor"} {
    if {![string match *c* [lindex [split [getchanmode $chan]] 0]]} { return "\003" } { return "" }
  } else {
    if {![string match *c* [lindex [split [getchanmode $chan]] 0]]} { return "\003$code" } { return "" }
  }
}
 
proc pubqsys::filtercodes {data chan} {
  if {[string match *c* [lindex [split [getchanmode $chan]] 0]]} {
    regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $data "" data 
  }
  return $data
}
 
 
putlog "\002*Public Quotes System v$pubqsys::version*\002 par MenzAgitat (\037\00312http://www.boulets-roxx.com\003\037) a été chargé"



NB: ne pas prendre le fichier public_quotes_system.tcl ce n'est pas le bon fichier !!!
Répondre Avertir


Messages dans ce sujet
Aide pour modifier un script de quote - par t1bz - 17/05/2010, 17:47
RE: Aide pour modifier un script de quote - par heretoc - 17/05/2010, 18:56

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit -Discutez en toute liberté