This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Channel user scan

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
F
Football
Master
Posts: 205
Joined: Fri Dec 26, 2008 3:08 pm
Location: Quakenet, #Football

Channel user scan

Post by Football »

A script that on a private message, will scan all of the users in a certain channel and will Sumarrize how many users are on which channel and will calculate how much % it is from the total users on the channel
I.e:
if you have 100 users on #EPL
!Scan #EPL
<BOT> 20 Users on #Manutd (20%), 19 users on #Hello (19%), 6 users on !tyrin (6%), 1 user on #magaster, #you and #morning (%1 each). total users: 100.

Anyone?
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

If I'm reading this right, your script requests are getting increasingly absurd.

To get the IRC channels that a user is on, a network /whois <user> is sent and the bot captures and inteprets the raw 319 response. To scan a channel of 100 users would require 100 network /whois to be sent pretty much in rapid succession. It's beginning to look like an akill for the bot.
I must have had nothing to do
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

IF the request is slightly modified to only cover channels your eggdrop is currently a channel member of, this could be feasible. Otherwise, in extent of what arfer pointed out, you'd also have issues with private/secret channels and invisible users.
NML_375
F
Football
Master
Posts: 205
Joined: Fri Dec 26, 2008 3:08 pm
Location: Quakenet, #Football

Post by Football »

what if it /whois someone when he joins, records it, and output the records when you request?
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Well first off, users don't stay on the same channels. Secondly, you would have to employ a significant delay before sending the network /whois to enable the user to join ALL their channels. In addition you would really have to manage users parting/quitting/splitting if you wish to maintain an array containing users/channels. Thirdly, if many users join as in a flood then you are back to multiple network /whois requests and the risk of an akill. So, overall, I'm afraid it's an unreasonable request.

nml375 is correct in pointing out that it is feasible if you limit the script to bot channels. That would involve simple Eggdrop Tcl commands rather than a network /whois per each user.

Code: Select all

# requires in the partyline .chanset #channelname +scanchan
# syntax !scanchan

setudef flag scanchan

bind PUB - !scanchan pScanchanCommand

proc pScanchanCommand {nick uhost hand channel txt} {
  if {[channel get $channel scanchan]} {
    if {[llength [split [string trim $txt]]] == 0} {
      if {[llength [channels]] > 1} {
        foreach usr [chanlist $channel] {
          foreach chn [channels] {
            if {(![string equal -nocase $chn $channel]) && (![isbotnick $usr])} {
              if {[lsearch -exact [chanlist $chn] $usr] != -1} {
                if {[info exists users($chn)]} {incr users($chn)} else {set users($chn) 1}
              }
            }
          }
        }
        if {[array size users] != 0} {
          set total 0
          foreach {name value} [array get users] {
            incr total $value
            set percent [format %.2f [expr {(double($value) / ([llength [chanlist $channel]] - 1)) * 100.0}]]
            lappend output \00312$name\003 $value (\00314$percent\%\003),
          }
          putserv "PRIVMSG $channel :[join $output] \002TOTAL\002 hits $total"
        } else {putserv "PRIVMSG $channel :\00304error\003 (\00314$nick\003) - none of the users in this channel were found in my other channels"}
      } else {putserv "PRIVMSG $channel :\00304error\003 (\00314$nick\003) - this is the only channel I am monitoring"}
    } else {putserv "PRIVMSG $channel :\00304error\003 (\00314$nick\003) - correct syntax is !scanchan without additional arguments"}
  }
  return 0
}
Image

The math excludes the bot itself, since it is almost certain to be on channels it has a channel record for. The individual percentage values are obviously not additive.

The example above indicates that one user in #eggTCL (the command channel) besides the bot itself (osmosis) is also in #Gigglers, and similarly three users in #Atlantis.

Do not use the command too quickly after the bot joins the command source channel, since it has to receive the network /who list for all its channels first.
Last edited by arfer on Mon Mar 09, 2009 4:40 pm, edited 1 time in total.
I must have had nothing to do
F
Football
Master
Posts: 205
Joined: Fri Dec 26, 2008 3:08 pm
Location: Quakenet, #Football

Post by Football »

thanks arfer, very useful script.
only 3 problems though, if it's on too many channels it doesn't write them all since it's trying to write them in 1 message.
And second, if possible, that it won't count Q (Quakenet's service bot), in the count?

and 3rd:

#ChelseaFC (14.6666666667%)
I think writing 14.6% is enough ;)

Thanks!
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

I would say it will easily deal with 20 channels, at least on DALnet. Thereafter it depends on the maximum number of characters the network permits per single output. If it gets to be too much then the output would have to be split. Surely you dont have the bot on more than 20 channels?

It deals with ALL users in the command source channel besides itself but I must admit I have no knowledge of quakenet.

I edited the script I posted to ensure percentage values are always to 2dp only. Copy it again if you are testing it.

LOL! useful?
I must have had nothing to do
Post Reply