|
Joined: Apr 2014
Posts: 31
Ameglian cow
|
OP
Ameglian cow
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? 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.
|
|
|
|
Joined: Feb 2011
Posts: 462
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Feb 2011
Posts: 462 |
|
|
|
|
Joined: Apr 2014
Posts: 31
Ameglian cow
|
OP
Ameglian cow
Joined: Apr 2014
Posts: 31 |
Fixed :P 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.
|
|
|
|
Joined: Jun 2014
Posts: 248
Fjord artisan
|
Fjord artisan
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?
|
|
|
|
Joined: Apr 2014
Posts: 31
Ameglian cow
|
OP
Ameglian cow
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 Quite a simple script but I'm failing to make it use wildcards.
Last edited by Gargantuan; 29/01/15 02:06 PM.
|
|
|
|
Joined: Dec 2013
Posts: 779
Hoopy frood
|
Hoopy frood
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" //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
|
|
|
|
Joined: Apr 2014
Posts: 31
Ameglian cow
|
OP
Ameglian cow
Joined: Apr 2014
Posts: 31 |
|
|
|
|
Joined: Dec 2013
Posts: 779
Hoopy frood
|
Hoopy frood
Joined: Dec 2013
Posts: 779 |
/help /while Basic syntax: var %i 1
while (%i <= $numtok($1-,32)) {
var %token $gettok($1-,%i,32)
inc %i
}
Nillens @ irc.twitch.tv Nillen @ irc.rizon.net
|
|
|
|
Joined: Apr 2014
Posts: 31
Ameglian cow
|
OP
Ameglian cow
Joined: Apr 2014
Posts: 31 |
I can't get it to work =| It stops working whenever a word is put behind the link. on *:text:*:#: {
var %i 1
while (%i <= $numtok($1-,32)) {
var %token $gettok($1-,%i,32)
inc %i
}
if ($read(■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.
|
|
|
|
Joined: Sep 2014
Posts: 259
Fjord artisan
|
Fjord artisan
Joined: Sep 2014
Posts: 259 |
It's hard to say what's wrong without seeing the code
|
|
|
|
Joined: Sep 2014
Posts: 259
Fjord artisan
|
Fjord artisan
Joined: Sep 2014
Posts: 259 |
You need to put
if ($read(test.txt, nw, %token))
inside the while loop
|
|
|
|
Joined: Apr 2014
Posts: 31
Ameglian cow
|
OP
Ameglian cow
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.
|
|
|
|
Joined: Sep 2014
Posts: 259
Fjord artisan
|
Fjord artisan
Joined: Sep 2014
Posts: 259 |
Add a return, so it will look something like this
if ($read(test.txt, nw, %token)) {
echo -a blah
return
}
Last edited by Sakana; 30/01/15 12:03 AM.
|
|
|
|
Joined: Apr 2014
Posts: 31
Ameglian cow
|
OP
Ameglian cow
Joined: Apr 2014
Posts: 31 |
Thank you works great
|
|
|
|
Joined: Apr 2014
Posts: 31
Ameglian cow
|
OP
Ameglian cow
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. on *:text:!list *:#: {
if ($read(■list\list.txt,nw,$2)) {
var %list $readn(■list\list.txt,nw,$2)
write -dl $+ %list ■list\list.txt
}
}
P.S: Is it possible to have several triggers here? Working. Not working. on *:text:*Hello*/*Hey*/*Hi*/:#: {
Last edited by Gargantuan; 31/01/15 07:37 PM.
|
|
|
|
Joined: Sep 2014
Posts: 259
Fjord artisan
|
Fjord artisan
Joined: Sep 2014
Posts: 259 |
This works for me on $*:text:/(Hello|Hey|Hi)/:#:{
if ($read(C:\test.txt,n,$2)) {
write -dl $+ $readn C:\test.txt
}
}
|
|
|
|
Joined: Apr 2014
Posts: 31
Ameglian cow
|
OP
Ameglian cow
Joined: Apr 2014
Posts: 31 |
on $*:text:/(Hello|Hey|Hi)/:#:{ Responds for some reason inside the TMI channel and wildcards break it. 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.
|
|
|
|
Joined: Jul 2006
Posts: 4,188
Hoopy frood
|
Hoopy frood
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
|
|
|
|
Joined: Apr 2014
Posts: 31
Ameglian cow
|
OP
Ameglian cow
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.
|
|
|
|
Joined: Apr 2014
Posts: 31
Ameglian cow
|
OP
Ameglian cow
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.comBot: Too much caps. Bot: Don't link without permission. The text above is just an example. But the problem is the same, any ideas?
|
|
|
|
|