Question

That i want to do is to separate reason and handle on some variables. Example: That's one row in my list.txt Where:

example row: *!*~*@217.21.146.130 someone Tachka, kakvo stava proshlqk? 0
someone = handle
*!*~*@217.21.146.130 someone Tachka, kakvo stava proshlqk? 0 = reason

May be somethig like:

[foreach line [split [readfile blacklist.txt] \n] {set reason [lrange $list 2 end-1]}]
Was it helpful?

Solution

Assuming that you want to put someone as the value for the handle variable, and that the reason variable should hold Tachka, kakvo stava proshlqk? 0

set fh [open blacklist.txt r]
while {[gets $fh line] != -1} {
    set reason [lassign [split $line] ip handle]
    puts "handle = $handle"
    puts "reason = [join $reason]"
}
close $fh

You have:

# Blacklist File:
set blackl(file) "scripts/blacklist.txt"

### CIDR
proc bl:cidr:ban {nick uhost hand chan} {
    global botnick exempt_userflag
    set fh [open blackl(file) r]

you need:

proc bl:cidr:ban {nick uhost hand chan} {
    global botnick exempt_userflag blackl
    set fh [open $blackl(file) r]

Given the updated requirement:

set line {*!*~*@217.21.146.130 someone Tachka, kakvo stava proshlqk? 0}
set rest [lassign [split $line] ip handle]
set reason [join [lrange $rest 0 end-1]]
set timeout [lindex $rest end]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top