| View previous topic :: View next topic |
| Author |
Message |
garfwen Halfop
Joined: 12 Mar 2008 Posts: 61
|
Posted: Thu Dec 18, 2008 5:24 pm Post subject: Add lines, and check them on a txt file |
|
|
Hello
Im looking for a script that can make this:
| Code: |
<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 ! |
Ty,
GaRfWeN  |
|
| Back to top |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
Posted: Sat Dec 20, 2008 6:34 pm Post subject: |
|
|
| Code: | # 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"
|
try :> |
|
| Back to top |
|
 |
garfwen Halfop
Joined: 12 Mar 2008 Posts: 61
|
Posted: Sun Dec 21, 2008 8:55 am Post subject: |
|
|
Ty
5*
 |
|
| Back to top |
|
 |
garfwen Halfop
Joined: 12 Mar 2008 Posts: 61
|
Posted: Tue Dec 23, 2008 7:48 am Post subject: |
|
|
Hello
Can you please add one thing to the script ?
It's to remove a line
When
| Code: |
<user> goobye
remove user from list
<botnick> goodbye $nick
|
Ty  |
|
| Back to top |
|
 |
|