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.

Displaying the number of users on channels, in a webpage.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
Exedore
Halfop
Posts: 43
Joined: Sun Jan 27, 2008 10:04 pm

Displaying the number of users on channels, in a webpage.

Post by Exedore »

Hi, I'm looking for a TCL that do this:

Code: Select all

#Channel-A 56 users
#Channel-B 191 users
#Channel-C 44 users
#Channel-D 19 users
#Channel-E 26 users
#Channel-F 74 users
#Channel-G 122 users
#Channel-H 16 users
#Channel-I 37 users
And put this info within a website.
Any help?

Thanks to all.
User avatar
username
Op
Posts: 196
Joined: Thu Oct 06, 2005 9:20 am
Location: Russian Federation, Podolsk
Contact:

Post by username »

Try it:

Code: Select all

bind time - "* * * * *" web_users

# Path to save html page.
set webusers_file "/var/www/123/web_users.html"

proc web_users {min hour day month year} {
global webusers_file
    if {[file exists "$webusers_file"]} {
        set fh [open "$webusers_file" "a+"]
    }
    set fh [open "$webusers_file" "w+"]
    puts $fh "<HTML><HEAD><TITLE>Total users</TITLE></HEAD>"
    puts $fh "<BODY>"
    foreach chan [channels] {
        set users [chanlist $chan]
        puts $fh "$chan: [llength $users] users<BR />"
    }
puts $fh "</BODY></HTML>"
close $fh
}
Last edited by username on Fri Jul 16, 2010 1:53 am, edited 1 time in total.
Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/
User avatar
Exedore
Halfop
Posts: 43
Joined: Sun Jan 27, 2008 10:04 pm

Post by Exedore »

Not works :cry:
User avatar
Exedore
Halfop
Posts: 43
Joined: Sun Jan 27, 2008 10:04 pm

Post by Exedore »

I've changed the bind section with

Code: Select all

bind time - "5 * * * *" web_users
I don't know if its ok. And my folder path..

Code: Select all

/home/my-username/eggdrop/webusers/users.html
User avatar
username
Op
Posts: 196
Joined: Thu Oct 06, 2005 9:20 am
Location: Russian Federation, Podolsk
Contact:

Post by username »

I've edit my code, try it. It works for me: http://egghelp.ru/123/web_users.html
Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/
User avatar
Exedore
Halfop
Posts: 43
Joined: Sun Jan 27, 2008 10:04 pm

Post by Exedore »

working partially...
it displays the first 2 channel with 0 users, when this channels have 80 each..

Code: Select all

#sun: 0 users (must be 80)
#uruguay: 0 users (must be 83)
#linux: 19 users
#yuyos: 5 users
#friends: 17 users
User avatar
username
Op
Posts: 196
Joined: Thu Oct 06, 2005 9:20 am
Location: Russian Federation, Podolsk
Contact:

Post by username »

Thats very strange, because to count users I use statdart Eggdrop command chanlist, you can read about it here: http://www.eggheads.org/support/egghtml ... mands.html
I dont know why there is 0 users. Try in your partyline this command: .tcl [llength chanlist #sun]
Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/
User avatar
Exedore
Halfop
Posts: 43
Joined: Sun Jan 27, 2008 10:04 pm

Post by Exedore »

Definitely works partially. I don't know if it has to do with my core (freebsd).
Anyway. I Apreciate your help, username.
Thanks for all.
r
rayvtirx
Voice
Posts: 16
Joined: Mon May 31, 2010 9:35 am
Location: bristol,england
Contact:

Post by rayvtirx »

Works Great!
does exactly what it says on the packet - Thanks
http://irc.mattwillett.co.uk/web_users.html
takes a couple of minutes to update but exactley what i wanted so i can show the number of users in chat on a forum.
any way i could get the nicks of the users in the channel or channels?
and probably asking a bit much now - but perhaps a way to exclude the count of certain nicks ( a bot for example)?
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

rayvtirx wrote: ...
any way i could get the nicks of the users in the channel or channels?
and probably asking a bit much now - but perhaps a way to exclude the count of certain nicks ( a bot for example)?
You reminded me of:
http://www.kreativrauschen.com/stats.mod/

I don't know if it will fit with what you are doing, but it makes a "live" display. Nicks listed, etc.

Check your messages here, for a link so you can see it online. :)
r
rayvtirx
Voice
Posts: 16
Joined: Mon May 31, 2010 9:35 am
Location: bristol,england
Contact:

Post by rayvtirx »

thanks for your help
i have used livestats before but its a bit too much information for what i want
really all i need is a couple of text files produced one with the number of users in it and another with the usernames, so i can include the number/names as a tooltip, or next to, a link in our forum. the code above i can easily change to just write a number, i can remove the bot from all but the #AirfixDogfighter channel. but the number will always include the bot - i could just -1 it in php . the usernames was me asking if there was another kind of a string like the users one in the script that gets the usernames , again i could just preg_replace out the bots name
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

rayvtirx wrote: ...
really all i need is a couple of text files produced one with the number of users in it and another with the usernames,
...
i can remove the bot from all but the #AirfixDogfighter channel. but the number will always include the bot - i could just -1 it in php . the usernames was me asking if there was another kind of a string like the users one in the script that gets the usernames , again i could just preg_replace out the bots name

For anyone following along:
We've chatted live online, and done some testing with his bot.
Below is one version of what we were working with.

Code: Select all

bind time - "* * * * *" web_users

