This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Add lines, and check them on a txt file

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
g
garfwen
Halfop
Posts: 61
Joined: Wed Mar 12, 2008 5:16 pm

Add lines, and check them on a txt file

Post by garfwen »

Hello

Im looking for a script that can make this:

Code: Select all

<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 :P
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

Code: Select all

# 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 :>
g
garfwen
Halfop
Posts: 61
Joined: Wed Mar 12, 2008 5:16 pm

Post by garfwen »

Ty

5*

:P
g
garfwen
Halfop
Posts: 61
Joined: Wed Mar 12, 2008 5:16 pm

Post by garfwen »

Hello

Can you please add one thing to the script ?

It's to remove a line


When

Code: Select all

<user> goobye

remove user from list

<botnick> goodbye $nick
Ty :D
Post Reply