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.

Problem nick list html

Help for those learning Tcl or writing their own scripts.
Post Reply
l
loulou7593
Voice
Posts: 12
Joined: Tue Apr 08, 2008 12:52 pm

Problem nick list html

Post by loulou7593 »

Hello all

I would like a tcl to create a nick list in a file HTML
here what I have

Code: Select all

###################################
########### nick list ###########
###################################

set canal "#accueil"
set fsource "/home/loulou/liste.tpl"
set fichier "/home/loulou/public_html/liste.html"

bind join - "$canal *" list:join
bind part - "$canal *" list:part
bind sign - "$canal *" list:quit

proc list:join {nick uhost handle chan} { list:log; }
proc list:part {nick uhost handle chan text} {
    if {$nick != $::botnick} { list:log; }
}
proc list:quit {nick uhost handle chan text} {
    if {$nick != $::botnick} { list:log; }
}

proc list:log {} {
   set ::u(op) {}
   set ::u(hop) {}
   set ::u(vop) {}
   set ::u(nop) {}
   set ::count 0
    foreach cnick [chanlist $::canal] {
        if { $cnick == $::botnick } { continue; }
        incr ::count
        if { [isop $cnick $::canal] == 1 } {
            lappend ::u(op) $cnick
        } elseif { [ishalfop $cnick $::canal] == 1 } {
            lappend ::u(hop) $cnick
        } elseif { [isvoice $cnick $::canal] == 1 } {
            lappend ::u(vop) $cnick
        } else {
            lappend ::v(op) $cnick
        }
    }
    save:log
}

proc save:log {} {
   set fp [open $::fichier w]
   set fi [open $::fsource r]
   set tpl [read $fi -nonewline $fi]
   close $fi
   $ulist = ""
   foreach nick $::u(op) {
       append $ulist "<tr><td style='color:red;'>@$nick</td></tr>\n"
   }
   foreach nick $::u(hop) {
      append $ulist "<tr><td style='color:blue;'>%$nick</td></tr>\n"
   }
   foreach nick $::u(vop) {
      append $ulist "<tr><td style='color:yellow;'>+$nick</td></tr>\n"
   }
   foreach nick $::u(nop) {
      append $ulist "<tr><td style='color:green;'>$nick</td></tr>\n"
   }
   regsub -all %count $tpl $::count tpl
   regsub -all %channel $tpl $::canal tpl
   regsub -all %list $tpl $ulist tpl
   fputs $fp $tpl
   close $fp
}
and the file template to be put in /home/loulou/liste.tpl

Code: Select all

<html>
<head>
<title>Les %count connectés sur %channel</title>
<style>body { background-color: black; }</style>
</head>
<body>
<table>
    <tr><th>Il y a %count personnes sur %channel</th></tr>
    %list
</table>
</body>
</html>
that should create me a file HTML with the names of the members color with a bottom of black screen

but I have this error in partyline

Code: Select all

 Tcl error [list:join]: wrong # args: should be "read channelId ?numChars?" or "read ?-nonewline? channelId"
somebody can help me please ??
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

You've got an extra argument on the third line in save:log:

Code: Select all

set tpl [read $fi -nonewline $fi]
I'm not sure if you need the -nonewline option, in any case the line should be one of the below (depending on whether you do need the -nonewline option)

Code: Select all

set tpl [read $fi]
or

Code: Select all

set tpl [read -nonewline $fi]
NML_375
l
loulou7593
Voice
Posts: 12
Joined: Tue Apr 08, 2008 12:52 pm

Post by loulou7593 »

I thus tested with the two codes

Code: Select all

set tpl [read $fi]
and

Code: Select all

set tpl [read -nonewline $fi]
and I have this error in partyline now

Code: Select all

Tcl error [list:join]: can't read "ulist": no such variable
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

That would be this line (in save:log):

Code: Select all

$ulist = ""
That is not the proper syntax for setting variables in tcl; the proper way is like follows:

Code: Select all

set ulist ""
Checking further, there are several other, similar issues, such as this one:

Code: Select all

append $ulist "<tr><td style='color:red;'>@$nick</td></tr>\n"
You don't want to do a variable substitution on ulist here, so don't prefix the variable name with $:

Code: Select all

append ulist "<tr><td style='color:red;'>@$nick</td></tr>\n"
The same applies to other similar lines.

Further, comparing nicknames with ::botnick is not the best way to check if it's the bot itself or not, as it's a case-sensitive match. Instead, use the isbotnick command.

Code: Select all

if {$nick != $::botnick} {...
Would be

Code: Select all

if {![isbotnick $nick]} {...
NML_375
l
loulou7593
Voice
Posts: 12
Joined: Tue Apr 08, 2008 12:52 pm

Post by loulou7593 »

thank you nml375

it is impeccable :)

I would like to know if it is possible to integrate a table around the pseudos ?

but the problem is that basic one does not know the number of pseudos connected. Thus how to define a table?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I'm sorry, but I have no idea whatsoever what you are talking about with "psuedos". As for table, if you are talking 'bout a html-table, your current code should already be creating a table with nicknames.
NML_375
l
loulou7593
Voice
Posts: 12
Joined: Tue Apr 08, 2008 12:52 pm

Post by loulou7593 »

afflicted I am French and my English is not very good lol

pseudo = nick

look at this page, it is currently what the code of front gives me http://loulou.hosting-free.be/liste.html

I would like to know if it is possible to have the people who are connected in a table?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

I just checked the source, and all the nicknames are in a table, one table row for each nick. If you are looking for some table borders, I suggest you setup the proper CSS for it.
NML_375
l
loulou7593
Voice
Posts: 12
Joined: Tue Apr 08, 2008 12:52 pm

Post by loulou7593 »

here what I would like to do

Image[/img]
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

As I said, add the proper CSS to your html document.

http://www.w3schools.com/css/css_table.asp might be a good start.
NML_375
l
loulou7593
Voice
Posts: 12
Joined: Tue Apr 08, 2008 12:52 pm

Post by loulou7593 »

ah ok sorry I had not included/understood. I will look at page Internet
l
loulou7593
Voice
Posts: 12
Joined: Tue Apr 08, 2008 12:52 pm

Post by loulou7593 »

Hello,

I think that there are minor problems because when a person join Channel that immediately does not write the name of the person in the file, on the other hand the meter works well.

Example:
on Chanel there are already the following people.
Niubot40
Ludo

the page indicates 2 people on the channel, but she writes that only one person on the page.

then if Cindy75 join the channel, the page indicates 3 people on the channel, but there is always that the name of only one person written on the page.

and only if another person join the channel, there the page indicates 4 people on the channel and she writes the name of 2 people. The name of the 2 first people who were already on the channel.

I think that the meter of people functions, but that there is a problem for the writing of the names of the people when it join, part or quit the channel.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Your problem lies in the list:log proc

Code: Select all

else {
            lappend ::v(op) $cnick
        } 
probably just a typo, but I am guessing it should be:

Code: Select all

else {
            lappend ::u(nop) $cnick
        }
you were in fact putting all the people not voice, halfop or op into a list which were never used.
Elen sila lúmenn' omentielvo
l
loulou7593
Voice
Posts: 12
Joined: Tue Apr 08, 2008 12:52 pm

Post by loulou7593 »

Hello

I would have liked to know if somebody could help me to make the same thing but for two channels?

There that functions well for the channel #accueil, but I would like that makes me also a list for the channel #game

As that I could have the list of the two channels on the same page
Post Reply