mIRC Home    About    Download    Register    News    Help

Print Thread
channel blacklist #172629 13/03/07 06:12 AM
Joined: Jan 2005
Posts: 25
L
LordoftheX Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2005
Posts: 25
ok, I'm trying to gin up a channel blacklist, one that would check the channels a user is in on join against a list, unfortunately I am running into a snag

here's what I got:

Code:
on *:join:#channel: {
  whois $nick
}
raw 319:*: {
  //set %blacklist.check $1-
  //set %blacklist.num $read(blacklist.txt,0)
  set %b 1
  while (%b <= %blacklist.num) {
    //set %blacklist $read(blacklist.txt,%b)
    if (%blacklist iscs %blacklist.check) {
      ban -u300 #channel $2 2
      kick #channel $2 You are in a blacklisted channel.  Please part %blacklist before rejoining. [5 Minute Ban]
      unset %b
      break
    }
    else {
      inc %b 1
    }
  }
}


Now, I took it apart piece by piece and figure the problem starts here:
Code:
    //set %blacklist $read(blacklist.txt,%b)


It will either set it to the first channel in the list and stay there, or simply not set.

Ideas?

Re: channel blacklist [Re: LordoftheX] #172631 13/03/07 08:27 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Change
Code:
//set %blacklist.num $read(blacklist.txt,0)
to
Code:
//set %blacklist.num $lines(blacklist.txt)


also you're using iscs which should be isin

For channel name, case is irrelevant, but your comparison is using the wrong format anyways.


Re: channel blacklist [Re: LordoftheX] #172633 13/03/07 10:13 AM
Joined: Mar 2007
Posts: 12
S
Sintel Offline
Pikka bird
Offline
Pikka bird
S
Joined: Mar 2007
Posts: 12
I'm not really all that sure it's useful what you are doing. You only check on join, and you tell them exactly why they got banned. The only thing they have to do is leave that other channel after 5 minutes, join yours, and then join the blacklisted channel again. If you don't want ppl inside your channel that frequent another, just banning them without too much info is better (like not saying for how long and what particular channel).

However, if it is just to try and keep out bots you know are in a particular channel, and that don't understand kick messages, then I shut up smile Which I'm sure this is actually for, so maybe this post is what was useless smirk

Re: channel blacklist [Re: RusselB] #172635 13/03/07 11:44 AM
Joined: Jan 2005
Posts: 25
L
LordoftheX Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2005
Posts: 25
made those changes and noticed something, when comparing channels, say #test and #test2 if the other person is on #test2 the script will think they are on #test

how can I get it so #test does not show up as confirming #test2?

this might be why this is happening, but when I run the script I get this error message:

* Too many parameters: $lines (line 75, script.ini)

which is
Code:
//set %blacklist $read(blacklist.txt,%b)

Re: channel blacklist [Re: LordoftheX] #172641 13/03/07 01:28 PM
Joined: Mar 2007
Posts: 12
S
Sintel Offline
Pikka bird
Offline
Pikka bird
S
Joined: Mar 2007
Posts: 12
I don't know why the parameter error occurs but the other problem is obvious. You put all the whois info in one var, so in essence you have one long string. Then you test by seeing if there is any occurrence of "#test" in that string, and of course there's "#test" in "#test2"

