<nick> hello
check if "$nick is on the file" if not
<botnick> hello
add line "hello $nick"
<nick> hello
check if "$nick is on the file" if it is
<botnick> Hello again $nick !
# Author: tomekk
# e-mail: tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.htm
# file with names
set hello_file "hello.txt"
##################################################
if {![file exist $hello_file]} {
set create_new [open $hello_file w]
close $create_new
}
bind pub - hello hello_proc
proc check_nick { name } {
global hello_file
set return_msg "not_exist"
set db_handler [open $hello_file r]
set all_names [read $db_handler]
close $db_handler
if {$all_names != ""} {
if {[lsearch [split $all_names "\n"] $name] != -1} {
set return_msg "exist"
}
}
return $return_msg
}
proc add_name { name } {
global hello_file
set append_hand [open $hello_file a]
puts $append_hand $name
close $append_hand
}
proc hello_proc { nick uhost hand chan arg } {
set name_status [check_nick $nick]
if {$name_status == "exist"} {
putquick "PRIVMSG $chan :hello again $nick"
} {
putquick "PRIVMSG $chan :hello"
add_name $nick
}
}
putlog "simple-hello.tcl ver 0.1 by tomekk loaded"