mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#250734 29/01/15 04:16 AM
Joined: Apr 2014
Posts: 31
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Apr 2014
Posts: 31
Hi, I've been trying to make a script that will trigger when someone says a specific link.
But I've failed to find anything that fixes the issue, not in the help files or on the forums. I
probably don't know the exact terms to search for. It triggers on every message and compares the
message to a .txt file. When someone says "www.google.com" then it works fine but it fails to
trigger if someone says "Hello www.google.com" etc. Anyone have any suggestions?

Code:
on *:text:*:#: {
  if ($read(C:\Users\RANDOM\AppData\Roaming\mIRC\■RANDOM\Blacklist.txt, nw, $1-)) {
    if $me isop # { 


P.S: "■" is symbol that the site doesn't figure out for some reason.

Last edited by Gargantuan; 29/01/15 04:23 AM.
Gargantuan #250735 29/01/15 04:18 AM
Joined: Feb 2011
Posts: 462
K
Pan-dimensional mouse
Offline
Pan-dimensional mouse
K
Joined: Feb 2011
Posts: 462
Why not paste the code?

KindOne #250736 29/01/15 04:24 AM
Joined: Apr 2014
Posts: 31
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Apr 2014
Posts: 31
Fixed :P
Code:
on *:text:*:#: {
  if ($read(C:\Users\RANDOM\AppData\Roaming\mIRC\■RANDOM\Blacklist.txt, nw, $1-)) {
    if $me isop # { 


But ye, completely lost. Can't figure out how to make it work.

Last edited by Gargantuan; 29/01/15 04:42 AM.
Gargantuan #250737 29/01/15 07:14 AM
Joined: Jun 2014
Posts: 248
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
This is a really poor implementation of link protection, are you sure this is really how you want this script to function?

Belhifet #250742 29/01/15 01:56 PM
Joined: Apr 2014
Posts: 31
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Apr 2014
Posts: 31
Not really meant to be link protection. That's what people use Nightbot and Moobot for, I'm just making this to ban specific links. Such as viruses/malware/scams/screamers etc. Basically I need a way for the script to read messages and if they post a link that's inside a txt file then it'll ban them. Doesn't need to be amazing smile Quite a simple script but I'm failing to make it use wildcards.

Last edited by Gargantuan; 29/01/15 02:06 PM.
Gargantuan #250743 29/01/15 02:11 PM
Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
You're actively searching for $1-, which in this case would be "hello www.google.com". You should be looping through each word using $gettok instead and wildcard search that. $gettok($1-,1,32) returns "hello", $gettok($1-,2,32) retuns "www.google.com"
Originally Posted By: Help Files: $read
//echo $read(info.txt, s, mirc)

Scans the file info.txt for a line beginning with the word mirc and returns the text following the match value.

//echo $read(help.txt, w, *help*)

Scans the file help.txt for a line matching the wildcard text *help*. The r switch implies a regex match.

If you specify the s, w, or r switches, you can also specify the N value to specify the line you wish to start searching from in the file, eg.:

//echo $read(versions.txt, w, *mirc*, 100)


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Nillen #250751 29/01/15 06:19 PM
Joined: Apr 2014
Posts: 31
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Apr 2014
Posts: 31
How do I loop it?

Gargantuan #250754 29/01/15 08:02 PM
Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
/help /while

Basic syntax:
Code:
var %i 1
while (%i <= $numtok($1-,32)) { 
var %token $gettok($1-,%i,32)
inc %i
}


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Nillen #250758 29/01/15 11:04 PM
Joined: Apr 2014
Posts: 31
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Apr 2014
Posts: 31
I can't get it to work =| It stops working whenever a word is put behind the link.

Code:
on *:text:*:#: {
  var %i 1
  while (%i <= $numtok($1-,32)) { 
    var %token $gettok($1-,%i,32)
    inc %i
  }

  if ($read(&#9632;MalwareProt\Links.txt, nw, %token)) {
    if $me isop # { 
      if $nick isop # {
        echo Nick is Mod
      }
      else {
        echo Worked
      }
    }
    else {
      echo Bot not Mod
    }
  }
  else {
    echo Fail Fail Fail
  }
}


