ok i downloaded this script but i need it changed a bit.
first i need it in english right but also i need the commands to work as follows
!asladd nick age location gender <--- now this has to be such that only the user can add for him/her self and the location can be anyting expl space lol
!asldel nick <--- only masters can remove
here is the code
Code: Select all
###
#
# Script to make a database with asl info
#
# - !asladd <nick> <sex/location> <date of birth>
# - !asldel <nick>
# - !asl <nick>
#
###
## Settings ##
## file to store stuff in
set asl_storefile asl.dat
## tempfile
set asl_tempfile asl.tmp
## trigger
set asl_trig "!asl"
## trigger to add
set asl_addtrig "!asladd"
## trigger to delete
set asl_deltrig "!asldel"
## what flags are needed to add (for none: "-")
set asl_addflag "-"
## what flags are needed to delete (for none: "-")
set asl_delflag "o"
## what flags are needed to request asl info (for none: "-")
set asl_flag "-"
## Settings end HERE! ##
#################################################################
# create the data file if it doesn't exist
if {![file exist $asl_storefile]} {
set create [open $asl_storefile a+]
close $create
}
# load the data in memory
catch { unset asl_entries }
set asl_file [open $asl_storefile]
while {![eof $asl_file]} {
lappend asl_entries [string tolower [lindex [gets $asl_file] 0]]
}
close $asl_file
bind pub $asl_addflag $asl_addtrig asl_add
bind pub $asl_delflag $asl_deltrig asl_del
bind pub $asl_flag $asl_trig asl_search
# add info
proc asl_add {nick host handle chan arg} {
global asl_storefile asl_addtrig asl_entries
if {[lindex $arg 2] == ""} {
puthelp "notice $nick :USAGE: $asl_addtrig <nick> <sex/location> <date>"
} {
set entry [string tolower [lindex $arg 0]]
# create the data file if it doesn't exist
if {![file exist $asl_storefile]} {
set create [open $asl_storefile a+]
close $create
catch { unset asl_entries }
}
if {[lsearch -exact $asl_entries $entry] == -1} {
if {![isvaliddate [lindex $arg 2]]} {
puthelp "notice $nick :USAGE: $asl_addtrig <nick> <sex/location> <date>"
puthelp "notice $nick :[lindex $arg 2] is not a valid date"
return 0
}
if {![isvalidasl [lindex $arg 1]]} {
puthelp "notice $nick :USAGE: $asl_addtrig <nick> <sex/location> <date>"
puthelp "notice $nick :[lindex $arg 1] is not a valid <sex/location>"
return 0
}
lappend asl_entries $entry
set file [open $asl_storefile a+]
puts $file $arg
close $file
putserv "notice $nick :added info for [lindex $arg 0]"
} {
putserv "notice $nick :i already have info for [lindex $arg 0]"
}
}
}
# delete info
proc asl_del {nick host handle chan arg} {
global asl_storefile asl_tempfile asl_deltrig asl_entries
if {[lindex $arg 1] != "" || [lindex $arg 0] == ""} {
putserv "notice $nick :USAGE: $asl_deltrig <nick>"
} {
set entry [string tolower $arg]
# create the data file if it doesn't exist
if {![file exist $asl_storefile]} {
set create [open $asl_storefile a+]
close $create
catch { unset asl_entries }
putserv "notice $nick :no info found for $arg"
return 0
}
set idx [lsearch -exact $asl_entries $entry]
if {$idx != -1} {
set asl_entries [lreplace $asl_entries $idx $idx]
set file [open $asl_storefile]
set tempfile [open $asl_tempfile w]
while {![eof $file]} {
set temp [gets $file]
if {[string tolower [lindex $temp 0]] != $entry && $temp != ""} {
puts $tempfile $temp
}
}
close $file
close $tempfile
file delete $asl_storefile
file rename $asl_tempfile $asl_storefile
putserv "notice $nick :deleted info for $arg"
} {
putserv "notice $nick :no info found for $arg"
}
}
}
# search for info
proc asl_search {nick host handle chan arg} {
global asl_storefile asl_entries
# create the data file if it doesn't exist
if {![file exist $asl_storefile]} {
set create [open $asl_storefile a+]
close $create
catch { unset asl_entries }
return 0
}
set entry [string tolower [lindex $arg 0]]
if {$entry == ""} { return 0 }
if {[lsearch -exact $asl_entries $entry] != -1} {
set file [open $asl_storefile]
while {![eof $file]} {
set line [gets $file]
set matchnick [string tolower [lindex $line 0]]
if {$entry == $matchnick} {
set rnick [lindex $line 0]
set asl [lindex $line 1]
set date [lindex $line 2]
if {[isvalidasl $asl]} {
set location [lindex [split $asl "/"] 1]
set sex [lindex [split $asl "/"] 0]
if {$sex == "m" || $sex == "M"} {
set heshe "Hij"
} {
set heshe "Ze"
}
} {
puthelp "privmsg $chan :$nick, $rnick's info is corrupt :/"
close $file
return 0
}
if {[isvaliddate $date]} {
set splitted [split $date "/"]
set day [lindex $splitted 0]
set month [lindex $splitted 1]
set year [lindex $splitted 2]
if {[string index $month 0] == 0} {
set month [string index $month 1]
}
if {[string index $day 0] == 0} {
set day [string index $day 1]
}
set systemday [clock format [unixtime] -format %d]
set systemmonth [clock format [unixtime] -format %m]
set systemyear [clock format [unixtime] -format %Y]
set age [expr $systemyear - $year -1]
if {$month < $systemmonth} { incr age }
if {$month == $systemmonth} {
if {$day < $systemday} { incr age }
}
} {
puthelp "privmsg $chan :$nick, $rnick's info is corrupt :/"
close $file
return 0
}
puthelp "privmsg $chan :$nick, $rnick is $age jaar. $heshe woont in $location en is jarig op $day [humanmonth $month]"
close $file
return 0
}
}
close $file
}
puthelp "privmsg $chan :$nick, geen info over [lindex $arg 0]"
}
# checkt of een string een geldige 'sex/location' is
proc isvalidasl {string} {
set splittedasl [split $string "/"]
if {[llength $splittedasl] != 2} { return 0 }
set sex [lindex $splittedasl 0]
if {$sex != "m" && $sex != "v" && $sex != "f" &&
$sex != "M" && $sex != "V" && $sex != "F"} {
return 0
}
return 1
}
# checkt of een string een geldige datum voorstelt in dd/mm/yyyy
# (schrikkeljaren buiten beschouwen gelaten :p)
proc isvaliddate {string} {
set splitteddate [split $string "/"]
if {[llength $splitteddate] != 3} { return 0 }
foreach num $splitteddate {
if {![isnumber $num]} { return 0 }
}
set day [lindex $splitteddate 0]
set month [lindex $splitteddate 1]
set year [lindex $splitteddate 2]
if {[string length $year] != 4} { return 0 }
if {$day > 31 || $day == 0} { return 0 }
if {$month > 12 || $month == 0} { return 0 }
switch $month {
2 { if {$day > 29} { return 0 } }
4 -
6 -
9 -
11 { if {$day > 30} { return 0 } }
}
return 1
}
# zet getal 1-12 om naar de corresponderende maand
proc humanmonth {num} {
switch $num {
1 { return "januari" }
2 { return "februari" }
3 { return "maart" }
4 { return "april" }
5 { return "mei" }
6 { return "juni" }
7 { return "juli" }
8 { return "augustus" }
9 { return "september" }
10 { return "oktober" }
11 { return "november" }
12 { return "december" }
}
}
putlog "asl thingy v1.02 loaded.."
## EOF
Zainul