mIRC Homepage
Posted By: anarres mass whois - 10/04/05 08:40 AM
Hy again :tongue:

I want to make in a remotes a mass whois when type !whois in a channel, of course with a timer or something like that to not disconect for flood.
Also I just want to know if there is a way to put in order a .txt file: I save a list of nick and it's uptime in the server, but I want then to put in order the numbrers (as in excel) for sending then the 4 nicks with more uptime. I think that I'ts impossible.

Thanx
Posted By: RusselB Re: mass whois - 10/04/05 11:20 AM
I make no guarantees, but I think this should work. I put it on my bot for testing purposes and didn't notice any problems.
Only thing that I can think of that might cause inaccurate results is if two (or more) people have the same amount of uptime

Code:
 on *:text:!whois:#:{
  var %a = 1
  while %a <= $nick(#,0) {
    .enable #scan
    whois $nick(#,%a)
    inc %a
  }
  set %uptime $sort(%uptime,32,n)
  var %a = 1
  while %a <= $numtok(%uptime) {
    set %nick $addtok(%nick,$hfind(uptime,$gettok(%uptime,%a,32),1),32)
    if %a < 5 .write -s $+ $nick uptime.txt $nick $gettok(%uptime,%a,32)
    inc %a
  }
}

#scan off
raw 317:*:{
  hadd -m uptime $nick(#,%a) $calc($ctime - $4)
  set %uptime = $addtok(%uptime,$calc($ctime - $4),32)
}
 
Posted By: anarres Re: mass whois - 10/04/05 02:09 PM
UH,

It doens't work, It makes the masswhois (without timer) and nothing else. It doesn't make any .txt file. If I do it in a channel with 50 or more users I fall for Flood.

Thanx
Posted By: RusselB Re: mass whois - 10/04/05 03:29 PM
Code:
on *:text:!whois:#:{
  var %a = 1
  while %a <= $nick(#,0) {
    .enable #scan
    whois $nick(#,%a)
.timer 1 2    inc %a
  }
  set %uptime $sort(%uptime,32,n)
  var %a = 1
  while %a <= $numtok(%uptime) {
    set %nick $addtok(%nick,$hfind(uptime,$gettok(%uptime,%a,32),1),32)
    if %a < 5 { .write -s $+ $nick uptime.txt $nick $gettok(%uptime,%a,32) }
    inc %a
  }
}

#scan off
raw 317:*:{
  hadd -m uptime $nick(#,%a) $calc($ctime - $4)
  set %uptime = $addtok(%uptime,$calc($ctime - $4),32)
}
#scan end
 


oops...forgot about the timer..one is now included, and also noticed that I missed some brackets and the end command for the scan. I hope that'll work for you now
Posted By: SladeKraven Re: mass whois - 10/04/05 03:31 PM
Hey Russel, I think you mean $sorttok(%uptime,32,n). smile
Posted By: DaveC Re: mass whois - 10/04/05 05:45 PM
Sorry Russell but im sure that is just wrong in so many ways dude

on TEXT {
might as well use no #group (u never switch it off)
timer on wrong line (typo?) and if so timers are all fixed to go off in 2 seconds so you flood in two seconds instead
$sort used instead of $sorttok; if not its a custom alias you didnt define
%uptime is (currently) undefinded (below assumes it was set from a previous execution of the script)
uptime hash table is currenlty (below assumes it wasset from a previous execution of the script)
$hfind i think needs the $hfind().data property (might be wrong on this, but arent you checking the uptime values, the items are the nicks?)
You write to a file uptime.txt the following line " $nick $gettok(%uptime,1,32) " then replace that line with " $nick $gettok(%uptime,2,32) " up to 4
This is also the lowest 4 values not the highest (assuming $sorttok used)
Countinue to loop after %a > 4 (could be accepted as its creating a %nick list of nicks)

raw 317 {
$nick(#,%a) is undefined
set command has a =
used addtok so If 2 nicks return same uptime only one is recorded (as mentioned)

I would wrote something BUT i get no raw 317's on the irc server i use, so couldnt test it out
Code:
;
;Designed to be run on multiple channels but only one at any one time.
;
on *:input:#:{ if ($1- == !whois) { mass.whois $chan } }
on *:text:!whois:#:{ mass.whois $chan }
;
; $1 = $chan
alias mass.whois {
  if (!%mass.whois) {
    set $+(-u,$calc($nick($1,0) * 2 + 4)) %mass.whois $true
    .timer.mass.whois.result 1 $calc($nick($1,0) * 2 + 2) mass.whois.results $1
    var %i = $nick($1,0)
    while (%i) {
      .timer 1 $calc(%i * 2) whois $nick($1,%i)
      dec %i
    }
    set %uptime.top4
  }
}
;
;$2 = nick
;$4 = connect time?
raw 317:*:{ set %uptime.top4 $gettok($replace($gettok($sorttok($cr $cr $cr $cr %uptime.top4 $+($right($+(0000000000,$calc($ctime - $4)),10),@,$2),32),-4-,32),$cr,$chr(32)),1-,32) }
;
; $1 = $chan
; %uptime.top4 = 0000000001@nickA 0000000002@nickB 0000000003@nickC 0000000004@nickD (maybe less than 4 nicks total) 
alias mass.whois.results {
  set %uptime.top4.nicks
  set %uptime.top4.times
  var %i = $numtok(%uptime.top4,32)
  while (%i) {
    set %uptime.top4.times %uptime.top4.times $calc($gettok($gettok(%uptime.top4,%i,32),1,64))
    set %uptime.top4.nicks %uptime.top4.nicks $gettok($gettok(%uptime.top4,%i,32),2,64)
    dec %i
  }
  unset %uptime.top4
  echo -s Top 4 uptimes on $1 are %uptime.top4.times
  echo -s Top 4 uptime nicks on $1 are %uptime.top4.nicks
  ; ^ do what you well here
}
Posted By: anarres Re: mass whois - 11/04/05 08:06 PM
DaveC

Woooo, thanx a lot dude, it works fine smile

I just have a last question, it's defined the %uptime.top4.times as the all top 4 and %uptime.top4.nicks top nicks, but how take each one individually?
I want on a text 1 nick uptime | 2n nick uptime etc... but I don't find how to select each one. I hope you understand me, I'm not really good with english.
Thanx a lot
Posted By: DaveC Re: mass whois - 12/04/05 12:04 AM
Once you have made %uptime.top4.times & %uptime.top4.nicks you can use
1st place is $gettok(%uptime.top4.nicks,1,32) with a time of $gettok(%uptime.top4.times,1,32)
2nd place is $gettok(%uptime.top4.nicks,2,32) with a time of $gettok(%uptime.top4.times,2,32) seconds
3rd place is $gettok(%uptime.top4.nicks,3,32) with a time of $gettok(%uptime.top4.times,3,32) seconds
4th place is $gettok(%uptime.top4.nicks,4,32) with a time of $gettok(%uptime.top4.times,4,32) seconds

if thats to hard try

var %tmp = $1- | tokenize 32 %uptime.top4.nicks %uptime.top4.times
1st place is $1with a time of $5 seconds
2nd place is $2with a time of $6 seconds
3rd place is $3with a time of $7 seconds
4th place is $4with a time of $8 seconds
tokenize 32 %tmp

* The var & tokenize at the begining saves the $1- values then replaces $1- with the 4 names then there 4 times
* the tokenize at the end returns the old $1- back to what they were
Posted By: RusselB Re: mass whois - 12/04/05 12:32 AM
With the exception of the fact that I did mean $sorttok, rather than $sort (which was a typo)...the code I posted works for me, and that's what I was basing it on when I posted it.
Posted By: DaveC Re: mass whois - 12/04/05 01:43 AM
I bet it failed on the first attempt tho, then seemed to work ok after that?, its working becuase it was giving results based on the previous runnings gathering of info. which if testing is so close in time the results would seem correct, but placed out life might be run with hours between them, thus the results wouldnt match.
© mIRC Discussion Forums