| View previous topic :: View next topic |
| Author |
Message |
Football Master
Joined: 26 Dec 2008 Posts: 205 Location: Quakenet, #Football
|
Posted: Mon Mar 09, 2009 7:49 am Post subject: Channel user scan |
|
|
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? |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Mon Mar 09, 2009 10:07 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Mar 09, 2009 12:13 pm Post subject: |
|
|
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, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Football Master
Joined: 26 Dec 2008 Posts: 205 Location: Quakenet, #Football
|
Posted: Mon Mar 09, 2009 3:18 pm Post subject: |
|
|
| what if it /whois someone when he joins, records it, and output the records when you request? |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Mon Mar 09, 2009 4:27 pm Post subject: |
|
|
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: |
# 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
}
|
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. _________________ I must have had nothing to do
Last edited by arfer on Mon Mar 09, 2009 4:40 pm; edited 1 time in total |
|
| Back to top |
|
 |
Football Master
Joined: 26 Dec 2008 Posts: 205 Location: Quakenet, #Football
|
Posted: Mon Mar 09, 2009 4:36 pm Post subject: |
|
|
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! |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Mon Mar 09, 2009 4:46 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
|