mIRC Home    About    Download    Register    News    Help

Print Thread
I need help #268034 07/11/20 01:15 PM
Joined: Nov 2020
Posts: 3
N
NiKaN Offline OP
Self-satisfied door
OP Offline
Self-satisfied door
N
Joined: Nov 2020
Posts: 3

I am sorry for my English.I found this somewhere.A script written in 2009.It is causing a problem with the program. Can you make it more up to date or do you have such a scenario?.thanks in advance

on *:LOAD: {
; since this script is not designed for multi-server use, this is neccesary
set %joins.network $$?="Please enter the name of the network you want this script to work for..."
}

on *:start: {
nicktracker
window -Sikzl15 @joins
window -ikz @whois
;clean the joinswindow every hour
.timerclean 0 3600 /clean_joins
;update (fill) the joinswindow every 10 seconds
;PLEASE NOTE THAT THIS IS SET TO SCON 1
;CHANGE THIS IF YOU WANT TO USE ANOTHER SERVER CONNECTION
.timerupdate 0 10 .scon 1 /update_joins
if (!%joins.network) { set %joins.network $$?="Please enter the name of the network you want this script to work for..." }
}

on *:QUIT: {
if ($fline(@joins,$nick,1,1)) { /dline -l @joins $fline(@joins,$nick,1,1) }
}

on *:PART:#: {
if ($fline(@joins,$nick,1,1)) { /dline -l @joins $fline(@joins,$nick,1,1) }
}

on *:TEXT:*:#: {
.joins_user
if ($network != %joins.network) { halt }
if ($fline(@joins,$nick,1,1)) { halt }
aline -l @joins $nick
}

on *:KICK:#: {
if ($fline(@joins,$knick,1,1)) { /dline -l @joins $fline(@joins,$knick,1,1) }
}

on *:nick: {
if ($fline(@joins,$nick,1,1)) { /rline -l @joins $fline(@joins,$nick,1,1) $newnick }
else { if ($network == %joins.network) { aline -l @joins $newnick } }
if (!$hget(join)) nicktracker
var %a = 1,%n = 0
while $hget(join,$address($newnick,2) $+ .nicknum. $+ %a) {
if ($v1 == $newnick) %n = 1
inc %a
}
if (%n == 0) hadd join $address($newnick,2) $+ .nicknum. $+ %a $newnick

}

on ^*:join:#: {
if ($nick == $me) { halt }
if (!$fline(@joins,$nick,1,1)) { if ($network == %joins.network) { aline -l @joins $nick } }
if (!$hget(join)) nicktracker
hinc join $address($nick,2) $+ $chan $+ .num

