mIRC Home    About    Download    Register    News    Help

Print Thread
#133066 17/10/05 02:18 AM
Joined: Oct 2005
Posts: 1
N
Mostly harmless
OP Offline
Mostly harmless
N
Joined: Oct 2005
Posts: 1
I'm looking to create a script that will ban people who mention any sort of channel (i.e ban for *#*) but that's not my problem. The problem is that I don't know how to check if the user has access to the channel not.

In summary what I want: I want to ban anyone who advertises a channel in my channel but I do not want to ban someone if they have any sort of access to the channel.

Question: How do I check to see if $nick has access to the channel or not?

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Do you mean an access level to your channel, or an access level to the channel that they're spamming/advertising?

Joined: Jul 2003
Posts: 655
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2003
Posts: 655
If i understood correctly, use this simple if (/help if-then-else), it will cause any code within the {}'s to only be evaluated/processed if $nick is a regular user on $chan. A regular user is any user on the channel that has not channel status flags such as op/voice/halfop/admin/founder/etc (+%@!&~.).

if ($nick isreg $chan) {
; ban code here
}


"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
on ^*:TEXT:*:#: {
if ($nick isreg $chan) { halt }
elseif ($chr35 isin $1-) {
mode # +b $address($nick,3)
kick # $nick No Advertising in #
}
}


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
LOL..that would mean that voiced, half-ops, and ops wouldn't be able to advertise, but anyone else could. I would think that they'd want it the other way around.

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
Quote:

isop nickname v1 is an op on channel v2
ishop nickname v1 is a halfop on channel v2
isvoice nickname v1 has a voice on channel v2
isreg nickname v1 is a normal nick on channel v2

To negate an operator you can prefix it with an ! exclamation mark.



on @*:TEXT:*:#: {
if ($nick !isreg $chan) { halt }
elseif ($chr35 isin $1-) {
mode # +b $address($nick,3)
kick # $nick No Advertising in #
}
}

try it like that, test it in a channel

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok, some problems with both scripts...

Code:
on @*:TEXT:*:#: {
  if ($nick !isreg $chan) { [color:red]return[/color] }
  if ($chr[color:red]([/color]35[color:red]) $+ * iswm[/color] $1-) {
    mode $chan +b $address($nick,3)
    kick $chan $nick No Advertising in $chan
  }
} 


Ok, some explanations...
* Return is a better way to leave a script than using halt.
* You forgot ()'s around the $chr number.
* This#is isn't a channel name and should get banned... using #* instead of *#* is more appropriate... hence the iswm part.
* Note that you could also use "ban -k" rather than two separate lines for banning/kicking people.
* You may also want to set it to only kick when the length of the #* is greater than 3. Why? If someone types #1, you don't want to ban them. So, checking length greater than 3 would allow #1 to #99 to be typed without a problem. And, most channel names are longer than 2 letters.

If you want to do the last part:

Code:
on @*:TEXT:*:#: {
  if ($nick !isreg $chan) { return }
  if ($wildtok($1-,$chr(35) $+ *,0,32) > 0) {
    var %c = 1
    var %i = $wildtok($1-,$chr(35) $+ *,0,32)
    while (%c <= %i) {
      if ($len($wildtok($1-,$chr(35) $+ *,%c,32)) > 3) {
        ban -k $chan $nick 3 No Advertising in $chan
        return
      }
      inc %c
    }
  }
} 


The loop will have it check all occurences of #* in the text for length (up until it reaches one that has greater than 3 length).

Just a note on the /ban -k ... I can't test it right now and I'm not entirely sure if the 3 will still be counted as the ban mask type, or if it will be counted as the kick reason. It may be necessary to replace $nick with $address($nick,3) and remove the 3 after the $nick. If it works without doing that, then this is a better way by using /ban's internal mask option.

Last edited by Riamus2; 17/10/05 02:08 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
If you mean with access that the user has op/voice or any other channel mode:

on $*:TEXT:m/#\d?\d?[^ ,]+/:# :if ($nick isreg $chan) ban -ku3600 $nick 3 No advertising!


If you mean channel access as a level in a nickserv database, it's more difficult. If the channel list is only updated occasionally, it's maybe best to add those in the list to your user list and check that level, or put them in an ini file or hash table. Maybe nickserv has a sort of hasaccesslevel message you can send it, but that is way more difficult to script, and the best way to get you flooded off the server...

Joined: Dec 2003
Posts: 10
A
Pikka bird
Offline
Pikka bird
A
Joined: Dec 2003
Posts: 10
Quote:
Just a note on the /ban -k ... I can't test it right now and I'm not entirely sure if the 3 will still be counted as the ban mask type, or if it will be counted as the kick reason. It may be necessary to replace $nick with $address($nick,3) and remove the 3 after the $nick. If it works without doing that, then this is a better way by using /ban's internal mask option.


The 3 should work correctly wink . (and if for some silly reason it doesn't you could always use $address like you said or just override /ban with a version where it WILL work)


Link Copied to Clipboard