mIRC Home    About    Download    Register    News    Help

Print Thread
#214598 09/08/09 09:07 AM
Joined: Feb 2009
Posts: 8
A
ahbb Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2009
Posts: 8
HI There,

Iv made a script that whois every person before they enter and if they are in the "bad channels" then they get kicked out of the channel as the Teen channel has a age restriction on.

Now in the script if added nicks that must not be kicked if they are in that channels, but it does not work, it still keep kicking the ppl out.

Could i please get some help on the script and tell me where i went wrong.

Quote:
on *:join:#TeenZone: {
if ($nick != $me) {
.raw whois $nick
set %cc.whois $nick
}
}
raw 319:*: {
var %chan = #TeenZone
if (%cc.whois) {
if (#vanman isin $3-) &&& (%cc.whois != statsbot) (%cc.whois != SilentAngel) {
mode %chan +bb %cc.whois $address(%cc.whois, 2)
kick %chan %cc.whois You are to old to be in this channel
}
}
halt
}

raw *:*:halt


Thanks

Andrew

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031

So if the joining user is on channel #vanman, they are NOT to be kicked? If so, then...

you should change this
if (#vanman isin $3-) &&& (%cc.whois != statsbot) (%cc.whois != SilentAngel) {

to this
if ((#vanman !isin $3-) && (%cc.whois != statsbot) && (%cc.whois != SilentAngel)) {

Joined: Feb 2009
Posts: 8
A
ahbb Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2009
Posts: 8
Hi,

No if the user are in #vanman and they join #teenzone the bot must kick and ban then, iv just tired that what you said and that kick everyone that is joining now.

Sorry if i was not clear in my first paragraph.

Then something els can i add more then one channel that can be blacklisted?

Thanks again.

Andrew

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
You could modify the raw 319 of this post.
- replace channelname #q with #teenzone
- add a condition to exclude certain allowed nicknames
- have it issue the "mode # +bb" instead of a "ban -k #"

Note that both your script and the script in this post have no check for being OP at all, and have no flood protection (you might flood yourself off the server by whoissing all the users in case of e.g. a bot attack or the mass-rejoin after a netsplit).
Also note that using a variable like %cc.whois to track a nick is not reliable: Another user may join while the whois reply for a previous nick hadn't been received yet, and thereby become the value of the variable. If now the whois reply for that "previous" user arrives, you might ban the innocent "new" user in his place. Use $2 instead - it's the nickname for the actual reply.

Joined: Feb 2009
Posts: 8
A
ahbb Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2009
Posts: 8
HI,

Thanks but let me just make sure i understand this code right that i went to have a look @ that you said i must.

I see where i can put the blacklisted channels in. But where can put users nicks in that must not be kick. Becuase it's a teen channel and only Under 21 can join there. But the ppl that are in charge in channel are older and in some of that blacklisted channels, so i dont want the bot 2 kick those ppl.?

Thanks so much for the help.

Quote:

raw 319:*: {
if ($2 ison #q) {

; put blacklisted channel names here, separated by space, WITHOUT the chantype prefix
var %ban = a b c 2m-clan

; this part sets a variable which has the status prefix (e.g. @) and the chantype-char (e.g. #) removed from $3-
var %regex = $+(/,(?<=^|\40),$chr(40),[,$prefix,]?,[,$chantypes,],$chr(41),(?=\S+),/g)
var %cleaned = $regsubex($3-,%regex,$null)

; loop the words of %cleaned...
var %n = 1
while ($gettok(%cleaned,%n,32)) {
; ...and check if the current word is a blacklisted channel of "%ban"
; if it is: kickban the user out of #q, stop the loop
if ($istok(%ban,$v1,32)) {
ban -k #q $2 You're on a banned channel
return
}
; if not: continue with next word
inc %n
}
}
}

Joined: Nov 2003
Posts: 102
T
Vogon poet
Offline
Vogon poet
T
Joined: Nov 2003
Posts: 102
Hey...I just wanted to put it out there that you can use the script "P&Plus" to do this job. It has a really nice script like you are asking about built in. You can set it up to have different reactions depending on how many times the rule is broke. You can ban a channel say its called "#sex" When a user joins "#teens" while at the same time they are in the channel #sex they will be either sent a msg,notice,kicked or banned. Can also set it up to warn the @'s that the person was warned,banned or kicked or whatever . Also is able to say warn the first time. Kick the second , ban the 3rd time and perm ban the last time. Its a very very useful script and its made for exactly what you are asking about. I use it that way every day.


Rock and Metal Music videos ON DEMAND!
<<<<<< http://www.tormented.tv >>>>>>
Joined: Nov 2003
Posts: 102
T
Vogon poet
Offline
Vogon poet
T
Joined: Nov 2003
Posts: 102
lol However i must say that a stand alone version of the same script they use in P&Plus would be very vaulable to alot of people.... wink


Rock and Metal Music videos ON DEMAND!
<<<<<< http://www.tormented.tv >>>>>>
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
A basic adaption:
Code:
; ----- your channel -----
alias -l teenchan { RETURN #TeenZone }

; ----- blacklisted channel names, separated by space, WITHOUT the chantype prefix -----
alias -l bannedchans { RETURN oldboys mature whathaveyou } 

; ----- allowed nicknames, separated by space -----
alias -l allowednicks { RETURN statsbot silentangel }

; someone (not you) joins the channel and you're @
on @!*:join:$($teenchan): {
  ; nick is not allowed anyway
  if (!$istok($allowednicks,$nick,32)) {
    ; basic flood-prevention (no more than 5 whois in 20 seconds):
    ; hash-table has less than 5 items atm
    if ($hget(teencheck,0).item < 5) {
      ; add a random item for 20s to the flood-prevention hash-table 
      hadd -mu20 teencheck $rand(1,999999)
      ; whois the nick
      !whois $nick
    }
  }
}

raw *:*: {
  ; raw reply is in the range 301-402 (this won't halt the display of ALL raw replies but of raws in the whois-reply-range)
  ; (you still won't see e.g. the default reply for a manual /whois or /names)
  if ($numeric isnum 301-402) {
    if ($numeric == 319) && ($2 ison $teenchan) && ($me isop $v2) && ($2 != $me) {
      var %regex = $+(/,(?<=^|\40),$chr(40),[,$prefix,]?,[,$chantypes,],$chr(41),(?=\S+),/g)
      var %cleaned = $regsubex($3-,%regex,$null), %n = 1
      while ($gettok(%cleaned,%n,32)) {
        if ($istok($bannedchans,$v1,32)) {

          ; ----- ban the user -----
          mode $teenchan +bb $2 $address($2,2)

          ; ----- kick the user -----
          kick $teenchan $2 This channel is for teens only

          return
        }
        inc %n
      }
    }
    haltdef
  }
}

Edit: forgot to add "allowed nicks"

Joined: Feb 2009
Posts: 8
A
ahbb Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2009
Posts: 8
Thank you to all, horst the script are working 100%

Andrew


Link Copied to Clipboard