egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Displaying the number of users on channels, in a webpage.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Exedore
Halfop


Joined: 27 Jan 2008
Posts: 43

PostPosted: Sat Jul 10, 2010 3:24 am    Post subject: Displaying the number of users on channels, in a webpage. Reply with quote

Hi, I'm looking for a TCL that do this:
Code:
#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.
Back to top
View user's profile Send private message
username
Op


Joined: 06 Oct 2005
Posts: 196
Location: Russian Federation, Podolsk

PostPosted: Sat Jul 10, 2010 8:09 am    Post subject: Reply with quote

Try it:
Code:
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
}

_________________
Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/


Last edited by username on Fri Jul 16, 2010 1:53 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Exedore
Halfop


Joined: 27 Jan 2008
Posts: 43

PostPosted: Fri Jul 16, 2010 12:54 am    Post subject: Reply with quote

Not works Crying or Very sad
Back to top
View user's profile Send private message
Exedore
Halfop


Joined: 27 Jan 2008
Posts: 43

PostPosted: Fri Jul 16, 2010 12:56 am    Post subject: Reply with quote

I've changed the bind section with
Code:
bind time - "5 * * * *" web_users

I don't know if its ok. And my folder path..
Code:
/home/my-username/eggdrop/webusers/users.html
Back to top
View user's profile Send private message
username
Op


Joined: 06 Oct 2005
Posts: 196
Location: Russian Federation, Podolsk

PostPosted: Fri Jul 16, 2010 1:55 am    Post subject: Reply with quote

I've edit my code, try it. It works for me: http://egghelp.ru/123/web_users.html
_________________
Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Exedore
Halfop


Joined: 27 Jan 2008
Posts: 43

PostPosted: Fri Jul 16, 2010 5:26 am    Post subject: Reply with quote

working partially...
it displays the first 2 channel with 0 users, when this channels have 80 each..
Code:
#sun: 0 users (must be 80)
#uruguay: 0 users (must be 83)
#linux: 19 users
#yuyos: 5 users
#friends: 17 users
Back to top
View user's profile Send private message
username
Op


Joined: 06 Oct 2005
Posts: 196
Location: Russian Federation, Podolsk

PostPosted: Fri Jul 16, 2010 8:34 am    Post subject: Reply with quote

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/1.6.20/tcl-commands.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/
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Exedore
Halfop


Joined: 27 Jan 2008
Posts: 43

PostPosted: Mon Jul 19, 2010 6:50 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
rayvtirx
Voice


Joined: 31 May 2010
Posts: 16
Location: bristol,england

PostPosted: Mon Apr 11, 2011 5:42 pm    Post subject: Reply with quote

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)?
Back to top
View user's profile Send private message Visit poster's website
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Mon Apr 11, 2011 8:23 pm    Post subject: Reply with quote

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. Smile
Back to top
View user's profile Send private message
rayvtirx
Voice


Joined: 31 May 2010
Posts: 16
Location: bristol,england

PostPosted: Tue Apr 12, 2011 4:57 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Tue Apr 12, 2011 1:12 pm    Post subject: Reply with quote

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:

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.
Back to top
View user's profile Send private message
rayvtirx
Voice


Joined: 31 May 2010
Posts: 16
Location: bristol,england

PostPosted: Tue Apr 12, 2011 1:25 pm    Post subject: Reply with quote

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:
[chanlist #AirfixDogfighter]] - 1 ]"
-1 at the end is to remove the bots count from the user_count
thank you very much willyw Very Happy
edit:
i stopped by your channel agin and asked but noone seemed to know
ive tried this
Code:
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)
Back to top
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Apr 13, 2011 4:19 am    Post subject: Reply with quote

Quote:

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:


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:

[lsearch -nocase $webusers(exclude) $nick] == -1

you could use:
Code:

[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:
Quote:

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:
Quote:

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. Rolling Eyes
_________________
Once the game is over, the king and the pawn go back in the same box.


Last edited by caesar on Wed Apr 13, 2011 2:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Wed Apr 13, 2011 9:18 am    Post subject: Reply with quote

rayvtirx wrote:

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

...

ive tried this
Code:

        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/1.6.20/tcl-commands.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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber