mIRC Homepage
Posted By: mikkisofta Ban script, with read - 18/03/09 10:12 AM
I know I'm very bad script writer but how I can make this work correctly ?

on *:text:*:#: { $read(urls.txt) { $ifmatch { /mode $chan +b $nick | /kick # $nick No Advertiseing !
}
}
}

That works, but not right.. Some1 say some url my bot kicks hime/her.. And I want that my bot reads that text file I specified and kick if the url is there..
Posted By: RusselB Re: Ban script, with read - 18/03/09 12:08 PM
Code:
on *:text:*:#:{
if $read(urls.txt,w,$+(*,$1,*)) {
.ban -k $chan $nick No advertising
}
}

This will check the text file for a match to the first word entered. There are excellent regex methods of restricting the match text section of the ON TEXT event to just a URL format.
Then the actual URL can be checked, no matter if the URL is the first word or not. Unfortunately I'm still in the process of waking up and not thinking straight enough to provide the regex.
Posted By: Wims Re: Ban script, with read - 18/03/09 12:34 PM
Regex is great when you want to match any link, here he want to match only link that are in his file.
Posted By: mikkisofta Re: Ban script, with read - 18/03/09 12:46 PM
Hmm.. Not working.. Where is should put that text file ?

I mean like this;

text file:

http://www.examble.com
http://examble.com
http://ThisIsExamble.com


mikkisofta: http://www.examble.com
Bot: set +b & kick.

mikkisofta: http://haveaniceday.org
Bot: nothing.
Posted By: RusselB Re: Ban script, with read - 18/03/09 12:57 PM
Code modified to allow for any of the examples that you posted.

Remember that the URL in the text file must match that of the URL that is posted in the channel.

Quote:
mikkisofta: http://haveaniceday.org
Bot: nothing.

The bot does nothing in this case, since you don't have http://haveaniceday.org in your text file (according to the samples you provided).

Posted By: Horstl Re: Ban script, with read - 18/03/09 03:03 PM
As an alternative, the script below will capture forbidden urls inside messages without the need to specify possile variations of the protocoll for each. It's the best method using $read for this task I can think of atm, though there may be a bether one, and $read isn't the best choice for this kind of matching at all. As long as you don't have an excessivly long list of urls, it may be sufficient.

Put all forbidden "urls" inside a textfile named "forbiddenurls.txt" located in your mirc main directory, each on a separate line.
DON'T add the protocol like http:// or host (www.) there, start at the domain part. You may use wildcards.
Examples:
for "www.google.com" add: google.com
for "https://forums.mirc.com" add: forums.mirc.com

The script will check all words that contain either the protocol "http://", "https://" "ftp://", or "www.". If any line in the textfile matches the text following the protocol, it will issue the kickban.

Example:
If you have e.g. in the textfile the line: test123.com
It will ban for messages:
"www.test123.com"
"Gratis testing? >http://www.test123.com<"
"check out http://test123.com/tests/something"

It won't ban for:
"www.anothertest123.com"
"I really like test123.com"


Code:
on @*:text:*:#YOURCHAN: { urlcheck $1- }
on @*:action:*:#YOURCHAN: { urlcheck $1- }

alias -l urlcheck {
  noop $regex($strip($1-),/(?:(?:http|https|ftp):\/\/|www\.)(?:www\.)?(\S+)/gi) 
  var %a = 1
  while ($regml(%a)) {
    var %b = 1
    while ($read(forbiddenurls.txt,%b)) {
      if ($+($v1,*) iswm $regml(%a)) {
        ban -k $chan $nick 1 No advertising!
        return
      }
      inc %b
    }
    inc %a
  }
}

(the regex is far from perfect, but it should work)
Posted By: mikkisofta Re: Ban script, with read - 18/03/09 03:42 PM
Originally Posted By: Horstl
As an alternative, the script below will capture forbidden urls inside messages without the need to specify possile variations of the protocoll for each. It's the best method using $read for this task I can think of atm, though there may be a bether one, and $read isn't the best choice for this kind of matching at all. As long as you don't have an excessivly long list of urls, it may be sufficient.

Put all forbidden "urls" inside a textfile named "forbiddenurls.txt" located in your mirc main directory, each on a separate line.
DON'T add the protocol like http:// or host (www.) there, start at the domain part. You may use wildcards.
Examples:
for "www.google.com" add: google.com
for "https://forums.mirc.com" add: forums.mirc.com

The script will check all words that contain either the protocol "http://", "https://" "ftp://", or "www.". If any line in the textfile matches the text following the protocol, it will issue the kickban.

Example:
If you have e.g. in the textfile the line: test123.com
It will ban for messages:
"www.test123.com"
"Gratis testing? >http://www.test123.com<"
"check out http://test123.com/tests/something"

It won't ban for:
"www.anothertest123.com"
"I really like test123.com"


Code:
on @*:text:*:#YOURCHAN: { urlcheck $1- }
on @*:action:*:#YOURCHAN: { urlcheck $1- }

alias -l urlcheck {
  noop $regex($strip($1-),/(?:(?:http|https|ftp):\/\/|www\.)(?:www\.)?(\S+)/gi) 
  var %a = 1
  while ($regml(%a)) {
    var %b = 1
    while ($read(forbiddenurls.txt,%b)) {
      if ($+($v1,*) iswm $regml(%a)) {
        ban -k $chan $nick 1 No advertising!
        return
      }
      inc %b
    }
    inc %a
  }
}

(the regex is far from perfect, but it should work)



Just this I ment.

Because I don't need script which ban all who say some url, ONLY them who say URL which is in text file. I'll test this script later today.
Posted By: Tomao Re: Ban script, with read - 18/03/09 05:31 PM
If you want the exact match for url links that you specified in your urls.txt, this should do it:
Code:
on *:TEXT:*:#: {
  var %x = $lines(urls.txt)
  while (%x) {
    if ($read(urls.txt,%x) isin $1-) {
      ban -k # $nick 2 $v1 is forbidden to advertise!
    }
    dec %x
  }
}
Posted By: Wims Re: Ban script, with read - 18/03/09 07:26 PM
This code is very inefficient :/, check what was already given using $read(file,w,)
Posted By: Tomao Re: Ban script, with read - 18/03/09 07:42 PM
Wims, I did try Russel's before I posted mine. Russel's will kick on anything beginning with www or http with or without a dot by them. And it won't trigger anything if one posts: welcome to http://www.blah.com or just welcome to www.blah.com without http://, meaning to start with a sentence with an url in it.
Posted By: Wims Re: Ban script, with read - 18/03/09 07:59 PM
I'm talking about your method, not the code itself
Posted By: Tomao Re: Ban script, with read - 18/03/09 08:35 PM
Rather than busting my chops, could you kindly show me your version of efficient method looks like?
Posted By: Wims Re: Ban script, with read - 18/03/09 08:48 PM
The one RusselB used in his first post, with $read ,w, smile
I'm just saying that you're not using a good way of doing something, that's all
Posted By: Tomao Re: Ban script, with read - 18/03/09 09:36 PM
Wims, no offense. But you're not being forthcoming to point out the right way of going at this, and you're keeping me baffled.
Posted By: Wims Re: Ban script, with read - 19/03/09 12:24 AM
No offense wink
I'm saying you're using an inefficient method because you're doing a /while on each line in the file whereas the ,w, parameter of $read already do this itself.
But I agree that the way you're checking for a match isn't the same as $read(,w,), I should not have compared the two situation sorry.
Posted By: mikkisofta Re: Ban script, with read - 19/03/09 06:02 AM
Where I should put that text file ? shocked

I tried both of those scripts, nothing happend.. Wtf I'm doing wrong with this ?
Posted By: Tomao Re: Ban script, with read - 19/03/09 06:47 AM
Make sure the text file is placed in mirc's directory, and the links you wish to kick are jotted down in the text file one per line.
Posted By: mikkisofta Re: Ban script, with read - 26/03/09 08:51 PM
I give up.. I've tried all the scripts on this page, nothing happened.. My bot didn't kick user who say url specified on urls.txt. My bot is running on the lates mIRC so I can't understoot whats wrong..

I think I've to do script like this:

on *:text:*http*:#: { /mode # $nick +b { -k Do not advertise } }

I even don't know will that work, but I'll try.. I hate that ppl are advertising on my channel!
Posted By: Tomao Re: Ban script, with read - 26/03/09 09:32 PM
Give this one a shot:
Code:
on *:TEXT:*:#: {
  if ($regex($1-,/(?<=^| )((?>[a-zA-Z-0-9]{3,8}:\/\/|www\.)\S+)/g)) || ($regex($1-,/(\.[a-zA-Z-0-9]{3,8}))) {
    ban -k $chan $nick 2 Do not advertise!
  }
}
Posted By: Horstl Re: Ban script, with read - 26/03/09 10:31 PM
At trying my suggestion, did you
- put a file "forbiddenurls.txt" in the main directory of the mIRC serving as your bot ( //echo -a $mircdir in the bot client)
- add url entries to this file as described: without http or www or the like
- replace "#YOURCHAN" in the code (2 instances) with the actual channel name or channel names
- make sure the bot running the script was @ in this channel
?
Posted By: Horstl Re: Ban script, with read - 26/03/09 10:33 PM
Do you really want to ban for ".abc" ? :X
Posted By: Tomao Re: Ban script, with read - 26/03/09 10:38 PM
Well, that being said, maybe an ideal script is for the op to set it and forget it...
Posted By: Horstl Re: Ban script, with read - 26/03/09 10:50 PM
I was pointing to your 2nd regex that would match a message like
Quote:
<PoorUser> ...why?
...an efficient method to stop both spam and chat together wink
Posted By: Tomao Re: Ban script, with read - 26/03/09 11:04 PM
Ok how about this:
Code:
on *:TEXT:*:#: {
  var %x = (\x2Ecom|\x2Enet|\x2Eorg|\x2Einfo)$
  if ($regex($1-,/(?<=^| )((?>[a-zA-Z-0-9]{3,8}:\/\/|www\.)\S+)/g)) || ($regex($1-,%x)) {
    ban -k $chan $nick 2 Do not advertise!
  }
}

The main reason I added that is some spammers might say come to blah.com without www. or http://
Posted By: Horstl Re: Ban script, with read - 26/03/09 11:13 PM
Originally Posted By: Tomao
The main reason I added that is some spammers might say come to blah.com without www. or http://
True. But without any www. OR http:// the OP could simply use one of the many badword scripts arround, And the original request was for a text-based url blacklist.
As I tested my code briefly I suppose he just missed something, e.g. I named the file "forbiddenurls.txt" instead of "urls.txt" to be not mistaken for urls.ini ... likely that I produced confusion by trying to prevent confusion frown
Posted By: Tomao Re: Ban script, with read - 26/03/09 11:18 PM
But does your script kick if I place just .com in urls.txt?
Posted By: Horstl Re: Ban script, with read - 26/03/09 11:25 PM
Originally Posted By: Horstl
Put all forbidden "urls" inside a textfile named "forbiddenurls.txt" located in your mirc main directory, each on a separate line.
DON'T add the protocol like http:// or host (www.) there, start at the domain part. You may use wildcards.
So it *should* work for "*.com" - But that's not what I had in mind smile
For general wildcard matches I'd use a simple wildcard-badword script. And the read loop above was to keep it simple and .txt-based - $hfind(W|R) would be more efficient.
Posted By: Tomao Re: Ban script, with read - 26/03/09 11:41 PM
Quote:
So it *should* work for "*.com"

Ok, I see. Unfortunately it didn't work per your description. I jotted down *.com or *.com* or .com in forbiddenurls.txt
Nothing happened with your script. I understand you didn't consider that function in mind, but wouldn't it be better to adjust it that way to seek .com .net or .org extension?
Posted By: Horstl Re: Ban script, with read - 27/03/09 12:07 AM
Erm, it does work, acc. to my description (?)
It doesn't ban for "something.com" but for "www.something.com" or "http://something.com". If you want to ban just for "*.com" you wouldn't need a protocol check at all, and it would be a (lousy) badword script, so why not use a good badword script instead, there are many out there. The downside is that you'd e.g. ban for quoting your $server too.

The script above checks all lines in the textfile against $regml(N)*, where $regml(N) is the text following any occurrence of www/http/https/ftp up to the next space char, that is: a link indicated by a www-host and/or protocol, but without this part, to make matching more versatile.
- If I want to ban "www.google.com" or "http://google.com" or "http://www.google.com", I'd add "google.com"
- If I want to ban all google, I'd add "google." or even "*google"
- If I want to ban "<whatever>.com" I'd add "*.com"

Finally, there are more top-level domains under the sun than *.com *.net and *.org smile
Posted By: mikkisofta Re: Ban script, with read - 03/04/09 01:49 PM
Originally Posted By: Horstl
At trying my suggestion, did you
- put a file "forbiddenurls.txt" in the main directory of the mIRC serving as your bot ( //echo -a $mircdir in the bot client) // Yes I did

- add url entries to this file as described: without http or www or the like // What u mean ?

- replace "#YOURCHAN" in the code (2 instances) with the actual channel name or channel names // I did that too, I specified that channel

- make sure the bot running the script was @ in this channel
Posted By: Horstl Re: Ban script, with read - 03/04/09 05:35 PM
Originally Posted By: mikkisofta
- add url entries to this file as described: without http or www or the like // What u mean ?

There are three examples in the initial post, and some more in my last post.
Quoting myself here:
Quote:
Put all forbidden "urls" inside a textfile named "forbiddenurls.txt" located in your mirc main directory, each on a separate line.
DON'T add the protocol like http:// or host (www.) there, start at the domain part. You may use wildcards.
Examples:
for "www.google.com" add: google.com
for "http://forums.mirc.com" add: forums.mirc.com

(...)

Example:
If you have e.g. in the textfile the line: test123.com
It will ban for messages:
"www.test123.com"
"Gratis testing? >http:[color:#33CC00]//www.[/color]test123.com<"
"check out http://test123.com/tests/something"

And here:
Quote:
- If I want to ban "www.google.com" or "http://google.com" or "http:[color:#FFFFFF]//www.[/color]google.com", I'd add "google.com"
- If I want to ban all google, I'd add "google." or even "*google"
- If I want to ban "<whatever>.com" I'd add "*.com"


/me running out of crayons... frown
© mIRC Discussion Forums