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.

Extra Characters on StrictHost Script [Help]

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
B
Branden
Halfop
Posts: 61
Joined: Sat Aug 04, 2007 8:36 pm

Extra Characters on StrictHost Script [Help]

Post by Branden »

The script below adds an extra character at the beginning of the ident!


Code: Select all

proc stricthost {host chan} { 

    set strict 0 
    if {[string index $host 0] == "!"} { 
        set host [string range $host 1 end] 
        set strict 1 
    } 
    if {![string match "*@*" $host]} { 
        set addhost "$host[getchanhost $host $chan]" 
        if {$strict == 0} { 
            set addhost [maskhost "*$addhost"] 
        } else { 
            if {[string index $addhost 0] == "~"} {set addhost "*[string range $addhost 1 end]"} 
            set addhost "*$addhost" 
        } 
        set host $addhost 
    } 
    return $host 
} 



proc Ban { nick host hand chan text } {
	set Who [lindex [split $text] 0]
	set Why [lrange $text 2 100]
	set thehost [stricthost $Who $chan] 

	putquick "MODE $chan +b $thehost"
	putquick "KICK $chan $Who $Why"
}



The REAL host is: *!*t0xs7s@*.east.verizon.net
And, what the bot is banning is: *!*st0xs7s@*.east.verizon.net[/code]
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

There are a few things in your code that makes little sense to me:

Code: Select all

            if {[string index $addhost 0] == "~"} {set addhost "*[string range $addhost 1 end]"}
            set addhost "*$addhost" 
Why have the conditional if you're only going to overwrite the addhost variable anyway.. I doubt this is the cause for the "odd behaviour".

Code: Select all

   set Why [lrange $text 2 100]
$text is not a list, so don't use list operations on it. Split it first like you did on the row before...

Code: Select all

        set addhost "$host[getchanhost $host $chan]"
Shouldn't this be "$host![getchanhost $host $chan]", or simply [getchanhost $host $chan]?
At the same time, neither way makes sense with the "strict" operation further on where you prefix this with a "*", essentially making the mask "*nickuser@host" or "*nick!user@host". Seems you want $addhost to hold nick!user@host if $strict is 0, and user@host otherwize.. I'd suggest you look into this part of the code, as it may very well be the culprit of your problems...
NML_375
B
Branden
Halfop
Posts: 61
Joined: Sat Aug 04, 2007 8:36 pm

Post by Branden »

To be honest, I didn't code this...

Could you please help me code it correctly?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Ahh, my bad. Thought I was checking "Scripting Help" rather than "Script Request" :oops:

Anyway, an attempt at rewriting the code in a somewhat proper way.. I have not made any major efforts to solve some ambiguity in the code, such as wether to kick when the target is a banmask rather than a nick, or whether to test if the nick is actually present in the channel.. I cannot guarantee this will produce exactly the same behaviour as the former code, but based on my understanding of the script, the edited version should behave somewhat similar with "logical" arguments.

Code: Select all

proc stricthost {target chan} {
 if {![string match "*@*" $target]} {
  set host "[getchanhost $target $chan]"

  if {[string index $target 0] == "!"} {
   return [maskhost "[string range $target 1 end]!$host"]
  }

  if {[string index $host 0] == "~"} {
   return "*!*[string range $host 1 end]"
  }

  return "*!*$host"
 }

 return $target
}

proc Ban { nick host hand chan text } {
 set t_list [split $text]
 pushmode $chan +b [stricthost [lindex $t_list 0]]
 putkick $chan [lindex $t_list 0]  [join [lrange $t_list 1 end]]
}
NML_375
B
Branden
Halfop
Posts: 61
Joined: Sat Aug 04, 2007 8:36 pm

Post by Branden »

Sorry for my delayed response, the script indeed does work.
But.
It is banning; *!*IDENT@Vhost

Example: *!*Branden@NetAdmin.CyberByteCafe.Co.CC

I want it to ban; *!*@*.rest.of.vhost

Example: *!*@*.CyberByteCafe.Co.CC
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

No worries, been out of town for a while myself...
What you ask for, pretty much mimics the behaviour of the maskhost function. Only added/kept the nick => hostmask feature..
Give it a try..

Code: Select all

proc stricthost {target chan} {
 if {![string match "*@*" $target]} {
  return [maskhost "[string trimleft $target "!"]![getchanhost $target $chan]"]
 }
 return [maskhost $target]
}

proc Ban { nick host hand chan text } {
 set t_list [split $text]
 pushmode $chan +b [stricthost [lindex $t_list 0]]
 putkick $chan [lindex $t_list 0]  [join [lrange $t_list 1 end]]
}
NML_375
Post Reply