mIRC Home    About    Download    Register    News    Help

Print Thread
#211620 25/04/09 09:29 PM
Joined: Nov 2006
Posts: 143
X
xyzzy Offline OP
Vogon poet
OP Offline
Vogon poet
X
Joined: Nov 2006
Posts: 143
Code:
on *:text:*:#:{
  if $nick isreg # { var %k = 1,%kk = $lines(spam.txt) | while %k <= %kk { 
      if $+(*,$read(spam.txt,%k),*) iswm $1- {
        if !$window(@Spams) { window -mze @Spams }
    echo -t @Spams $chan $nick : $1- | return $true } | inc %k } | return $false 
    write $qt($mircdirlogs\Spams.txt) $fulldate $chan $nick : $1-
  } 
}

i need fix this code to make it work for pvt and channel spams
and something wrong its not writing the log in Spams.txt confused



xyzzy #211623 25/04/09 11:03 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
To have it work in pm's change the # in the ON TEXT event to an *

Also note that in a pm, your first if statement will always return $false as the # character references a channel name, and in a pm there is no channel name, so the # character returns $null

Regarding the file not being written, it probably is but you reference spam.txt for the file that is read and spams.txt for the file that is written.
Additionally, since you didn't specify a directory location for spam.txt, mIRC looks for that file in the same directory where mirc.ini is located. Your Spams.txt file is specified to be in the logs directory.


xyzzy #211625 25/04/09 11:12 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
It's not writing because the "return" command will halt any further processing - it cannot get to the /write in any case.
Here's the same code with the write command at the right position (a match on a line read) and some cosmetic changes that make it more easy to read - your code (using a lot of pipes and weird bracket positions) is hard to read > debug. Instead of "return", "break" is used (breaks out of the loop, so commands after the loop would be processed. But as there are none, "return" would have the same effect )

Code:
on *:text:*:#:{
  if ($nick isreg #) {
  ECHO -a triggert
    var %k = 1, %kk = $lines(spam.txt) 
    while (%k <= %kk) { 
      if ($+(*,$read(spam.txt,%k),*) iswm $1-) {
        if (!$window(@Spams)) { window -mze @Spams }
        echo -t @Spams $chan $nick : $1-
        write $qt($mircdirlogs\Spams.txt) $fulldate $chan $nick : $1-
        break
      }
      inc %k
    }
  } 
}

And to make it work for queries too:
Code:
; location "#" was changed for "*" to match both channel- and query messages
on *:text:*:*:{
  ; if it's in a query theres no chan, so the condition was extended
  if (!$chan) || ($nick isreg $chan) {
    var %k = 1, %kk = $lines(spam.txt) 
    while (%k <= %kk) { 
      if ($+(*,$read(spam.txt,%k),*) iswm $1-) {
        if (!$window(@Spams)) { window -mze @Spams }
        ; the two $iif in the next lines will echo/write the channels name or "[query]" for private messages
        echo -t @Spams $fulldate $iif($chan,$v1,[query]) $nick : $1-
        write $qt($mircdirlogs\Spams.txt) $fulldate $iif($chan,$v1,[query]) $nick : $1-
        break
      }
      inc %k
    }
  } 
}

Horstl #211629 26/04/09 12:33 AM
Joined: Nov 2006
Posts: 143
X
xyzzy Offline OP
Vogon poet
OP Offline
Vogon poet
X
Joined: Nov 2006
Posts: 143
thanksss works very well smile


Link Copied to Clipboard