mIRC Homepage

TXT File Help

Posted By: Buggs2008

TXT File Help - 24/11/07 11:55 PM

Hello,

I have this code but I would like to create an alias to del the user from the blacklist.

the format would be: $blacklist(del,$gettok($ial($$2,1),1,64))

alias blacklist {
if ($1 == check) {
var %addr = $gettok($ial($$2,1),1,64)
var %line = $read($scriptdirblacklist.txt,w,%addr)
if (%line) return $true
else return $false
}
elseif ($1 == set) {
if (!$isfile(blacklist.txt)) write -c blacklist.txt
var %addr = $gettok($ial($$2,1),1,64)
var %line = $read($scriptdirblacklist.txt,w,%addr)
if (!%line) write $scriptdirblacklist.txt $gettok($ial($$2,1),1,64) $3-
}
}

on 1:join:#:{
if ($blacklist(check,$nick) == $true) { kick # $nick : [-BlackListed-] }
}

Any help is greatly appreciated.

Thanks a bunch.

J
Posted By: Lpfix5

Re: TXT File Help - 25/11/07 04:00 AM

Um (I just replaced vars around so they arew not called 1 million times) and I use the same format of your picked to delete the user with Write -dl#

Code:
alias blacklist {
  if ($$1) {
    var %addr = $gettok($ial($$2,1),1,64)
    var %line = $read($scriptdirblacklist.txt,w,%addr)
    if ($1 == check) {
      if (%line) return $true
      else return $false
    }
    elseif ($1 == set) {
      if (!$isfile(blacklist.txt)) write -c blacklist.txt
      if (!%line) write $scriptdirblacklist.txt $gettok($ial($$2,1),1,64) $3-
    }
    elseif ($1 == del) {
      if (!$isfile(blacklist.txt)) write -c blacklist.txt
      if (!%line) .write $+(-dl,$readn) $scriptdirblacklist.txt
    }
  }
  else { echo 4 ERROR: Incorrect Syntax Use }
}



EDIT: FIXED $scriptdirblacklist.txt
Posted By: Wims

Re: TXT File Help - 25/11/07 04:54 AM

I think you forgot some $scriptdir and a "blacklist.txt"

Edit : the OP himself don't use $scriptdir at some point ...
Posted By: Lpfix5

Re: TXT File Help - 25/11/07 05:51 AM

Fixed :p
Posted By: Buggs2008

Re: TXT File Help - 26/11/07 02:46 AM

Hello

I just wanted to give a big thanks to everyone who helped me on this. You guys are god saint

Thanks a bunch

Cheers

- J laugh
Posted By: Lpfix5

Re: TXT File Help - 26/11/07 02:52 AM

blush :P
Posted By: Buggs2008

Re: TXT File Help - 26/11/07 03:21 AM

I was trying to play around with it, it works perfectly to delete the user from the blacklist on one condition -> They are in the channel,

however how could I modify this code such that it would be possible to delete user when they are not in the channel, but rather in the database itself?

alias blacklist {
if ($$1) {
var %addr = $gettok($ial($$2,1),1,64)
var %line = $read($scriptdirblacklist.txt,w,%addr)
if ($1 == check) {
if (%line) return $true
else return $false
}
elseif ($1 == set) {
if (!$isfile(blacklist.txt)) write -c blacklist.txt
if (!%line) write $scriptdirblacklist.txt $gettok($ial($$2,1),1,64) $3-
}
elseif ($1 == del) {
if (!%line) { echo -a ***** Error: $chr(91) %addr $chr(93) is not listed in the [-BlackList-] | halt }
elseif (%line) {
write -dl $readn $scriptdirblacklist.txt
echo -a 4***** $chr(91)  $+ %addr $+  $chr(93) deleted from blacklist *****
}
}
}
}

Thanks a bunch.
Posted By: Lpfix5

Re: TXT File Help - 26/11/07 05:09 AM

Um, a quick fix to your answer is Adding a var and using that var for that section and to call up the search terms of identifier $2 to scan file for matches (If match return then) it deletes data from file weather he/she is on #channel

Code:
alias blacklist {
  if ($$1) {
    var %addr = $gettok($ial($$2,1),1,64)
    var %line = $read($scriptdirblacklist.txt,w,%addr)
    if ($1 == check) { echo -a $iif(%line,$true,$false) }
    elseif ($1 == set) {
    if (!%line) write $scriptdirblacklist.txt %addr $3-    }
    elseif ($1 == del) {
      var %del = $read($scriptdirblacklist.txt,w,$+(*,$$2,*))
      if (!%del) { echo -a ***** Error: $chr(91) %addr $chr(93) is not listed in the [-BlackList-] | halt }
      elseif (%del) { 
        write $+(-dl,$readn) $scriptdirblacklist.txt
        echo -a 4***** $chr(91)  $+ %addr $+  $chr(93) deleted from blacklist ***** 
      }
    }
  }
}


enjoy
Posted By: Buggs2008

Re: TXT File Help - 26/11/07 06:10 AM

Wow,

Thanks for the fast reply, everything works fine now.

Thanks again, I really appreciate it, im very glad this forum has lots of mIRC experts wink

Cheers and have a nice day!

- J
Posted By: Lpfix5

Re: TXT File Help - 26/11/07 02:42 PM

I love playing with .txt files laugh
© 2019 mIRC Discussion Forums