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.
Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
-
rabanne
- Voice
- Posts: 4
- Joined: Thu Jul 30, 2009 6:13 am
- Location: Sofia, Bulgaria
-
Contact:
Post
by rabanne »
Hello. Can I do this TCL to show only the lastest 20 lines that are written in the channel?
Code: Select all
set chat_setting(chan) "#Channel"
set chat_setting(file) "/home/ircd/www/radio/chat.html"
set chat_setting(temp) "/home/ircd/www/radio/chat.tmp"
if {![file exists $chat_setting(file)]} {
set filehand [open $chat_setting(file) w]
puts -nonewline $filehand ""
close $filehand
}
bind pubm - * chat_update
proc chat_update {nick uhost hand chan text} {
global chat_setting
if {![string match "* [string tolower $chan ]*" "l [string tolower $chat_setting(chan)] l"]} {
return 0
}
set time [clock format [clock seconds] -format "(%H:%M:%S\)"]
set date [clock format [clock seconds] -format {%d %B %Y}]
set text_nick "($nick)"
set text_form "<b>($date) $time text_nick</b> $text<BR>"
chat_file $text_form
return 0
}
proc chat_file {text} {
global chat_setting
set filehand [open $chat_setting(file) r]
set filehandtemp [open $chat_setting(temp) w]
set linenum 0
while {![eof $filehand]} {
set line [gets $filehand]
set lines [incr linenum]
puts $filehandtemp "$line"
}
puts -nonewline $filehandtemp "$text"
close $filehand
close $filehandtemp
file rename -force $chat_setting(temp) $chat_setting(file)
}
putlog "Инсталиран: WebChat.tcl"
Last edited by
rabanne on Tue Aug 04, 2009 11:29 am, edited 1 time in total.
-
tomekk
- Master
- Posts: 255
- Joined: Fri Nov 28, 2008 11:35 am
- Location: Oswiecim / Poland
-
Contact:
Post
by tomekk »
try:
Code: Select all
set chat_setting(chan) "#kupa"
set chat_setting(file) "/home/www/chat.html"
set chat_setting(temp) "/home/www/chat.tmp"
if {![file exists $chat_setting(file)]} {
set filehand [open $chat_setting(file) w]
puts -nonewline $filehand ""
close $filehand
}
bind pubm - * chat_update
proc chat_update {nick uhost hand chan text} {
global chat_setting
if {![string match "* [string tolower $chan ]*" "l [string tolower $chat_setting(chan)] l"]} {
return 0
}
set time [clock format [clock seconds] -format "(%H:%M:%S\)"]
set date [clock format [clock seconds] -format {%d %B %Y}]
set text_nick "($nick)"
set text_form "<b>($date) $time text_nick</b> $text<BR>"
chat_file $text_form
return 0
}
proc chat_file {text} {
global chat_setting
set filehand [open $chat_setting(file) r]
set filehandtemp [open $chat_setting(temp) w]
# set linenum 0
# while {![eof $filehand]} {
# set line [gets $filehand]
# set lines [incr linenum]
# puts $filehandtemp "$line"
# }
set last_lines [join [lrange [split [read $filehand] "\n"] end-18 end] "\n"]
puts $filehandtemp $last_lines
puts -nonewline $filehandtemp "$text"
close $filehand
close $filehandtemp
file rename -force $chat_setting(temp) $chat_setting(file)
}
putlog "Инсталиран: WebChat.tcl"
-
rabanne
- Voice
- Posts: 4
- Joined: Thu Jul 30, 2009 6:13 am
- Location: Sofia, Bulgaria
-
Contact:
Post
by rabanne »
Ten q ;>
Working Perfectly
...And if you want the last 30 lines should be
set last_lines [join [lrange [split [read $filehand] "\n"] end-28 end] "\n"] ?
for 40
set last_lines [join [lrange [split [read $filehand] "\n"] end-38 end] "\n"] .... etc
How can I make a site to see the numbers of rows? etc:
1. (date) (time) (nick) (text)
2. (date) (time) (nick) (text)
-
tomekk
- Master
- Posts: 255
- Joined: Fri Nov 28, 2008 11:35 am
- Location: Oswiecim / Poland
-
Contact:
Post
by tomekk »
try:
Code: Select all
# channel
set irc_chan "#channel"
# html file
set channel_file "/home/www/chat.html"
# max lines number
set output_lines 20
##################################################33
bind pubm -|- "*" log_channel
if {![file exists $channel_file]} {
set create_new [open $channel_file w]
close $create_new
}
proc log_channel { nick uhost hand chan text } {
global irc_chan channel_file output_lines
if {$irc_chan != $chan} {
return
}
set log_time [clock format [clock seconds] -format "%H:%M:%S"]
set log_date [clock format [clock seconds] -format "%d %B %Y"]
set log_line "<b>($log_date) ($log_time) ($nick) ($text)</b><br>"
set read_current [open $channel_file r]
set get_all [split [read $read_current] "\n"]
close $read_current
lappend get_all $log_line
set get_all [lrange $get_all end-$output_lines end]
set line_idx 1
set rewrite [open $channel_file w]
foreach each_line $get_all {
if {$each_line != ""} {
regsub {^[0-9]+\. } $each_line "" each_line
puts $rewrite "$line_idx\. $each_line"
incr line_idx 1
}
}
close $rewrite
}
putlog "html-chan-log.tcl"
-
rabanne
- Voice
- Posts: 4
- Joined: Thu Jul 30, 2009 6:13 am
- Location: Sofia, Bulgaria
-
Contact:
Post
by rabanne »
You are number one !
