egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Proxy check

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Scarpa_SD
Voice


Joined: 25 May 2009
Posts: 3

PostPosted: Mon May 25, 2009 5:17 pm    Post subject: Proxy check Reply with quote

I was trying to edit this script http://jamesoff.net/site/wp-content/uploads/2008/02/proxychecktcl.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:
 # 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:
 # 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.
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Mon May 25, 2009 5:44 pm    Post subject: Reply with quote

Code:
if {$status} {

Substituted, evaluated... not interpreted. This works. Smile

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

Substituted, interpreted, evaluated. This doesn't... Sad

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)... Sad

Simply remove the [ ]'s around $status and it's dandy again...
Edit: bolded the above for added effect Wink
_________________
speechles' eggdrop tcl archive


Last edited by speechles on Mon May 25, 2009 6:34 pm; edited 1 time in total
Back to top
View user's profile Send private message
Scarpa_SD
Voice


Joined: 25 May 2009
Posts: 3

PostPosted: Mon May 25, 2009 5:59 pm    Post subject: Reply with quote

Yeah I can get it to work with
Code:
 if {$status} { 
But I'm trying to make it not execute anything if the host of the user is already in the banlist.
Code:
   if {($status) && (![matchban *@$orighost])} {
gives me this
Quote:
[15:08] Tcl error [proxycheck_check3]: invalid command name "
"

I tried
Code:
 if {([$status]) && (![matchban *@$orighost])} {  { 
Code:
 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:
 # 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]
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Mon May 25, 2009 6:28 pm    Post subject: Reply with quote

Quote:
I tried
Code:
 if {([$status]) && (![matchban *@$orighost])} {

Code:
 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:
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:
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:
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 Wink
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Scarpa_SD
Voice


Joined: 25 May 2009
Posts: 3

PostPosted: Mon May 25, 2009 7:49 pm    Post subject: Reply with quote

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. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber