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.

Proxy check

Help for those learning Tcl or writing their own scripts.
Post Reply
S
Scarpa_SD
Voice
Posts: 3
Joined: Mon May 25, 2009 4:33 pm

Proxy check

Post by Scarpa_SD »

I was trying to edit this script http://jamesoff.net/site/wp-content/upl ... ecktcl.bz2 to do global bans instead of channel specific ones because a few drones were going into multiple channels and would get 1 line of spam in before the checks went through. I changed the original code that looked like this

Code: Select all

 # second callback (catches RBL results)
proc proxycheck_check3 { ip host status nick orighost channel rbl } {
  global proxycheck_bantime

  if {$status} {
    putlog "proxycheck: got host $host = ip $ip from RBL $rbl ... banning"
    newchanban $channel "*@$orighost" "proxychk" "proxycheck: $rbl" $proxycheck_bantime
  }
  #if we didn't get a host, they're not in RBL 
into this

Code: Select all

 # second callback (catches RBL results)
proc proxycheck_check3 { ip host status nick orighost channel rbl } {
  global proxycheck_bantime

  if {([$status]) && (![matchban *@$orighost])} {
    putcmdlog "proxycheck: got host $host = ip $ip from RBL $rbl ... banning"
         newban "*@$orighost" "proxychk" "proxycheck: $channel $rbl" $proxycheck_bantime
         puthelp "PRIVMSG $nick :This is an automated response. You've been banned for $proxycheck_bantime from $channel because your host $host is listed at $rbl"
         puthelp "PRIVMSG $nick :You will need to fix whatever caused you to be listed and get removed from $rbl before you're able to rejoin $channel ."
         puthelp "PRIVMSG #opschan :$nick was banned from $channel for being listed in $rbl."
        }
It worked before I tried to cut down the flood it sent by having it only message the ops channel and the user once instead of every time they tried to join a channel my bot has ops in. Now I get this error from the bot [14:17] Tcl error [proxycheck_check3]: invalid command name "0"
If you guys have any ideas on how to fix this I'd be very appreciative.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

if {$status} { 
Substituted, evaluated... not interpreted. This works. :)

Code: Select all

if {([$status]) && (![matchban *@$orighost])} { 
Substituted, interpreted, evaluated. This doesn't... :(

Why? For some reason you put [brackets] around $status as well as the command matchban. This will cause the interpreter to treat their contents as commands. This is fine for matchban, it is a command. But this will happen after substitution of $status with it's value (which in your case, is obviously 0). This is what generates your error (it's trying to invoke the command "0", which of course doesn't exist)... :(

Simply remove the [ ]'s around $status and it's dandy again...
Edit: bolded the above for added effect ;)
Last edited by speechles on Mon May 25, 2009 6:34 pm, edited 1 time in total.
S
Scarpa_SD
Voice
Posts: 3
Joined: Mon May 25, 2009 4:33 pm

Post by Scarpa_SD »

Yeah I can get it to work with

Code: Select all

 if {$status} {  
But I'm trying to make it not execute anything if the host of the user is already in the banlist.

Code: Select all

   if {($status) && (![matchban *@$orighost])} { 
gives me this
[15:08] Tcl error [proxycheck_check3]: invalid command name "
"
I tried

Code: Select all

 if {([$status]) && (![matchban *@$orighost])} {  {  

Code: Select all

 if {[$status] && (![matchban *@$orighost])} {  { 
ect and every other possibility I could think of.
Can I have a if then statement in an if statement like this?

Code: Select all

 # second callback (catches RBL results)
proc proxycheck_check3 { ip host status nick orighost channel rbl } {
  global proxycheck_bantime
if {isban *@$orighost} {} 
     {
           if {$status} {
           putlog "proxycheck: got host $host = ip $ip from RBL $rbl ... banning"
      newchanban $channel "*@$orighost" "proxychk" "proxycheck: $rbl" $proxycheck_bantime
     }
  }
  #if we didn't get a host, they're not in RBL
}[/quote]
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

I tried

Code: Select all

 if {([$status]) && (![matchban *@$orighost])} { 

Code: Select all

 if {[$status] && (![matchban *@$orighost])} { 
......simply read what I've said, and slow down... We will go 1 step at a time, go back to your original version....


Now....


....Simply remove the [ ]'s around $status and it's dandy again...


Should get you somewhere near here:

Code: Select all

if {($status) && (![matchban *@$orighost])} {
Remember...Only when you are using the contents as a command do you ever want to use [bracket's]. I stated this in my post above if you read the end of the post.

Also worth nothing, the use of return would eliminate that nasty nest of if's your seem to be constructing. You simply return a value from the procedure and bail out.

Code: Select all

if {isban *@$orighost} {} 
You made a mistake here, remember to put [bracket's] around commands. isban i'm guessing is a procedure/command. What I also assume is this evaluation is meant as a trap if it matches. Instead, why not simply:

Code: Select all

if {[isban *@$orighost]} { return 0 } 
Bail out, and return a condition of negative? This should help you on you way to fixing you script now ;)
S
Scarpa_SD
Voice
Posts: 3
Joined: Mon May 25, 2009 4:33 pm

Post by Scarpa_SD »

Well that worked. Thanks so much speechles. I guess after I posted I started tinkering around with the script more instead of waiting for a response and messed something else up so when I did what you said it resulted in another error. After going back and reverting it to my original changes I removed the [] brackets from $status and it worked right. Plus now I know brackets only go around commands and not values. :D
Post Reply