mIRC Home    About    Download    Register    News    Help

Print Thread
Read file with Command on TEXT #268353 12/01/21 10:56 PM
Joined: Dec 2020
Posts: 10
Bes Offline OP
Pikka bird
OP Offline
Pikka bird
Joined: Dec 2020
Posts: 10
Hello all.

I need help, for this code, maybe its not a dificult and for you its to easy but for me its not easy..

Code
on *:TEXT:*!PROXY*:#kontrolli:{
  if ($nick ison #) && ($2 = $read(C:\telejuara.txt,w,$2)) && ($2) { msg #kontrolli 47I cant add this IP  - $+ $2 $+ - on SHUN because its in ALLOW list - telejuara.txt  halt }
  if ($nick ison #) && ($2 != $read(C:\telejuara.txt,s,$2)) && ($2) { msg #Kontrolli 4,1Proxy: 12I have make this IP in SHUN: 6 $2 | /shun $4 20s 47Β« Your system its not sure because You use Proxy or VPN..  Β» ( /Firewall Off ) halt }
}
}


I have created a file with txt to C:\ with the name telejuara.txt and I have put all IP what are all good from good company and when I make !Proxy 46.19.225.162 read automatic this file and found thit IP in this File (C:\telejuara.txt) and make nothing, WHEN a IP its not in this File (C:\telejuara.txt) i have coded and make SHUN

Now what i want to help ME its:


i want to configure this code, when a make a IP in this File (C:\telejuara.txt) ---> 46.19.* <--- and than, when a make a full IP in my channel maybe !Proxy 46.19.125.19 and make nothing because this IP its sure and its in this File (C:\telejuara.txt).

Thanka for help.

AdmiraL

Last edited by Bes; 12/01/21 11:00 PM.
Re: Read file with Command on TEXT [Re: Bes] #270411 22/06/22 01:28 PM
Joined: Jan 2012
Posts: 209
Epic Offline
Fjord artisan
Offline
Fjord artisan
Joined: Jan 2012
Posts: 209
I have created a small script for you. Try to use it according to your needs. All settings are made inside the alias "ci_set".

Code
alias -l ci_set {
  %ci_path_list = scripts\CheckIP\allow_list.txt
  %ci_shun_time = 1h
  %ci_shun_reason = You are probably using a Proxy or VPN...
  %ci_chans = #test,#kontrolli
}
---------------------------------------------------------------------
on *:TEXT:!proxy*:#:{
  ci_set | if ($istok(%ci_chans,$chan,44)) {
    if ($imfind($2)) msg $chan I cant add this IP:03 $2 - on SHUN because its in ALLOW list:12 $v1
    else { shun $+(*!*@,$2) %ci_shun_time %ci_shun_reason | msg $chan Proxy - I have added this IP in SHUN:04 $2 }
  }
}
alias -l imfind { var %n $gettok($1,1,46) | var %f %ci_path_list | var %l 1 | :next | if ($read(%f, wt, $+(%n,.*), %l)) { var %r $readn | var %l $calc(%r +1) | var %s $read(%f,%r) | if (%s iswm $1) return %s | if (%l < $lines(%f)) goto next } }



🌐 http://forum.epicnet.ru πŸ“œ irc.epicnet.ru 6667 #Code (mIRC scripts, help, discuss, examples)
Re: Read file with Command on TEXT [Re: Epic] #270412 22/06/22 03:43 PM
Joined: Jul 2006
Posts: 3,931
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,931
The 't' and 'n' switches of $read seem to have slipped out of the code before you clicked Post Reply!


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Re: Read file with Command on TEXT [Re: Wims] #270415 23/06/22 10:21 AM
Joined: Jan 2012
Posts: 209
Epic Offline
Fjord artisan
Offline
Fjord artisan
Joined: Jan 2012
Posts: 209
Originally Posted by Wims
The 't' and 'n' switches of $read seem to have slipped out of the code before you clicked Post Reply!

Not certainly in that way. Just given the condition of delivered the task, I do not consider it necessary to use excess additional switches inside the identifier "$read()" while reading and checking the lines of the file containing only the numbers "0-9", dots "." and asterisks "*". Because with a large number of IP addresses in the list, the script should work as efficiently and quickly as possible.





🌐 http://forum.epicnet.ru πŸ“œ irc.epicnet.ru 6667 #Code (mIRC scripts, help, discuss, examples)
Re: Read file with Command on TEXT [Re: Epic] #270416 23/06/22 11:53 AM
Joined: Jan 2004
Posts: 1,352
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,352
What would make you think adding more switches would slow it down? If anything they'll make it faster because the lines won't be evaluated.

Re: Read file with Command on TEXT [Re: Epic] #270417 23/06/22 02:12 PM
Joined: Jul 2006
Posts: 3,931
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,931
But it is necessary. Either you want the line to be evaluated or you don't, if you don't, you should use the n switch, and it's extremely rare that a script will result in a need to evaluate the line from a $read call, it almost never happen in practice, and it's very dangerous to evaluate unknown content, via a different exploit someone may be able to write code to that file.
The t switch is also almost always required in practice because the content of the file is either unknown, or it's known but the first line is not representing the total number of line. So in practice, not using the t switch will only result in some $read failure when the first line is a number, rather than doing any good to the read call by not using it.

Not using the t switch will only result in failure but not using the n switch can result in someone evaluating code behind your back etc.

You used "wt" switches for the first $read call and then you didn't use the t switch to get the whole line, your t switch usage is not consistent anyway.

And as pointed out evaluating will only make it slower.

Always use the n switch unless you specifically want to evaluate the line, and always use the t switch unless you control the first line of the file and it's a number representing the total number of lines in the file.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Re: Read file with Command on TEXT [Re: Loki12583] #270418 23/06/22 05:05 PM
Joined: Jan 2012
Posts: 209
Epic Offline
Fjord artisan
Offline
Fjord artisan
Joined: Jan 2012
Posts: 209
OΠΊ. To cast aside all doubts, I made several tests and this is the result I got:

    [Linked Image from i.ibb.co]

Hmm... but with the earlier version it was much faster:

    [Linked Image from i.ibb.co]

In principle, I agree with this, when there are fears that unauthorized actions can be performed with working file by extraneous scripts with the addition of new entries or in the case of using unknown files, then in order to avoid dangerous consequences, it is better to always use the "n" switch when reading a file.


🌐 http://forum.epicnet.ru πŸ“œ irc.epicnet.ru 6667 #Code (mIRC scripts, help, discuss, examples)
Re: Read file with Command on TEXT [Re: Epic] #270419 24/06/22 05:59 AM
Joined: Jan 2004
Posts: 1,807
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,807
Your demo is not very legible. Your "earlier" test has a later timestamp, but you have 2 pairs of tests that both happen to start at the same hr:mins:secs ?
This is a test that takes 6 minutes to read from a text? or you have a large number of repeats? When benchmarking things, you must take care to minimize things not being tested. For example, disk access is very slow compared to other things, so to lessen the effect of the disk read, you should have a disk read to put the file into the cache, before doing the timed test. It's really hard to read your test, since the reader is more concerned with how long a test takes, not what the start and stop times are.