P.S: I know it's weird because of the if nick is mod but never figured out how to reverse it.

Last edited by Gargantuan; 29/01/15 11:27 PM.
Gargantuan #250759 29/01/15 11:18 PM
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
It's hard to say what's wrong without seeing the code

Sakana #250760 29/01/15 11:37 PM
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
You need to put

if ($read(test.txt, nw, %token))

inside the while loop

Sakana #250761 29/01/15 11:43 PM
Joined: Apr 2014
Posts: 31
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Apr 2014
Posts: 31
Worked but now the issue is that if someone types the link 5 times inside the same message. Then it says Worked x5. And will most likely send the message and ban him 5 times.

Last edited by Gargantuan; 29/01/15 11:45 PM.
Gargantuan #250762 29/01/15 11:47 PM
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Add a return, so it will look something like this wink

Code:
if ($read(test.txt, nw, %token)) {
echo -a blah
return
}



Last edited by Sakana; 30/01/15 12:03 AM.
Sakana #250763 30/01/15 01:05 AM
Joined: Apr 2014
Posts: 31
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Apr 2014
Posts: 31
Thank you works great smile

Sakana #250824 31/01/15 07:16 PM
Joined: Apr 2014
Posts: 31
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Apr 2014
Posts: 31
Hi again Sakana, thought it would be better to reply here than making a new topic. Can you see an error in this code?
Example:
list.txt has 500 lines. Counting up from 1.
!list 368 (Should remove line 368)
But it removes (line 1) This script worked a month ago, I updated mIRC and now it doesn't.

Code:
on *:text:!list *:#: {
  if ($read(&#9632;list\list.txt,nw,$2)) {
    var %list $readn(&#9632;list\list.txt,nw,$2)
    write -dl $+ %list &#9632;list\list.txt
  }
}


P.S: Is it possible to have several triggers here?
Working.
Code:
on *:text:*Hello*:#: {

Not working.
Code:
on *:text:*Hello*/*Hey*/*Hi*/:#: {



Last edited by Gargantuan; 31/01/15 07:37 PM.
Gargantuan #250825 31/01/15 08:23 PM
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
This works for me wink

Code:
on $*:text:/(Hello|Hey|Hi)/:#:{
  if ($read(C:\test.txt,n,$2)) {
    write -dl $+ $readn C:\test.txt
  }
} 

Sakana #250826 31/01/15 08:45 PM
Joined: Apr 2014
Posts: 31
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Apr 2014
Posts: 31
Code:
on $*:text:/(Hello|Hey|Hi)/:#:{

Responds for some reason inside the TMI channel and wildcards break it.

Code:
  if ($read(C:\test.txt,n,$2)) {
    write -dl $+ $readn C:\test.txt
  }
} 

If I tell it to remove the 8th line (which would be the 8th letter then it removes the 9th =|

Last edited by Gargantuan; 31/01/15 08:45 PM.
Gargantuan #250828 31/01/15 09:12 PM
Joined: Jul 2006
Posts: 4,188
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,188
Hello, if the first line of the file is a number, mIRC use it as the total number of lines in the file to speed up processing, you need to use the 't' switch in $read to prevent it from doing that. It should not have worked with previous version for the same reason, which version were you on before updating?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #250829 31/01/15 10:00 PM
Joined: Apr 2014
Posts: 31
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Apr 2014
Posts: 31
Don't know what version it was, were several months ago. You fixed the problem though =D Thanks a lot. Really love this stuff but it's so hard to figure out what's wrong when I don't know what exist. /help helps a lot but well, it's a lot of info to scour through.

Gargantuan #250913 02/02/15 03:31 PM
Joined: Apr 2014
Posts: 31
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Apr 2014
Posts: 31
Is there some kind of function that stops two scripts from triggering on the same message?

Person: HELLOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO www.google.com
Bot: Too much caps.
Bot: Don't link without permission.

The text above is just an example. But the problem is the same, any ideas?

Page 1 of 2 1 2

Link Copied to Clipboard