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.

exemp script

Help for those learning Tcl or writing their own scripts.
Post Reply
A
AlbozZz
Voice
Posts: 3
Joined: Sun Jan 26, 2020 5:59 pm

exemp script

Post by AlbozZz »

Now the script is work great, but need to change the commands and remove channel name, when i add IP in exemp.txt file list,

someone can help here, how to change this public comand , thx in advance

!exemp help change in !help

!exemp list change in !list

!exemp del 1 change in !del 75.34.37.12 | 75.34.37.* | 75.34.*

!exemp add change in !add 75.34.37.12 | 75.34.37.* | 75.34.*

and to remove the name channel when i add Ip on exemp.txt list
to add only the IP

Code: Select all


proc check_ip {ip} {
	set file [open "exemp.txt" r]
	set fdata [split [read $file] \n]
	close $file
	foreach entry $fdata {
		if {[string match $entry $ip]} {
			return 1
		}
	}
	return 0
}

bind pub n|n !exemp  exemp:cmd

set exemp(file) "exemp.txt"

if {![file exists $exemp(file)]} {
	set file [open $exemp(file) w]
	close $file
}

proc exemp:cmd {nick host hand chan arg} {
	global exemp
	
	set arg0 [lindex [split $arg] 0]
	set arg1 [lindex [split $arg] 1]
if {$arg0 == ""} {
	putserv "NOTICE $nick :EXEMP Use: \002!exemp help\002 for more informations."
	return
}
switch $arg0 {
	add {
if {$arg1 == ""} {
	putserv "NOTICE $nick :EXEMP Use: \002!exemp help\002 for more informations."
	return
}
	set file [open $exemp(file) a]
	puts $file "$chan $arg1"
	close $file
	putserv "NOTICE $nick :EXEMP I added\002 $arg1 \002in my ExempList."
	}

	list {
	set file [open $exemp(file) "r"]
	set read [read -nonewline $file]
	close $file
	set data [split $read "\n"]
	set i 0
if {$data == ""} { 
	putserv "NOTICE $nick :EXEMP There are\002 no IP \002added to ExempList."
	return
}
	putserv "NOTICE $nick :EXEMP The list of IP added in my ExempList."
foreach line $data {
	set read_chan [lindex [split $line] 0]
if {[string match -nocase $read_chan $chan]} {
	set i [expr $i +1]
	set read_blackchan [lindex [split $line] 1]
	putserv "NOTICE $nick :$i.) $read_blackchan"
			}
		}
	}

	
	del {
	array set exempdel [list]
if {![regexp {.*?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).*?\((.*?)\)} $arg1]} {
	putserv "NOTICE $nick :EXEMP Use: \002!exemp help\002 for more informations."
	return
}


set file [open $exemp(file) "r"]
	set data [read -nonewline $file]
	close $file
	set lines [split $data "\n"]
	set counter -1
	set line_counter -1
	set current_place -1
foreach line $lines {
	set line_counter [expr $line_counter + 1]
	set read_chan [lindex [split $line] 0]
if {[string match -nocase $read_chan $chan]} {
	set counter [expr $counter + 1]
	set exempdel($counter) $line_counter
	}
}

foreach place [array names exempdel] {
	if {$place == [expr $arg1 - 1]} {
	set current_place $exempdel($place)
	}
}

if {$current_place == "-1"} {
	putserv "NOTICE $nick :EXEMP The entry number\002 $arg1 \002does not exist."	
	return	
}

	set delete [lreplace $lines $current_place $current_place]
	set files [open $exemp(file) "w"]
	puts $files [join $delete "\n"]
	close $files
	set file [open $exemp(file) "r"]
	set data [read -nonewline $file]
	close $file
if {$data == ""} {
	set files [open $exemp(file) "w"]
	close $files
}
	putserv "NOTICE $nick :EXEMP The entry number\002 $arg1 \002was removed from ExempList."

	}

	help {
	putserv "NOTICE $nick :EXEMP You can add IP using: \002!exemp add <IP>\002 "
	putserv "NOTICE $nick :EXEMP To see all the IP in ExempList use:\002 !exemp list\002"
	putserv "NOTICE $nick :EXEMP To delete a IP use:\002 !exemp del <number>\002 (from the ExempList)"
		}
	}
}
this is how works the script for now.

Code: Select all


<+BoB> !exemp add 75.34.37.12
 -TestBot- EXEMP I added 75.34.37.12 in my ExempList.

 <+BoB> !exemp list
 -TestBot- EXEMP The list of IP added in my ExempList.
 -TestBot- 1.) 75.34.37.12

<BoB> !exemp del 1
 -TestBot- EXEMP The entry number 1 was removed from ExempList.

<BoB> !exemp list
-TestBot- EXEMP There are no  IP added to ExempList.

<+BoB> !exemp del 75.34.37.12
 -TestBot- EXEMP Use: !exemp help for more informations.

 <+BoB> !exemp help
 -TestBot- EXEMP You can add IP using: !exemp add <IP>
 -TestBot- EXEMP To see all the IP in ExempList use: !exemp list
 -TestBot- EXEMP To delete a IP use: !exemp del <number> (from the ExempList)

This is the way how is adding now the ip on exemp.txt wrong :
need to remove the channel and to be only on #opers chan to use the all commands !list !help !add !del

Code: Select all


#Test 75.34.37.12

the right way to add every IP in exemp.txt without name channel only the IP like this:

Code: Select all


75.34.37.12 
75.34.37.* 
75.34.*

Post Reply