To fix that last problem you have to find out what the delimiter is between information (comma or space or whatever). Suppose that a comma is the delimiter (think it's a space tho), then you have to change your test to finding an occurrence of the channelname + delimiter in the string, so look for "#test," instead.

you can do this easily by $+(%blacklist,$chr(delimiternumber))

This does not completely solve it either, as the last piece of information has no delimiter after it normally (check it), so you will have to append %blacklist.check with a delimiter before going into your checking loop.

Also, double dashes are not necessary in scripts, you can just leave them out.

Re: channel blacklist [Re: Sintel] #172645 13/03/07 01:49 PM
Joined: Jan 2007
Posts: 259
K
Kardafol Offline
Fjord artisan
Offline
Fjord artisan
K
Joined: Jan 2007
Posts: 259
What about using $addtok, $istok and $deltok (You need to use $findtok in $deltok to find the position of the token)?
[I hate when firefox crashes because of Shift + Enter]
I've used this method before, and it works fine, as you only need one variable to store the data, and $istok won't match 'a' in "b c d e ae".

From the help file:
Quote:

$addtok(text,token,C)

Adds a token to the end of text but only if it's not already in text.

$addtok(a.b.c,d,46) returns a.b.c.d

$addtok(a.b.c.d,c,46) returns a.b.c.d

The C parameter is the ascii value of the character separating the tokens.

Note: $addtokcs() is the case-sensitive version.

$deltok(text,N-N2,C)

Deletes the Nth token from text.

$deltok(a.b.c.d,3,46) returns a.b.d

$deltok(a.b.c.d,2-3,46) returns a.d

You can specify a negative value for N.

$findtok(text,token,N,C)

Returns the position of the Nth matching token in text.

$findtok(a.b.c.d,c,1,46) returns 3

$findtok(a.b.c.d,e,1,46) returns $null

If you specify zero for N, it returns the total number of matching tokens.

Note: $findtokcs() is the case-sensitive version.

$gettok(text,N,C)

Returns the Nth token in text.

$gettok(a.b.c.d.e,3,46) returns c

$gettok(a.b.c.d.e,9,46) returns $null

You can also specify a range of tokens:

$gettok(a.b.c.d.e,2-,46) returns 2nd token onwards b.c.d.e

$gettok(a.b.c.d.e,2-4,46) returns tokens 2 through 4 b.c.d

You can specify a negative value for N.

$istok(text,token,C)

Returns $true if token exists, otherwise returns $false.

Note: $istokcs() is the case-sensitive version.


Those who can, cannot. Those who cannot, can.
Re: channel blacklist [Re: Kardafol] #172651 13/03/07 02:38 PM
Joined: Feb 2006
Posts: 546
J
jaytea Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
Originally Posted By: Kardafol
(You need to use $findtok in $deltok to find the position of the token)


usually a combination of $deltok/$findtok can be replaced by just $remtok :p


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Re: channel blacklist [Re: Kardafol] #172656 13/03/07 03:20 PM
Joined: Mar 2007
Posts: 12
S
Sintel Offline
Pikka bird
Offline
Pikka bird
S
Joined: Mar 2007
Posts: 12
yeah, stupid that i didn't think about the token identifiers, but will need to know the delimiter for that as well.

so a general structure would be
if $istok {
$remtok
;whatever
}

Re: channel blacklist [Re: Sintel] #172662 13/03/07 05:28 PM
Joined: Jan 2007
Posts: 259
K
Kardafol Offline
Fjord artisan
Offline
Fjord artisan
K
Joined: Jan 2007
Posts: 259
No, the structure would be:
Code:
;check
if ($istok(%var,%channel-user-is-on,deltimer asc)) {
...
}
;add
set %var $addtok(%var,%add,deltimer asc)
;delete
if ($istok(%var,%del,deltimer asc)) {
set %var $deltok(%var,$findtok(%var,%del,deltimer asc),deltimer asc)
}


Those who can, cannot. Those who cannot, can.
Re: channel blacklist [Re: Sintel] #172663 13/03/07 05:52 PM
Joined: Jan 2005
Posts: 25
L
LordoftheX Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2005
Posts: 25
[EDIT] Ok, didn't see the latest post, lets see if that will help shed light on my predicament
[Further EDIT] For my revision, it looks like the script is not doing anything in the while() and again, don't know why :x

ok, I went back through and tried my hand again, using tokens this time, and though it seems a much more straightforward way to go about things, it still doesn't work.

The frustrating part is its not returning any sort of error ^^;;

Code:
raw 319:*: {
  set %blacklist.check $remove($1-,@,+)
  var %i= 1
  while (%i <= $0) {
    if ($gettok(%blacklist.check,%i,32) isin %blacklist {
      ;command
    }
    else { 
      inc %i
    }
  }
}


and I just cant seem to find whats getting snagged up. knowing me, its probably something very stupid T_T

Last edited by LordoftheX; 13/03/07 06:15 PM.
Re: channel blacklist [Re: LordoftheX] #172678 13/03/07 09:44 PM
Joined: Jan 2005
Posts: 25
L
LordoftheX Offline OP
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Jan 2005
Posts: 25
Code:
raw 319:*: {
if ($2 ison #channel) {
  set %user.channels $remove($1-,@,+)
  set %checknum $0
  set %i 3
  while (%i <= %checknum) {
    set %blacklist.check $addtok(%blacklist.check,$gettok(%user.channels,%i,32),32)
    set %del $gettok(%user.channels,%i,32)
    if ($istok(%blacklist,%blacklist.check,32) == $true) {
      ban -u300 #ircmods $2 2
      :command
      unset %blacklist.check
      unset %del
      break
    }
    if ($istok(%blacklist.check,%del,32)) {
      set %blacklist.check $deltok(%blacklist.check,$findtok(%blacklist.check,%del,32),32)
      inc %i 1
    }
  }
}


^ worked shocked

Thanks for the help