namespace eval Chat { ### vars set debug 0 set develop 0 if {$::botnick=="Honecker" || $::botnick=="Berlin"} { set develop 0 } set major 0 set minor 3 if {![info exist build] || !$develop} { set build 107 } { incr build } if {![info exist run]} { set run 1 } { incr run } set ::lateststable 0.3.107 ### helper if {$::Chat::debug} { putcmdlog "Warning! Debug Mode ist \002ON\002!" } if {$::lateststable!="$major.$minor.$build"} { if $develop { putcmdlog "Warning! Developer Mode \002ON\002! Latest stable: $::lateststable" } { putcmdlog "Warning! Unstable Version! Latest stable: $::lateststable" } } setudef flag ChatLog set Path /home/berlin/tmp/.htDAT if { ![ info exist Lastlog ] } { array set Lastlog { } } proc Load { } { if [info exists $Chat::Path/Lastlog.dat] { #putcmdlog "Load" set fh [ open $Chat::Path/Lastlog.dat r ] set Chat::Lastlog(All) [gets $fh] close $fh } { set Chat::Lastlog(All) [ list ] } } proc Save { } { #putcmdlog "Save" set fh [ open $Chat::Path/Lastlog.dat w ] puts $fh $Chat::Lastlog(All) close $fh } proc LoadChannel { channel } { if { [ lsearch [ channel info $channel ] -ChatLog ]!=-1 } { return } if [info exists $Chat::Path/Lastlog.dat] { #putcmdlog "SaveChannel $channel" set fh [ open $Chat::Path/Lastlog.$channel.dat r ] set Chat::Lastlog($channel) [gets $fh] close $fh } else { set Chat::Lastlog($channel) [ list ] } } proc SaveChannel { channel } { if { [ lsearch [ channel info $channel ] -ChatLog ]!=-1 } { return } #putcmdlog "SaveChannel $channel" set fh [ open $Chat::Path/Lastlog.$channel.dat w ] puts $fh $Chat::Lastlog($channel) close $fh } proc NicklistChannel { channel } { if { [ lsearch [ channel info $channel ] -ChatLog ]!=-1 } { return } #putcmdlog "NicklistChannel $channel" set Nick [ list ]; set OP [ list ]; set Voice [ list ]; set nNick 0; set nOP 0; set nVoice 0; foreach User [ chanlist $channel ] { if [ isop $User $channel ] { lappend OP $User; incr nOP } elseif [ isvoice $User $channel ] { lappend Voice $User; incr nVoice } { lappend Nick $User; incr nNick } } set fh [ open $Chat::Path/Nicklist.$channel.dat w ] puts $fh [ lsort $OP ] puts $fh [ lsort $Voice ] puts $fh [ lsort $Nick ] if [info exists ::ModeD::onlinelist] { puts $fh [ lsort $::ModeD::onlinelist ] } close $fh #putcmdlog "$channel o [llength $OP] v [llength $Voice] u [llength $Nick] - o $nOP v $nVoice u $nNick" } proc TopicChannel { channel } { if { [ lsearch [ channel info $channel ] -ChatLog ]!=-1 } { return } #putcmdlog "TopicChannel $channel" set fh [ open $Chat::Path/Topic.$channel.dat w ] puts $fh [ topic $channel ] close $fh } proc Add { type channel nick { args "" } } { if { [ lsearch [ channel info $channel ] -ChatLog ]!=-1 } { return } #putcmdlog "Add $type in $channel from $nick" if { ![ info exist Chat::Lastlog(All) ] } { set Chat::Lastlog(All) [list]; Load } if { ![ info exist Chat::Lastlog($channel) ] } { set Chat::Lastlog($channel) [list]; LoadChannel $channel } set time [ clock seconds ] if [isop $nick $channel] { set nick "@$nick" } elseif [isvoice $nick $channel] { set nick "+$nick" } #putmsg #cybex.test "Add [ llength $Chat::Lastlog(All) ] [ llength $Chat::Lastlog($channel) ] $type : $channel $nick $args" set Chat::Lastlog(All) [ linsert $Chat::Lastlog(All) 0 [ subst -nocommands { $type $time $channel $nick $args } ] ] if { [ llength $Chat::Lastlog(All) ]>999 } { set Chat::Lastlog(All) [ lrange $Chat::Lastlog(All) 0 999 ] } set Chat::Lastlog($channel) [ linsert $Chat::Lastlog($channel) 0 [ subst -nocommands { $type $time $nick $args } ] ] if { [ llength $Chat::Lastlog($channel) ]>999 } { set Chat::Lastlog($channel) [ lrange $Chat::Lastlog($channel) 0 999 ] } #putmsg #cybex.test "Total [ llength $Chat::Lastlog ] : $Chat::Lastlog" Save; SaveChannel $channel } proc c_dcc { { args "" } } { putcmdlog "c_dcc: $args" } proc c_pubm { nick uhost handle channel text } { #putcmdlog "Pubm $nick in $channel"; Chat::Add pubm $channel $nick $text } proc c_join { nick uhost handle channel } { Chat::Add join $channel $nick; NicklistChannel $channel } proc c_part { nick uhost handle channel text } { Chat::Add part $channel $nick $text; NicklistChannel $channel } proc c_sign { nick uhost handle channel text } { Chat::Add sign $channel $nick $text; NicklistChannel $channel } proc c_topc { nick uhost handle channel text } { Chat::Add topc $channel $nick $text; TopicChannel $channel } proc c_kick { nick uhost handle channel knick {text "" } } { #putcmdlog "Kick $nick in $channel"; Chat::Add kick $channel $nick [ subst -nocommands { $knick $text } ]; NicklistChannel $channel } proc c_nick { nick uhost handle channel text } { Chat::Add nick $channel $nick $text; NicklistChannel $channel } proc c_mode { nick uhost handle channel mc { text "" } } { Chat::Add mode $channel $nick [ subst -nocommands { $mc $text } ]; NicklistChannel $channel } proc c_ctcp { nick uhost handle channel key { text "" } } { putcmdlog "Action $nick in $channel"; Chat::Add ctcp $channel $nick [ subst -nocommands { $key $text } ] } bind dcc * chat Chat::c_dcc bind pubm - * Chat::c_pubm bind join - * Chat::c_join bind sign - * Chat::c_sign bind topc - * Chat::c_topc bind kick - * Chat::c_kick bind nick - * Chat::c_nick bind mode - * Chat::c_mode bind part - * Chat::c_part bind ctcp - "ACTION" Chat::c_ctcp putlog "Chat.tcl loaded version $major.$minor.$build.$run" return "$major.$minor.$build.$run" }