I got back to my house and as I promised I will share the code.
Code: Select all
bind pub oa|n !fieladd add_fan
bind pub oa|n !djadd add_dj
bind pub a|n !adminadd add_admin
bind pub n|n !rootadd add_root
#bind msgm <flags> <mask> <proc>, The CHaN bot mask is *!-@-#
bind msgm - *!-@- fiel:registro
bind msgm - *!-@- dj:registro
bind msgm - *!-@- admin:registro
bind msgm - *!-@- root:registro
set canal_radio #channel1
set canal_djs #channel2
set canal_admin #channel3
proc add_fan {nick uhost hand chan text} {
global canal_radio canal_djs canal_admin
if {$text == ""} {putmsg $chan "You must enter the nick of the fan to add!";return }
set fan [join [lindex [split $text] 0]]
set faninv "$ndj[join !*@*]"
putserv "PRIVMSG chan :access $canal_radio add $fan 100"
if {![file exists regfiel]} {
set fs [open "regfiel" w+]
puts $fs 0
close $fs
set temp [open "regfiel" r]
set reg [gets $temp]
set nickreg [lindex $reg 0]
close $temp
} else {
if {[file exists regfiel]} {
set temp [open "regfiel" r]
set reg [gets $temp]
set nickreg [lindex $reg 0]
close $temp
}}
if {$nickreg == 1} { putmsg $chan "Can not add to staff a nick NO Signup!";return}
if {$nickreg == 0 } {
.................more stuff...........
proc add_dj {nick uhost hand chan text} {
.......
Similar lines to the above process
........
if {![file exists regdj]} {
set fs [open "regdj" w+]
puts $fs 0
close $fs
set temp [open "regdj" r]
set reg [gets $temp]
set nickreg [lindex $reg 0]
close $temp
} else {
if {[file exists regdj]} {
set temp [open "regdj" r]
set reg [gets $temp]
set nickreg [lindex $reg 0]
close $temp
}}
if {$nickreg == 1} { putmsg $chan "Can not add to staff a nick NO Signup!";return}
if {$nickreg == 0 } {
.................more stuff...........
proc add_admin {nick uhost hand chan text} {
.......
Similar lines to the above process
........
if {![file exists regadm]} {
set fs [open "regadm" w+]
puts $fs 0
close $fs
set temp [open "regadm" r]
set reg [gets $temp]
set nickreg [lindex $reg 0]
close $temp
} else {
if {[file exists regadm]} {
set temp [open "regadm" r]
set reg [gets $temp]
set nickreg [lindex $reg 0]
close $temp
}}
if {$nickreg == 1} { putmsg $chan "Can not add to staff a nick NO Signup!";return}
if {$nickreg == 0 } {
.................more stuff...........
proc add_root {nick uhost hand chan text} {
.......
Similar lines to the above process
........
if {![file exists regroot]} {
set fs [open "regroot" w+]
puts $fs 0
close $fs
set temp [open "regroot" r]
set reg [gets $temp]
set nickreg [lindex $reg 0]
close $temp
} else {
if {[file exists regroot]} {
set temp [open "regroot" r]
set reg [gets $temp]
set nickreg [lindex $reg 0]
close $temp
}}
if {$nickreg == 1} { putmsg $chan "Can not add to staff a nick NO Signup!";return}
if {$nickreg == 0 } {
.................more stuff...........
#procname <nick> <user@host> <handle> <text> The user@host of bot CHaN is CHaN!-@- #
proc fiel:registro {nick CHaN!-@- hand text} {
if {[string match -nocase "*only contain registered nicknames*" $text]} {
set fs [open "regfiel" w+]
puts $fs 1
close $fs
return
} else {
set fs [open "regfiel" w+]
puts $fs 0
close $fs
}}
proc dj:registro {nick uhost hand text} {
if {[string match -nocase "*only contain registered nicknames*" $text]} {
set fs [open "regdj" w+]
puts $fs 1
close $fs
return
} else {
set fs [open "regdj" w+]
puts $fs 0
close $fs
}}
proc admin:registro {nick uhost hand text} {
if {[string match -nocase "*only contain registered nicknames*" $text]} {
set fs [open "regadm" w+]
puts $fs 1
close $fs
return
} else {
set fs [open "regadm" w+]
puts $fs 0
close $fs
}}
proc root:registro {nick uhost hand text} {
if {[string match -nocase "*only contain registered nicknames*" $text]} {
set fs [open "regroot" w+]
puts $fs 1
close $fs
return
} else {
set fs [open "regroot" w+]
puts $fs 0
close $fs
}}
The problems that have arisen me are obvious:
Adding a fan, dj, admin or root, the 4
bind msgm events simultaneously triggers , because the 4 events used the same mask (*!-@-).
That makes who 4 files (
regfiel, regdj, regadm and regroot) change their values, when wish who only one of them, change the value.
The code works fine, if only one of bot operators, adds a certain staff. i.e !addfan or !addj etc...
But, if simultaneously, several operators adds staff at the same time, a conflict is generated.
Is there any way that
bind msgm events triggers individual for each level of staff adding?
Example:
While the operator
A adds a DJ, only trigger event
bind msgm - *!-@- dj:registro .
While the operator
B adds simutaneamente
A a ADMIN, only trigger event
bind msgm - *!-@- admin:registro .
Reason Edit: add an example.