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.

bot kick to ops

Old posts that have not been replied to for several years.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I know what they mean... but rationalizing them:

with || it means for example if $nick isn't voiced or oped then the proc will apply to him, but with &&, $nick must be NOT oped and NOT voiced, which means if he is oped but isnt voice or vise versa he won't be exempted.
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

Code: Select all

set spambantime 60
set spamwords {
  "\#"
  "join"
  "channel"
}
bind msgm - * pv_kick 
proc pv_kick {nick uhost hand text} { 
  global botnick spamwords spambantime
  foreach sw $spamwords {
    if {[string match -nocase "*$sw*" "$text"]} {
      foreach kickchan [channels] { 
        set kickchan [string tolower $kickchan] 
        if {[onchan $nick $kickchan]} {    
          if {(![isop $nick $kickchan]) && (![isvoice $nick $kickchan])} { 
            set bmask "*!*[string range $uhost [string first "@" $uhost] end]" 
            if {(![ischanban $bmask $kickchan]) && ([botisop $kickchan])} { 
              set kickmsg "\00312\002\037Cause\037:\002 Mass-Msg/Invite/Adv/Trojan Send\00312"  
              putquick "KICK $kickchan $nick :$kickmsg" 
              newchanban $kickchan $bmask $botnick Mass-Msg $spambantime
            }
          } else {
            return 0
          }
        } 
      }
      return 0
    } 
  } 
} 

I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Dedan wrote:

Code: Select all

set spambantime 60
set spamwords {
  "\#"
[snip]
I guess there's no need for the "" behind #
User avatar
BarkerJr
Op
Posts: 104
Joined: Sun Mar 30, 2003 1:25 am
Contact:

Post by BarkerJr »

No, but just to be safe, you could make in {#}. I always use {}'s around strings that I don't want Tcl to parse.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Sir_Fz wrote:I know what they mean... but rationalizing them:

with || it means for example if $nick isn't voiced or oped then the proc will apply to him, but with &&, $nick must be NOT oped and NOT voiced, which means if he is oped but isnt voice or vise versa he won't be exempted.
Sir_Fz.... with || the scenario will always be true.... This is because the person will never be BOTH opped and voiced....

Code: Select all

if {![isop $nick $kickchan] || ![isvoice $nick $kickchan]} { 
In other terms... If Sir_Fz is not opped in #egghelp, or not voiced in #egghelp, then let's do the following code... See?

Analysis of ||:
First Scenario) If you are opped, you don't have to be voiced, which will make the code following the statement get triggered...
Second Scenario) If you are voiced, you don't have to be opped, which will make the code following the statement get triggered as well...
Third Scenario) If you don't have either voice or op status, the code following the statement will get triggered as well...

See? it is the same as having if {1} { ... this stuff will always get called ... }

That is why && is needed...

Code: Select all

if {![isop $nick $kickchan] && ![isvoice $nick $kickchan]} { 
In other terms, if Sir_Fz is not opped in #egghelp, and not voiced in #egghelp, then let's do the following code...

Analysis of &&:
First scenario) If you are opped, you don't satisfy the first (not opped) condition, so already the code following the statement must be skipped [which is what we want to happen, remember?]
Second scenario) If you are voiced, you satisfy the first (not opped) condition, but you don't satisfy the second (not voiced) condition, so the code following the statement must again be skipped [again, which is what we want to happen]
Third scenario) If you are neither opped or voiced, then you satisfy both conditions, thus the code following the statement will be executed...[which is truly what we want, as we only want the bot to react on these
typ of channel members, leaving ops and voiced users alone]

I don't know how else to explain it to you Sir_Fz... if you don't get this explanation, then I'm afraid you will never understand :(
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

okay :) that was a good explanation, sorry for being so stuborn :p, I have a math test (irrational functions) tommorow, so I've got my mind mixed up with all the problems solving :P

thank you :)
Locked