Communauté Eggdrop
adduser et modification de donnée avec accès sql - Version imprimable

+- Communauté Eggdrop (https://forum.eggdrop.fr)
+-- Forum : Eggdrop et TCL (https://forum.eggdrop.fr/forumdisplay.php?fid=8)
+--- Forum : Scripts TCL (https://forum.eggdrop.fr/forumdisplay.php?fid=4)
+--- Sujet : adduser et modification de donnée avec accès sql (/showthread.php?tid=619)



adduser et modification de donnée avec accès sql - foufou - 25/02/2010

Bonjour (il est très tot je sais :p)

Je voulais savoir comment procéder pour faire en sorte qu'avec la commande par exemple adduser cela enregistre dans la base de donnée du salon par exemple nommé #test et la liste des access nommé access puisse se faire ! Sachant que je suis débutant dans ce domaine mais cela est très pratique je pense afin de mieux gèrer les accès.

(ou bien alors une simple db sachant qu'il faudra que ca vérifie sur quel salon ou il est bien opérateur)

exemple:

TCL
bind msg o|o op xmsgop
proc xmsgop {nick userhost hand arg} {
global botnick
set password [lindex $arg 0]
set chan [lindex $arg 1]
set raison [lrange $arg 2 end]
if {![validuser $hand]} {return}
if {$arg == ""} {putnow "NOTICE $nick :Utilisation:  /msg $botnick op <mot-de-pass> <#!salon!>"; return 0}
if {![onchan $nick #Central]} {putquick "NOTICE $nick :Vous n'êtes pas sur #Central. Requête échouée !"; putquick "invite $nick #Central"; return 0}
if {$chan == ""} {putnow "NOTICE $nick :Erreur:  Il manque le salon !"; return 0}
if {![onchan $nick $chan]} {putnow "NOTICE $nick :Vous n'êtes pas sur $chan"; return 0}
if {[isop $nick $chan]} { return 0}
if {![onchan $nick $chan]} {return 0}
if {![string match #!*! $chan]} { putnow "NOTICE $nick :Erreur : Seuls les salons officiels peuvent faire l'objet d'un Opage !"; return 0 }
if {![passwdok $hand $password]} {putnow "NOTICE $nick :\002Erreur :\002 Votre mot de pass est incorrect !";return}
       if {[getuser $hand XTRA SUSPEND]=="ON"} {putnow "NOTICE $nick :Erreur: Votre accès est suspendu."; return}
	if {![matchattr $hand n] && ![matchattr $hand -|o $chan]} {putnow "NOTICE $nick :Vous n'avez pas access à $chan"; return 0}
putnow "mode $chan +o $nick"
}




J'avais aussi dans l'idée de modifier par exemple si l'user souhaite modifier son mot de pass:

Exemple:

TCL
bind msg - pass info:pass
proc info:pass { nick userhost hand arg } {
global botnick salon
set chan [lindex $arg 0]
set pass [lindex $arg 1]
if {![validuser $hand]} {return}
if {[getuser $hand XTRA SUSPEND]=="ON"} {putnow "NOTICE $nick :Erreur: Votre accès est suspendu."; return}
if {![onchan $nick #Central]} {putquick "NOTICE $nick :Vous n'êtes pas sur #Central. Requête échouée !"; putquick "invite $nick #Central"; return 0}
if {$chan == ""} {putnow "NOTICE $nick :Erreur:  Il manque le salon !"; return 0}
if {$pass == ""} {putnow "NOTICE $nick :Erreur:  Il manque Votre pass !"; return 0}
if {![string match #!*! $chan]} { putnow "NOTICE $nick :\002Erreur :\002 Seuls les salons officiels peuvent faire l'objet d'un changement de pass !"; return 0 }
setuser $hand PASS $pass
putnow "notice $nick :Votre pass est désormais $pass sur $chan"
putnow "PRIVMSG Pamela :pass $hand $pass"
}



Merci de votre aide :)


RE: adduser et modification de donnée avec accès sql - foufou - 01/03/2010

Personne saurai ?


RE: adduser et modification de donnée avec accès sql - foufou - 01/03/2010

bon vu que ça ne se bouscule pas, j'ai réussi à faire par exemple avec la commande de opage !!!! exemple :


TCL
##############
# CONFIGURATION #
##############
 
# -> Login 
set sql(login) "XXX"
# -> Mot de passe 
set sql(pass) "XXX" 
# -> Nom de la base de donnée
set sql(db) "access"
# -> L'host a l'aquelle ce connecté
set sql(host) "127.0.0.1"
# -> Localisation de fichier mysql.sock
set sql(sock) "tmp/mysql.sock"
 
###########
# PAQUETAGE #
###########
 
catch {package require mysqltcl}
 
#######
# CODE  #
#######
 
#########
# CONNECT #
#########
proc service:connect {} {
set ::mysqlink [mysqlconnect -host $::sql(host) -user $::sql(login) -password $::sql(pass) -sock $::sql(sock)]
	mysqluse $::mysqlink $::sql(db)
}
 
###########
# DECONNECT #
###########
 
proc service:deconnect {} {
	mysqlclose $::mysqlink; unset -nocomplain ::mysqlink	
}
 
########
# ISAUTH #
########
 
proc isauth {arg} {
   service:connect
   set res [mysqlsel $::mysqlink "select statut from access where pseudo = '$arg' and statut = 'On'"]
   service:deconnect
   return $res
}
 
##########
# ISSUSPEND #
##########
 
proc issuspend {arg} {
   service:connect
   set res [mysqlsel $::mysqlink "select statut from access where pseudo = '$arg' and suspend = 'On'"]
   service:deconnect
   return $res
}
 
############
# ISVALIDUSER #
############
 
proc isvaliduser {arg} {
   service:connect
   set res [mysqlsel $::mysqlink "select pseudo from access where pseudo = '$arg'"]
   service:deconnect
   return $res
}

################
# ISVALIDPASSWORD #
################
 
proc isvalidchan {mot1 mot2} {
   service:connect
   set res [mysqlsel $::mysqlink "select pseudo, pass from access where pseudo = '$mot1' and chan = '$mot2'"]
   putlog "select pseudo, pass from access where pseudo = '$mot1' and chan = '$mot2'"
   service:deconnect
   return $res
}

################
# ISVALIDPASSWORD #
################
 
proc isvalidpassword {mot1 mot2} {
   service:connect
   set res [mysqlsel $::mysqlink "select pseudo, pass from access where pseudo = '$mot1' and pass = '$mot2'"]
   putlog "select pseudo, pass from access where pseudo = '$mot1' and pass = '$mot2'"
   service:deconnect
   return $res
}
 
########
# AUTH #
########
 
proc auth {arg} {
   service:connect
   mysqlsel $::mysqlink "UPDATE `access` SET `statut` = 'On' WHERE pseudo = '$arg'"
   service:deconnect
}
 
#######
# AUTH  #
#######
 
bind msg - xauth msg:xauth
proc msg:xauth {nick host hand arg} {
   set mot1 [lindex $arg 0]
   set mot2 [lindex $arg 1]
   if { $mot1 == "" || $mot2 == "" } { puthelp "NOTICE $nick :Commande auth : /msg $::botnick auth <pseudo> <pass>"; return 0 }
   if { ![isvaliduser $mot1] } { puthelp "NOTICE $nick :$mot1 user inconnue !"; return 0 }
   if { [isvalidpassword $mot1 $mot2] } {
      if { [issuspend $mot1] } { puthelp "NOTICE $nick :Accés suspendu"; return 0 }
      if { [isauth $mot1] } { puthelp "NOTICE $nick :Vous êtes déjà  identifié !"; return 0 }
      puthelp "NOTICE $nick :Félicitation, vous êtes identifier"
      auth $mot1
   } else {
      puthelp "NOTICE $nick :Erreur, mot de passe incorrect."; return 0
   }
}

#######
# op  #
#######
 
bind msg - op msg:op
proc msg:op {nick host hand arg} {
   set mot1 [lindex $arg 0]
   set mot2 [lindex $arg 1]
   set mot3 [lindex $arg 2]
set sql(db) "access"
putlog "$mot1 $mot2 $mot3"
   if { $mot1 == "" || $mot2 == "" } { putquick "NOTICE $nick :Commande auth : /msg $::botnick auth <pass> <chan>"; return 0 }
	set ::mysqlink [mysqlconnect -host $::sql(host) -user $::sql(login) -password $::sql(pass) -sock $::sql(sock)]
	mysqluse $::mysqlink $::sql(db)
 if { ![isvaliduser $nick] } { return 0 }
   if { ![isvalidpassword $nick $mot1] } { putquick "NOTICE $nick :Erreur, mot de passe incorrect $mot1 $mot2"; return 0 }
      if { ![isvalidchan $nick $mot2] } { putquick "NOTICE $nick :Vous n'avez pas accès à $mot2"; return 0 }
      if { [issuspend $mot1] } { putquick "NOTICE $nick :Votre accés est suspendu !"; return 0 }
      putquick "mode $mot2 +o $nick"
}


j'ai testé et :

[20:13:22] <Tchatche-Bot> [20:13] select pseudo, pass from access where pseudo = 'Artefact' and pass = 'mayleen91'
[20:13:22] <Tchatche-Bot> [20:13] select pseudo, pass from access where pseudo = 'Artefact' and chan = '#aide'
[20:13:22] <Tchatche-Bot> [20:13] Punishing Tchatche-Land (deopped Artefact on #aide)
[20:13:22] <Tchatche-Bot> [20:13] Now deopping guest@ServAdmin.Tchatche-Land.fr (deopped Artefact on #aide)

Donc nickel!

Par contre, afin de mieux gerer les salons et accès, une personne saurait comment faut t-il procéder pour que la procédure de vérification fonctionne dans access/salon ?

car je souhaite plus tard faire les commandes adduser etc par salon et verif de nick ! (ou alors, dite moi que je me prend sans doute trop la tête à classer ca !)

Bien cordialement


RE: adduser et modification de donnée avec accès sql - fedora - 01/03/2010

pourquoi ne regarderais tu pas le système de windop.tcl vue qu'ont peut géré tout par mysql .