; fill the messages in @joins window
if ($hget(join,$address($nick,2) $+ $chan $+ .last)) echo # 03 $+ $timestamp * $nick 01 $+ $address($nick,2) 03has joined # - Joined $hget(join,$address($nick,2) $+ $chan $+ .num) times - Last as $hget(join,$address($nick,2) $+ $chan) $duration($calc($ctime - $hget(join,$address($nick,2) $+ $chan $+ .last))) ago
else echo # 03 $+ $timestamp * $nick 01 $+ $address($nick,2) 03has joined # - First join
aline @joins 03 $+ $timestamp * $nick 01 $+ $address($nick,0) 03has joined #
if ($hget(join,$address($nick,2) $+ $chan $+ .last)) { aline @joins 03 $+ $timestamp * $nick joined # 01 $+ $hget(join,$address($nick,2) $+ $chan $+ .num) 03times, last:01 $duration($calc($ctime - $hget(join,$address($nick,2) $+ $chan $+ .last))) 03ago }
else { aline @joins 03 $+ $timestamp * $nick never joined # before }

; add new data to database
hadd join $address($nick,2) $+ $chan $nick
hadd join $address($nick,2) $+ $chan $+ .last $ctime
var %a = 1,%n = 0,%b = 1
while $hget(join,$address($nick,2) $+ .nicknum. $+ %a) {
if ($v1 == $nick) %n = 1
inc %a
}
if (%n == 0) hadd join $address($nick,2) $+ .nicknum. $+ %a $nick

;output some more data
aline -p @joins 03 $+ $timestamp * $nick $+ `s previous nicks:01 $checknick($nick)
if ($file($logdir $+ $nick $+ . $+ $network $+ .log)) { aline @joins 03 $+ $timestamp * You have Query logs from01 $nick }
aline -p @joins 03 $+ $timestamp * comchans with $nick $+ : 01 $+ $comchans($nick) $+ .

; clonescanner
while $nick(#,%b) {
if ($nick(#,%b) != $nick) && ($address($nick(#,%b),2) == $address($nick,2)) aline @joins 4 $+ $timestamp * $nick(#,%b) is a clone from $nick $+ !
inc %b
}

; add an empty line and halt other defaults
aline @joins 
haltdef
}

;tracks nicks
alias nicktracker {
hmake join 1000
hload join join.hsh
.timer 0 600 hsave join join.hsh
}

;search previous nicks
alias prevnicks {
if (!$hget(join)) nicktracker
var %a = 1,%s
while $hget(join,$address($1,2) $+ .nicknum. $+ %a) {
%s = %s $v1
inc %a
}
echo -a -->12 $1 has had the nicks:4 %s
}

;search common chans with an user
alias comchans {
/var %x 0
:comchanloop
/inc %x
if ($1 ison $chan(%x)) {
if (!%y) { /var %y $chan(%x) }
else { /var %y $+(%y,$chr(44),$chr(32),$chan(%x)) }
}
if (%x < $chan(0)) {
goto comchanloop
}
/return %y
}

;update the current online users (topic)
alias joins_user {
renwin @joins @joins $line(@joins,0,1) users online
}

;check old nicknames on hostmask
alias checknick {
if ($1 isin $read(nicks.txt, s, $address($1, 2))) {
return $read(nicks.txt, s, $address($1, 2))
halt
}
if (($read(nicks.txt, w, $address($1, 2) $+ *)) && ($1 !isin $read(nicks.txt, s, $address($1, 2)))) {
var %oldnicks $read(nicks.txt, s, $address($1, 2))
/write -s $address($1, 2) nicks.txt $address($1, 2) %oldnicks $+ , $1
return $read(nicks.txt, s, $address($1, 2))
halt
}
/write nicks.txt $address($1, 2) $1
return $read(nicks.txt, s, $address($1, 2))

}

;fill the sidebar with online users
alias update_joins {
set %z $chan(0)
while (%z >= 1) {
set %y $nick($chan(%z),0)
while (%y >= 1) {
aline -nl @joins $nick($chan(%z),%y)
dec %y
}
dec %z
}
}

;repeat info (+ some whois info)
alias getinfo {
whois $1
.enable #getinfo
aline @joins 03 $+ $timestamp * $1 $+ 's host is01 $address($1, 5)
aline -p @joins 03 $+ $timestamp * $1 comchans: 01 $+ $comchans($1)
aline -p @joins 03 $+ $timestamp * $1 $+ 's other nicknames:01 $checknick($1)
set %x $numtok($comchans($1), 44)
while (%x >= 1) {
aline @joins 03 $+ $timestamp * $1 joined01 $gettok($comchans($1), %x, 44) 04 $+ $hget(join,$address($1,2) $+ $strip($gettok($comchans($1), %x, 44)) $+ .num) 03times, last:01 $duration($calc($ctime - $hget(join,$address($1,2) $+ $strip($gettok($comchans($1), %x, 44)) $+ .last))) 03ago

dec %x
}
.timerget2 1 1 .disable #getinfo
.timerget 1 1 aline @joins 

}

;checks users that are in the list, but are not online
alias clean_joins {
set %x $line(@joins,0,1)
while (%x >= 1) {
if (!$address($line(@joins,%x,1),2)) { /dline -l @joins %x }
dec %x
}
}

#getinfo off
;whois information for getinfo
raw *:*: {
if ($istok($whoisnumerics,$numeric,124)) haltdef
if ($numeric == 301) aline @joins 11? Away: Yes: ( $+ $3- $+ )
elseif ($numeric == 307) aline @joins 03 $+ $timestamp * Registered Nickname: 01Yes.
elseif ($numeric == 310) aline @joins 03 $+ $timestamp * IRC Helper: 01Yes.
elseif ($numeric == 311) {
aline @joins 03 $+ $timestamp * Real Name:01 $6-
}
elseif ($numeric == 312) aline @joins 03 $+ $timestamp * Server:01 $3
elseif ($numeric == 313) aline @joins 03 $+ $timestamp * Network Functions:01 $5-9

elseif ($numeric == 317) {
aline @joins 03 $+ $timestamp * Signed on at:01 $asctime($4,dddd dd/mm/yyyy HH:nn:ss)
aline @joins 03 $+ $timestamp * Time idle:01 $duration($3)
aline @joins 03 $+ $timestamp * Time online:01 $duration($calc($ctime - $4))
}
elseif ($numeric == 320) aline @joins 03 $+ $timestamp * Swhois:01 $2-
elseif ($numeric == 330) aline @joins 03 $+ $timestamp * Authname:01 $3
elseif ($numeric == 335) aline @joins 03 $+ $timestamp * Bot:01 Yes
elseif ($numeric == 338) {
aline @joins 03 $+ $timestamp * Real Hostmask:01 $3
aline @joins 03 $+ $timestamp * Real IP:01 $4
}
elseif ($numeric == 378) aline @joins 03 $+ $timestamp * Connecting from:01 $6-
elseif ($numeric == 379) aline @joins 03 $+ $timestamp * Modes:01 $6-
elseif ($numeric == 671) aline @joins 03 $+ $timestamp * Secure Connection:01 Yes
}
#getinfo end

;menu for joinswindow
menu @joins {
clear window:/clear @joins
clear listbox:/clear -l @joins
clean listbox:/clean_joins
$iif($$1, get info):/getinfo $$1
$iif($$1, del user):/dline -l @joins $fline(@joins,$$1,1,1)
}

;menu for checking an users previous nicks in a channel
menu nicklist {
Previous nicks:/prevnicks $$1
}

Re: I need help [Re: NiKaN] #268037 08/11/20 02:36 AM
Joined: Jan 2004
Posts: 1,437
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,437
what do you mean by "it is causing"? Do you mean you want the script completely re-coded to enable support across multiple networks at the same time, or there's some other kind of backwards compatibility error?

If you want it to support multiple networks, you need to be more specific. Should it put all network traffic into 1 set of windows, or have a separate group of windows for each network?

Re: I need help [Re: maroon] #268040 08/11/20 02:45 PM
Joined: Nov 2020
Posts: 3
N
NiKaN Offline OP
Self-satisfied door
OP Offline
Self-satisfied door
N
Joined: Nov 2020
Posts: 3
Originally Posted by maroon
what do you mean by "it is causing"? Do you mean you want the script completely re-coded to enable support across multiple networks at the same time, or there's some other kind of backwards compatibility error?

If you want it to support multiple networks, you need to be more specific. Should it put all network traffic into 1 set of windows, or have a separate group of windows for each network?






I want a separate window for each server.Causes freezes in the program.Can you make it more current and stable according to today's conditions?.Sorry again for my English and thank you very much for your help

Re: I need help [Re: NiKaN] #268041 08/11/20 06:48 PM
Joined: Jan 2004
Posts: 1,437
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,437
You say it makes you freeze, but making it work for more than 1 network would make it even slower. So is best to first find out why it freezes. Surely there's something out there like P&P https://mircscripts.net/1Vxgh which can do a lot of what you want.

First, before you make any changes to your script, be sure to copy it somewhere as a backup.

I did see one thing which is dumb, and is probably one of the causes of your freezes, assuming they happen at 10 seconds intervals. In your ON START event is the command:

.timerupdate 0 10 .scon 1 /update_joins

This causes your "update_joins" alias to run at 10 seconds FOREVER until there's a disconnect event on that server causing the timer to stop, and it never restarts until you restart mirc. "update_joins" appears to add all nicks from all nicklists from all channels into the @join window, so your window will fill very quickly. If you are in channels where the nicklists have a combined 100 nicks, then this timer would add lines to @join at the rate of 600 per minute. Remove that timer command from the script, and instead replace it with something which adds 1 nicklist as you join 1 channel. In the script there is currently a line which says:

if ($nick == $me) { halt }

Replace that line with:

if ($nick == $me) { timer 1 1 fill_nicklist_into_joins $unsafe($chan) | return }

Then insert this next alias above the line ";fill the sidebar with online users"

Code
; fill sidebar with online users after YOU join it
alias fill_nicklist_into_joins {
  if ($network != %joins.network) return
  var %y $nick($1,0)
  while (%y) { aline -nl @joins $nick($1,%y) | dec %y }
}


I know this is still not efficient because it adds the same nick several times if they share several channels with you. I am just getting the most benefit quickly.

-

Now, let's see how large your joins hashtable and your nicks.txt file are. When you paste this command in the editbox, what is the result:

//echo -ag nicks.txt $lines(nicks.txt) joins $hget(joins,0).item

--

Next, let's benchmark how long it takes to handle 1 person joining 1 channel. On the line below "on ^*:join:#: {" insert the line:

var %time $ticks

Next, a few lines below "clonescanner" is a line that has "haltdef". Insert this next line as a new line above the "haltdef":

echo -s $scriptline debug: time to handle $nick join in $chan is: $calc($ticks - %time) ms

This will cause a message in status window each time someone joins. The message contains the line of the script, which helps you find it later when is time to delete it. If the debug message shows the number of milliseconds is too high, the most likely problem is reading from disk.

A few lines above "clonescanner" is a line which contains "$checknick($nick)". Let's see the time taken by that line by doing the following. Insert a line above and below that line, so that 1 line now looks like these 3 lines:

old:

aline -p @joins 03 $+ $timestamp * $1 $+ 's other nicknames:01 $checknick($1)

new:

var %diskread $ticks
aline -p @joins 03 $+ $timestamp * $1 $+ 's other nicknames:01 $checknick($1)
echo -s $scriptline debug: time to checknick $nick is: $calc($ticks - %diskread) ms

If you can identify other events that seem to cause the freeze, then you can add debug messages to show how long other portions of the code are taking.

--

I've not verified my next change, but it seems that alias "checknick" is very inefficient, because it performs duplicate disk reads in order to retrieve data that it already has. Reading from disk is slow, and writing to disk can be even slower. For example, the current "checknick" code begins by scanning nicks.txt for a string match. Then instead of the /return using that scanned string, the /return performs a 2nd scan. Later in "checknick", it scans the nicks.txt for a line containing a string, then it uses a write command which scans a 2nd time to find that same line. Then when it returns a string to the caller, it wastes time again by scanning the diskfile for the string it just wrote to disk. For the disk reads, I also added the 'nt' switches. Even when the disk file does not contain text to be evaluated as if it is code, those switches save a small amount of time by not hunting for it.

Save the next change below for last, after you have done the above, to see if they solve your freeze. I did not test this alias, but I believe it works. If it does not work correctly, you can remove this alias and the code will continue to use the old "checknick" alias.

Insert this next alias as a replacement for alias "checknick" by pasting this next alias *above* the existing checknick alias, which makes the existing code call my alias instead of the existing "checknick" alias.

Code
 ; substitute for alias checknick - delete or rename this alias if it does not work correctly
alias checknick {
  if ($1 isin $read(nicks.txt, nts, $address($1, 2))) { return $v2 }
  if (($read(nicks.txt, ntw, $address($1, 2) $+ *)) && ($1 !isin $read(nicks.txt, nts, $address($1, 2)))) {
  var %oldnicks $v2
  write -l $readn nicks.txt $address($1, 2) %oldnicks $+ , $1
  return %oldnicks $+ , $1
 }
  write nicks.txt $address($1, 2) $1
  return $1
}

Re: I need help [Re: maroon] #268045 09/11/20 07:13 AM
Joined: Nov 2020
Posts: 3
N
NiKaN Offline OP
Self-satisfied door
OP Offline
Self-satisfied door
N
Joined: Nov 2020
Posts: 3
Thank you for your help, but as I said, I have a mediocre English, and I don't know enough about mirc scripts.According to your instructions, it's going to take me a long time to do that.
I need to find a friend who will know this regularly it's hard to understand with this google translation.many thank you for your help