# Path to save text files.
set webusers_file "you/need/to/edit/this/path/web_users.txt"
set webusers_count_file "you/need/to/edit/this/path/web_users_count.txt"

proc web_users {min hour day month year} {
global webusers_file webusers_count_file botnick
    
    set fh [open "$webusers_file" "w+"]
        
        set nicklist "[chanlist #AirfixDogfighter]"

	    set i "0"
	    foreach nick $nicklist {

            if {"$nick" == "$botnick"} {
                set newnicklist [lreplace $nicklist $i $i ]
               }
            incr i
           }
          puts $fh [join $newnicklist ", " ]
         close $fh




	set fh [open "$webusers_count_file" "w+"]

        puts $fh "[expr [llength [chanlist #AirfixDogfighter]] - 1 ]"
 
	close $fh

} 


Then, he does some magic with his web page, using the info in the files made by the bot, and makes a very slick looking little pop up (or whatever it is called), when you hover your mouse on his web page.
r
rayvtirx
Voice
Posts: 16
Joined: Mon May 31, 2010 9:35 am
Location: bristol,england
Contact:

Post by rayvtirx »

lol its just a tooltip
but this was exactley what ive been after on a few occasions
the nick list excludes the nicknames of bots and the

Code: Select all

[chanlist #AirfixDogfighter]] - 1 ]" 
-1 at the end is to remove the bots count from the user_count
thank you very much willyw :D
edit:
i stopped by your channel agin and asked but noone seemed to know
ive tried this

Code: Select all

bind time - "* * * * *" web_users

# Path to save text files.
set webusers_file "you/need/to/edit/this/path/web_users.txt"
set webusers_count_file "you/need/to/edit/this/path/web_users_count.txt"

proc web_users {min hour day month year} {
global webusers_file webusers_count_file botnick
   
    set fh [open "$webusers_file" "w+"]
       
        set nicklist "[chanlist #AirfixDogfighter]"

       set i "0"
       set b "0"
       foreach nick $nicklist {

            if {"$nick" == "$botnick"} {
                set newnicklist [lreplace $nicklist $i $i ]
             incr b
               }
            incr i
           }
          puts $fh [join $newnicklist ", " ]
         close $fh




   set fh [open "$webusers_count_file" "w+"]

        puts $fh "[expr [llength [chanlist #AirfixDogfighter]] - $b ]"
 
   close $fh

} 
with the intention that it automatically ignore bots in the count_file
It seems to work (though i only rehashed the bot)
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

if {"$nick" == "$botnick"} {
you should use the 'isbonick' function instead, or at least either 'string tolower' both variables or 'string equal -nocase' them.

Here's my version of the code to exclude from the list:

Code: Select all


bind time - "* * * * *" time:webusers

# Path to save text files.
set webusers(file) "you/need/to/edit/this/path/web_users.txt"
set webusers(count_file) "you/need/to/edit/this/path/web_users_count.txt" 
set webusers(exclude) "bot1 bot2 bot3 user1 user2" 

proc time:webusers {min hour day month year} {
  global webusers
  set i 0
  foreach nick [chanlist #AirfixDogfighter] {
    if {[isbotnick $nick] || [lsearch -nocase $webusers(exclude) $nick] == -1} continue
    lappend nicklist $nick
    incr i
  }
  set fh [open $webusers(file) "w"]
  puts $fh [join $nicklist ", "]
  close $fh

  set fh [open $webusers(count_file) "w"]
  puts $fh "$i"
  close $fh
}
Eventually, instead of

Code: Select all

[lsearch -nocase $webusers(exclude) $nick] == -1
you could use:

Code: Select all

[matchattr [nick2hand $nick] bf #AirfixDogfighter]
to exclude all users that have the b or f flag, or whatever you wish for that specific channel or some global flags.

@username : When opening a file with a+ it will:
Open the file for reading and writing. If the file does not exist, create a new empty file. Set the initial access position to the end of the file.
thus no need for:
if {[file exists "$webusers_file"]} {
set fh [open "$webusers_file" "a+"]
}
set fh [open "$webusers_file" "w+"]
not to mention that you open a file and forgot to close it before opening it again.

Edit: fixed typo. :roll:
Last edited by caesar on Wed Apr 13, 2011 2:26 pm, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

rayvtirx wrote: ...
edit:
i stopped by your channel agin and asked but noone seemed to know

...

ive tried this

Code: Select all

        puts $fh "[expr [llength [chanlist #AirfixDogfighter]] - $b ]"
 
   close $fh

} 
with the intention that it automatically ignore bots in the count_file
It seems to work (though i only rehashed the bot)
I think I understand what you really want... for the script to examine each of the users currently in the channel, and some how be able to determine if a given user is a bot, or not.

That's interesting.

It becomes a case of, "What are we looking for, and how to we find it?",
when examining whatever characteristics are available to us, for each user in the channel.

Not sure what is the best way to go about it. We'll have to talk a bit more and think about it. ( Have we gotten too far away from the original topic?... should you start another thread? )

Regarding the variable you've introduced - $b - I don't believe that will work, as-is. To accomplish what I believe to be your goal, is not that simple.
There is only going to be one time that
if {"$nick" == "$botnick"}
is true.
Go here: http://www.eggheads.org/support/egghtml ... mands.html
and find the section:
10. Global variables
and see the defintion of botnick for perhaps a clearer explanation of it than I gave you.
Post Reply