I'm using a script to keep a log from my channel. I'm using the log to make channel statistics.
When the script logs the channel, it is messing up "æøå". So that "Æ" for instances looks like "æ".
I'm not sure if it is the script, eggdrop og even my Linux distribution in general that needs to be modifed, to make it log the chars correctly!?
I have tried searching this forum, and have google for hours, without finding anything that resembles issues with ÆØÅ in Eggdrop or tcl scripts.
Do I need to modify my script? If so, could anyone be of assistance please! Or is it some sort of variable I have to set corretly in my Eggdrop og Linux?
Here is the code I'm using...:
Code: Select all
#### mIRCStats Eggdrop Logger by Jules <jules@angelbears.org> #manchester@IRCNet
#### Multiple Channel Support by SirSir <sirsir@thuntek.net>
#### Unix/Linux Support by T_D <todd6971@msn.com> #cracks2000@EFNet
####
#### This tcl creates mIRC-style channel logfiles for use with the popular
#### mIRCStats <http://gamma.nic.fi/~mauvinen/mircstats/> program.
#### This tcl will ONLY run on eggdrop1.6.0 or higher!!!
####
#### For version history see history.txt
#### Set your mel directories here.
set statsdir "mel/"
set statslogdir "mel/logs/"
#### Set this to your handle on the bot. You will be UNABLE to use any of
#### the partyline commands if this is set incorrectly!!!
set logkeeper "Jules"
#### Select if you want filenames without a leading #. 1 is without #, 0 is with #.
set usenix 0
#### Select if you want a datestamp in the filenames. 1 is yes, 0 is no.
#### Datestamped filenames are like #channel.03.25.2001.log
#### This value can be ignored when running in mAC mode.
set dslogfiles 1
#### Select if you are upgrading from mEL version 1.5.3 or lower.
set upgrade 0
# # # # # # # # # # # # DO NOT CHANGE ANYTHING BELOW HERE # # # # # # # # # # #
set logver "v1.5.5"
set vername "\002mEL $logver:\002"
set todaydate [strftime %j:%Y]
set switch 1
set switched 0
set daysamount 7
set melinitfile "init.mel"
set daysfile "switch.mel"
set removedchannels "rmchans.mel"
set macfile "checkmac.mel"
set setdaysfile "setdays.mel"
set started "iunno..."
set mel_chanid 0
set mel_keepid 0
bind dcc * mel mel_dcc
bind pubm - * mel_chatter
bind join - * mel_enter
bind sign - * mel_signoff
bind topc - * mel_ctopic
bind kick - * mel_kicked
bind nick - * mel_nickchange
bind mode - * mel_cmode
bind part - * mel_partinga
bind ctcp - "ACTION" mel_caction
if {![file isdirectory $statsdir]} {
putlog "$vername Settings directory not found... creating..."
[file mkdir $statsdir]
}
if {![file isdirectory $statslogdir]} {
putlog "$vername Logfile directory not found... creating..."
[file mkdir $statslogdir]
}
#### End_globvarstat_a
#### Start_procdcc
proc mel_dcc {handle idx arg} {
global logkeeper upgrade started daysamount statsdir statslogdir logver autoswitch switch vername mel_chans mel_chanid statsdir macfile setdaysfile daysfile todaydmy nextswitch mel_keepid mel_keepers macmode
set arg1 [lindex $arg 0]
set arg2 [lindex $arg 1]
if {![finditem fkeep [string tolower $handle]]} {
putlog "#$handle# mel $arg"
putidx $idx "You are not allowed to perform maintenance!"
putidx $idx "Contact $logkeeper for more information"
putidx $idx "\002mIRCStats Eggdrop Logger\002 $logver"
return 0
}
switch -- $arg1 {
on {
putlog "#$handle# mel on"
if {$switch == 1} {
putidx $idx "$vername mEL is already turned on!"
return 0
}
if {![array exists mel_chans]} {
putidx $idx "$vername You must use .mel +chan first!!"
return 0
}
set switch 1
putidx $idx "$vername mEL turned on!"
return 0
}
off {
putlog "#$handle# mel off"
if {$switch == 0} {
putidx $idx "$vername mEL is already turned off!"
return 0
}
set switch 0
putidx $idx "$vername mEL turned off!"
return 0
}
setdays {
putlog "#$handle# mel setdays"
if {$switch == 0} {
putidx $idx "$vername Can't change amount of days to log -> Logging is disabled!"
return 0
}
if {$arg2 == ""} {
putidx $idx "Please enter an amount of days"
return 0
}
if {[string compare [string index $arg2 0] "-"] == 0} {
putidx $idx "Negative value detected! Ignoring..."
return 0
}
if {[string compare [string is digit -failindex indexfailed $arg2] 1] != 0} {
set failedchar [string index $arg2 $indexfailed]
putidx $idx "Error! $failedchar is not a valid digit!"
return 0
}
if {$arg2 == "0"} {
if {[checkmacfile]} {
putidx $idx "$vername mEL is already running in mAC mode!"
return 0
}
putidx $idx "Switching to mAC mode..."
foreach search [binds time] {
set procname [lindex $search 4]
if {[string compare $procname "meltimer"] == 0} {
set binder [lindex $search 2]
unbind time - "$binder" meltimer
break
}
}
set create [open ${statsdir}${macfile} w]
puts $create "mAC mode check file - DO NOT REMOVE!!!"
close $create
set autoswitch 1
switchlogs
set macmode 1
putidx $idx "$vername mEL has switched to mAC mode. Switching back to manual mode will restart logging!"
return 0
} else {
set arg2 [string trimleft $arg2 0]
if {![checkmacfile]} {
set todaydmy [clock format [unixtime] -format "%d %m %Y"]
set nextswitch [clock format [clock scan "today next $arg2 days"] -format "%d %m %Y"]
putidx $idx "$vername Changing logging to $arg2 days"
if {[file exists ${statsdir}${daysfile}]} {
set remove [file delete -force ${statsdir}${daysfile}]
}
set create [open ${statsdir}${daysfile} w]
puts $create "$nextswitch"
close $create
if {[file exists ${statsdir}${setdaysfile}]} {
set remove [file delete -force ${statsdir}${setdaysfile}]
}
set create [open ${statsdir}${setdaysfile} w]
puts $create "$arg2"
close $create
foreach search [binds time] {
set procname [lindex $search 4]
if {[string compare $procname "meltimer"] == 0} {
set binder [lindex $search 2]
unbind time - "$binder" meltimer
break
}
}
bind time - "* 00 $nextswitch" meltimer
putlog "$vername Timer bound to the first second of [lindex $nextswitch 0]/[lindex $nextswitch 1]/[lindex $nextswitch 2]"
return 0
} else {
putidx $idx "$vername Switching back to manual mode..."
set todaydmy [clock format [unixtime] -format "%d %m %Y"]
set remove [file delete -force ${statsdir}${macfile}]
set nextswitch [clock format [clock scan "today next $arg2 days "] -format "%d %m %Y"]
if {[file exists ${statsdir}${daysfile}]} {
set remove [file delete -force ${statsdir}${daysfile}]
}
set create [open ${statsdir}${daysfile} w]
puts $create "$nextswitch"
close $create
if {[file exists ${statsdir}${setdaysfile}]} {
set remove [file delete -force ${statsdir}${setdaysfile}]
}
set create [open ${statsdir}${setdaysfile} w]
puts $create "$arg2"
close $create
set autoswitch 1
switchlogs
putidx $idx "$vername Back in manual mode."
foreach search [binds time] {
set procname [lindex $search 4]
if {[string compare $procname "meltimer"] == 0} {
set binder [lindex $search 2]
unbind time - "$binder" meltimer
}
}
bind time - "* 00 $nextswitch" meltimer
putlog "$vername Timer bound to the first second of [lindex $nextswitch 0]/[lindex $nextswitch 1]/[lindex $nextswitch 2]"
set macmode 0
return 0
}
return 0
}
return 0
}
status {
putlog "#$handle# mel status"
if {$switch == 0} {
putidx $idx "mEL MUST be turned on first."
return 0
}
readdays
if {[lindex $daysamount 0] == "iunno..."} {
set donotswitch 1
} else { set donotswitch 0 }
set thisday [clock format [unixtime] -format "%d %m %Y"]
set status "Off"
if {$switch == 1} {
set status "On"
}
putidx $idx "mEL is turned $status"
if {[checkmacfile]} {
putidx $idx "mEL is running in mAC mode."
} else {
if {$donotswitch == 1} {
putidx $idx "mEL has disabled switching!!! Please use \002.mel setdays\002 to enable switching!!"
putidx $idx "mEL is NOT running in mAC mode and mEL is NOT switching logfiles!!!!!"
} else {
putidx $idx "mEL switches logfiles every $daysamount day(s)."
putidx $idx "Next switch is at the first second of [lindex $nextswitch 0]/[lindex $nextswitch 1]/[lindex $nextswitch 2]"
putidx $idx "Today is [lindex $thisday 0]/[lindex $thisday 1]/[lindex $thisday 2]"
}
}
foreach m [array names mel_chans] {
set data $mel_chans($m)
putidx $idx " Logging $data"
}
if {$upgrade == 1} {
putidx $idx ""
putidx $idx "DO NOT FORGET TO SET VARIABLE 'UPGRADE' TO 0!!!!!!!!!"
}
putidx $idx ""
putidx $idx "Storing settings in $statsdir"
putidx $idx "Storing logfiles in $statslogdir"
return 0
}
+chan {
if {$arg2 != ""} {
putlog "#$handle# mel +chan $arg2"
if {[string index $arg2 0] != "#"} {
putidx $idx "Please use .mel +chan <#channel>"
return 0
}
if {$mel_chanid != 0} {
if {[finditem fchan [string tolower $arg2]]} {
putidx $idx "$vername $arg2 is already being logged!"
return 0
}
}
set temp [additem achan [string tolower $arg2]]
putidx $idx "mEL is logging $arg2"
return 0
}
}
-chan {
if {$arg2 != ""} {
putlog "#$handle# mel -chan $arg2"
if {[string index $arg2 0] != "#"} {
putidx $idx "Please use .mel -chan <#channel>"
return 0
}
if {![array exists mel_chans]} {
putidx $idx "$vername You must use .mel +chan <channel> first!"
return 0
}
if {![finditem fchan [string tolower $arg2]]} {
putidx $idx "$vername $cmd2 is not being logged!"
return 0
}
set temp [delitem dchan [string tolower $arg2]]
putidx $idx "mEL is no longer logging $arg2"
putidx $idx "Use .mel erase to remove the logfile!"
return 0
}
}
erase {
putlog "#$handle# mel erase"
killog $handle
return 0
}
addkeeper {
if {$arg2 != ""} {
putlog "#$handle# mel addkeeper $arg2"
if {[string tolower $handle] != [string tolower $logkeeper]} {
putidx $idx "$vername Sorry, you can't add logkeepers!"
return 0
}
if {![validuser $arg2]} {
putidx $idx "$vername This is not a valid handle!"
return 0
}
if {[finditem fkeep [string tolower $arg2]]} {
putidx $idx "$vername $arg2 already is a logkeeper!"
return 0
}
set temp [additem akeep [string tolower $arg2]]
putidx $idx "$vername User added successfully!"
return 0
}
}
rmkeeper {
if {$arg2 != ""} {
putlog "#$handle# mel rmkeeper $arg2"
if {[string tolower $handle] != [string tolower $logkeeper]} {
putidx $idx "$vername Sorry, you can't remove logkeepers!"
return 0
}
if {[string tolower $logkeeper] == [string tolower $arg2]} {
putidx $idx "$vername Unable to remove static logkeeper!"
return 0
}
if {![finditem fkeep $arg2]} {
putidx $idx "$vername $arg2 isn't a logkeeper to begin with!"
return 0
}
set temp [delitem dkeep $arg2]
putidx $idx "$vername User removed successfully!"
return 0
}
}
listkeeper {
putlog "#$handle# mel listkeeper"
putidx $idx "The following handles have logkeeper status:"
putidx $idx " $logkeeper"
foreach k [array names mel_keepers] {
set foundkeeper $mel_keepers($k)
if {[string tolower $foundkeeper] != [string tolower $logkeeper]} {
putidx $idx " $foundkeeper"
}
}
return 0
}
}
putidx $idx "\002Usage:\002 .mel <on/off/setdays/status/+chan/-chan/erase/addkeeper/rmkeeper/listkeeper>"
return 0
}
#### End_procdcc
#### Start_variousprocs
proc checkmacfile {} {
global statsdir macfile
if {[file exists ${statsdir}${macfile}]} {
return 1
} else {
return 0
}
}
proc checklogrestart {channel} {
global statslogdir usenix
set chan1 [string tolower $channel]
if {$usenix == 1} {
set chan [string trimleft $chan1 #]
} else { set chan $chan1 }
if {![file exists ${statslogdir}${chan}.log]} {
createlog $chan
}
}
proc readdays {} {
global daysfile nextswitch daysamount setdaysfile statsdir
if {[file exists ${statsdir}${daysfile}]} {
set read [open ${statsdir}${daysfile} r]
while {![eof $read]} {
set days [gets $read]
if {[eof $read]} {break}
set nextswitch $days
}
close $read
}
if {[file exists ${statsdir}${setdaysfile}]} {
set read [open ${statsdir}${setdaysfile} r]
while {![eof $read]} {
set days [gets $read]
if {[eof $read]} {break}
set daysamount $days
}
close $read
}
}
#### End_variousprocs
#### Start_arrayhandler
proc mel_arrayinit {} {
global statsdir melinitfile mel_chanid mel_chans mel_keepid mel_keepers switch vername
if {![file exists ${statsdir}${melinitfile}]} {
set switch 0
return 0
}
set chansel 0
set keepsel 0
set nokeeper 0
set readin [open ${statsdir}${melinitfile} r]
while {![eof $readin]} {
set raw_initdata [gets $readin]
if {[eof $readin]} {break}
if {$chansel == 0} {
if {[string compare $raw_initdata "\[channels\]"] == 0} {
set chansel 1
continue
}
putlog "$vername No channels identifier found! Initialization failed! Possible corrupt init-file!"
return 0
} else {
if {$keepsel == 0} {
if {$chansel == 1} {
set allchans 0
incr chansel
}
if {[string compare $raw_initdata "\[keepers\]"] == 0} {
set keepsel 1
continue
}
if {$allchans == 0} {
unset allchans
}
lappend allchans $raw_initdata
continue
} else {
if {$keepsel == 1} {
set allkeepers 0
incr keepsel
}
if {[string compare $raw_initdata "\[end of file\]"] == 0} {break}
if {[string compare $raw_initdata "\[ignores\]"] == 0} {
putlog "$vername Old init-file detected... removing ignores from init-file..."
set nokeeper 1
break
}
if {$allkeepers == 0} {
unset allkeepers
}
if {$nokeeper != 1} {
lappend allkeepers $raw_initdata
}
continue
}
}
}
close $readin
set mel_chanid 0
set mel_keepid 0
if {$allchans != 0} {
foreach melchans $allchans {
incr mel_chanid
set mel_chans($mel_chanid) $melchans
}
} else {set switch 0}
if {$allkeepers != 0} {
foreach melkeeps $allkeepers {
incr mel_keepid
set mel_keepers($mel_keepid) $melkeeps
}
}
if {$nokeeper == 1} {write_array}
return 0
}
proc write_array {} {
global statsdir melinitfile mel_chanid mel_chans mel_keepid mel_keepers
if {[file exists ${statsdir}${melinitfile}]} {
set backup_init [file rename -force ${statsdir}${melinitfile} ${statsdir}${melinitfile}.bak]
}
set put_init [open ${statsdir}${melinitfile} w]
puts $put_init "\[channels\]"
foreach c [array names mel_chans] {
set add_chan $mel_chans($c)
puts $put_init $add_chan
}
puts $put_init "\[keepers\]"
foreach k [array names mel_keepers] {
set add_keep $mel_keepers($k)
puts $put_init $add_keep
}
puts $put_init "\[end of file\]"
close $put_init
mel_arrayinit
return 0
}
#### End_arrayhandler
#### Start_itemhandler
proc finditem {itemid item} {
global mel_chanid mel_chans mel_keepid mel_keepers logkeeper
set result 0
switch $itemid {
fchan {
foreach c [array names mel_chans] {
set compare_chan $mel_chans($c)
if {[string compare [string tolower $compare_chan] $item] == 0} {
set result 1
}
}
if {$result == 1} {return 1}
return 0
}
fkeep {
if {[string compare $item [string tolower $logkeeper]] == 0} {
set result 1
} else {
foreach k [array names mel_keepers] {
set compare_keep $mel_keepers($k)
if {[string compare [string tolower $compare_keep] $item] == 0} {
set result 1
}
}
}
if {$result == 1} {return 1}
return 0
}
}
}
proc additem {itemid item} {
global mel_chanid mel_chans mel_keepid mel_keepers
switch $itemid {
achan {
incr mel_chanid
set mel_chans($mel_chanid) $item
createlog $item
}
akeep {
incr mel_keepid
set mel_keepers($mel_keepid) $item
}
}
write_array
return 0
}
proc delitem {itemid item} {
global mel_chanid mel_chans mel_keepid mel_keepers statsdir removedchannels switch
switch $itemid {
dchan {
foreach c [array names mel_chans] {
set foundchan $mel_chans($c)
if {[string compare $foundchan $item] == 0} {
endlog $item
unset mel_chans($c)
if {![file exists ${statsdir}${removedchannels}]} {
set create [open ${statsdir}${removedchannels} w]
puts $create $item
close $create
} else {
set addfile [open ${statsdir}${removedchannels} a]
puts $addfile $item
close $addfile
}
}
}
}
dkeep {
foreach k [array names mel_keepers] {
set foundkeep $mel_keepers($k)
if {[string compare $foundkeep $item] == 0} {
unset mel_keepers($k)
}
}
}
}
write_array
return 0
}
#### End_itemhandler
#### Start_timehandler
proc meltimer {} {
global autoswitch daysamount vername switch
set autoswitch 1
switchlogs
set newswitch [clock format [clock scan "today next $daysamount days"] -format "%d %m %Y"]
foreach search [binds time] {
set procname [lindex $search 4]
if {[string compare $procname "meltimer"] == 0} {
set binder [lindex $search 2]
unbind time - "$binder" meltimer
}
}
if {$switch == 0} {
putlog "$vername Hey! Logging has been disabled! Better prevent timer binding!"
return 0
}
bind time - "* 00 $newswitch" meltimer
putlog "$vername Timer bound to the first second of [lindex $newswitch 0]/[lindex $newswitch 1]/[lindex $newswitch 2]"
}
proc timestarter {} {
global statsdir nextswitch vername setdaysfile daysfile switch autoswitch
if {$switch == 0} {
foreach search [binds time] {
set procname [lindex $search 4]
if {[string compare $procname "meltimer"] == 0} {
putlog "$vername Huh!? Found a meltimer!? disabling the timer..."
set binder [lindex $search 2]
unbind time - "$binder" meltimer
}
}
return 0
}
set todaydmy [clock format [unixtime] -format "%d %m %Y"]
set todayd [lindex $todaydmy 0]
set todaym [lindex $todaydmy 1]
set todayy [lindex $todaydmy 2]
if {![file exists ${statsdir}${setdaysfile}]} {
set create [open ${statsdir}${setdaysfile} w]
puts $create "iunno... this shouldn't be here"
close $create
putlog "$vername Missing file ${statsdir}${setdaysfile}!!! Automatic switching disabled!"
putlog "$vername You haven't used .mel setdays yet!!!! Use this at least once!!! Automatic switching disabled!"
return 0
}
set no_start_date 0
set readold [open ${statsdir}${setdaysfile} r]
while {![eof $readold]} {
set data [gets $readold]
if {[eof $readold]} {break}
if {[lindex $data 0] == "iunno..."} {
set no_start_date 1
break
}
set amount_of_days $data
break
}
close $readold
if {$no_start_date == 1} {
putlog "$vername You haven't used .mel setdays yet!!!! Use this at least once!!! Automatic switching disabled!"
return 0
}
set switchd [lindex $nextswitch 0]
set switchm [lindex $nextswitch 1]
set switchy [lindex $nextswitch 2]
if {$todayy > $switchy} {
putlog "$vername We better switch those logfiles and create a new timer..."
set newswitch [clock format [clock scan "today next $amount_of_days days"] -format "%d %m %Y"]
bind time - "* 00 $newswitch" meltimer
set deleteold [file delete -force ${statsdir}${daysfile}]
set makenew [open ${statsdir}${daysfile} w]
puts $makenew "$newswitch"
close $makenew
return 0
}
if {$todaym > $switchm && $todayy >= $switchy} {
putlog "$vername We better switch those logfiles and create a new timer..."
set newswitch [clock format [clock scan "today next $amount_of_days days"] -format "%d %m %Y"]
bind time - "* 00 $newswitch" meltimer
set deleteold [file delete -force ${statsdir}${daysfile}]
set makenew [open ${statsdir}${daysfile} w]
puts $makenew "$newswitch"
close $makenew
return 0
}
if {$todayd > $switchd && $todaym >= $switchm && $todayy >= $switchy} {
putlog "$vername We better switch those logfiles and create a new timer..."
set newswitch [clock format [clock scan "today next $amount_of_days days"] -format "%d %m %Y"]
bind time - "* 00 $newswitch" meltimer
set deleteold [file delete -force ${statsdir}${daysfile}]
set makenew [open ${statsdir}${daysfile} w]
puts $makenew "$newswitch"
close $makenew
return 0
}
bind time - "* 00 $nextswitch" meltimer
return 0
}
#### End_timehandler
#### Start_logfilehandler
proc datestamp {} {
global statslogdir switch vername usenix mel_chanid mel_chans
set fulldate [ctime [unixtime]]
set dm [lrange $fulldate 0 1]
if {[lindex $fulldate 2] == ""} {
set testday 0[lindex $fulldate 3]
set rest [lrange $fulldate 4 end]
} else {
set testday [lindex $fulldate 2]
set rest [lrange $fulldate 3 end]
}
set starttime "$dm $testday $rest"
set current [strftime %H:%M]
if {![array exists mel_chans]} {
putlog "$vername Use .mel +chan <channel>."
set switch 0
return 0
}
foreach m [array names mel_chans] {
set data1 $mel_chans($m)
if {$usenix == 1} {
set data [string trimleft $data1 #]
} else { set data $data1 }
set addtimestamp [open ${statslogdir}${data}.log a]
puts $addtimestamp "Session Time: $starttime"
close $addtimestamp
}
}
proc createlog {channel} {
global statslogdir switch vername botnick usenix
set fulldate [ctime [unixtime]]
set dm [lrange $fulldate 0 1]
if {[lindex $fulldate 2] == ""} {
set testday 0[lindex $fulldate 3]
set rest [lrange $fulldate 4 end]
} else {
set testday [lindex $fulldate 2]
set rest [lrange $fulldate 3 end]
}
set starttime "$dm $testday $rest"
set current [strftime %H:%M]
set chan1 [string tolower $channel]
if {$usenix == 1} {
set chan [string trimleft $chan1 #]
} else { set chan $chan1 }
if {![finditem fchan $chan1]} {
putlog "$vername Error! Tried to create new logfile for $chan but $chan doesn't appear to be added!"
return 0
}
if {![file exists ${statslogdir}${chan}.log]} {
set create [open ${statslogdir}${chan}.log w]
puts $create "Session Start: $starttime"
puts $create "\[$current\] *** Now talking in $chan1"
puts $create "\[$current\] <$botnick> Hi"
close $create
putlog "$vername Created logfile for $chan1"
}
if {$switch == 0} {
set switch 1
putlog "$vername Logger turned on!"
}
return 0
}
proc endlog {channel} {
global statslogdir switch vername usenix
set fulldate [ctime [unixtime]]
set dm [lrange $fulldate 0 1]
if {[lindex $fulldate 2] == ""} {
set testday 0[lindex $fulldate 3]
set rest [lrange $fulldate 4 end]
} else {
set testday [lindex $fulldate 2]
set rest [lrange $fulldate 3 end]
}
set endtime "$dm $testday $rest"
set chan1 [string tolower $channel]
if {$usenix == 1} {
set chan [string trimleft $chan1 #]
} else { set chan $chan1 }
if {![finditem fchan $chan1]} {
putlog "$vername Error! Tried to close log of channel not being logged!"
return 0
}
if {![file exists ${statslogdir}${chan}.log]} {
putlog "$vername Error! Tried to close non-existant logfile!"
return 0
}
set add "Session Close: $endtime"
set addfile [open ${statslogdir}${chan}.log a]
puts $addfile $add
close $addfile
putlog "$vername Closed logfile for channel $chan1"
return 0
}
proc switchlogs {} {
global statslogdir daysfile switch autoswitch switched vername usenix dslogfiles mel_chanid mel_chans
if {$switch == 0} {return 0}
foreach m [array names mel_chans] {
set data1 $mel_chans($m)
set switched 1
set fulldate [ctime [unixtime]]
set dm [lrange $fulldate 0 1]
if {[lindex $fulldate 2] == ""} {
set testday 0[lindex $fulldate 3]
set rest [lrange $fulldate 4 end]
} else {
set testday [lindex $fulldate 2]
set rest [lrange $fulldate 3 end]
}
set closetime "$dm $testday $rest"
set add "Session Close: $closetime"
if {$usenix == 1} {
set data [string trimleft $data1 #]
} else { set data $data1 }
set addfile [open ${statslogdir}${data}.log a]
puts $addfile $add
close $addfile
set secs [clock seconds]
set cdate [clock format [incr secs -61] -format %m.%d.%Y]
if {$dslogfiles == 1} {
set copynew [file rename -force ${statslogdir}${data}.log ${statslogdir}${data}.${cdate}.log]
putlog "$vername Created a backup copy of ${statslogdir}${data}.log to ${statslogdir}${data}.${cdate}.log file."
} else {
set copynew [file rename -force ${statslogdir}${data}.log ${statslogdir}${data}.log.bak]
putlog "$vername Created a backup copy of ${statslogdir}${data}.log to ${statslogdir}${data}.log.bak file."
}
createlog $mel_chans($m)
}
if {$autoswitch == 1} {
putlog "$vername Procedure called automatically"
}
if {$autoswitch == 0} {
putlog "$vername Procedure called upon users request"
}
}
proc killog {handle} {
global removedchannels statslogdir statsdir usenix
set idx [hand2idx $handle]
if {![file exists ${statsdir}${removedchannels}]} {
putidx $idx "All closed logfiles are already erased"
return 0
}
putidx $idx "Removing closed logfiles..."
set read [open ${statsdir}${removedchannels} r]
while {![eof $read]} {
set data1 [gets $read]
if {[eof $read]} {break}
if {$usenix == 1} {
set data [string trimleft $data1 #]
} else { set data $data1 }
if {[file exists ${statslogdir}${data}.log]} {
set remove [file delete -force ${statslogdir}${data}.log]
putidx $idx " Removed ${statslogdir}${data}.log..."
}
if {[file exists ${statslogdir}${data}.log.bak]} {
set remove [file delete -force ${statslogdir}${data}.log.bak]
putidx $idx " Removed ${statslogdir}${data}.log.bak..."
}
}
close $read
set remove [file delete -force ${statsdir}${removedchannels}]
putidx $idx "Removed all closed logfiles..."
return 0
}
#### End_logfilehandler
#### Start_loggingprocs
proc strip {args} {
regsub -all \{|\} $args "" args
regsub -all \002 $args "" args
regsub -all \037 $args "" args
regsub -all $args "" args
regsub -all $args "" args
regsub -all {(([0-9])?([0-9])?(\,([0-9])?([0-9])?)?)?} $args "" args
regsub -all { ([0-9A-F][0-9A-F])?} $args "" args
set arg [string trimleft $args]
set lastchar [string index $arg [expr [string length $arg] -1]]
if {[string compare $lastchar "\\"] == 0} {
regsub -all {\\} $arg "" newarg
append newarg "\\"
set arg $newarg
}
return $arg
}
proc mel_event {mel_id mnick mhost mhandle mchannel arg} {
global statslogdir switch usenix macmode
if {$switch == 0} {return 0}
set low_chan [string tolower $mchannel]
if {![finditem fchan $low_chan]} {return 0}
set unick $mnick
set current [strftime %H:%M]
if {$usenix == 1} {
set chan [string trimleft $low_chan #]
} else {
set chan $low_chan
}
if {$macmode == 1} {checklogrestart $chan}
set stripped_arg [strip $arg]
switch -- $mel_id {
chat {
set add "\[$current\] <$unick> $stripped_arg"
}
join {
set add "\[$current\] *** $unick ($mhost) has joined $mchannel"
}
part {
set add "\[$current\] *** $unick ($mhost) has left $mchannel ($stripped_arg)"
}
quit {
set add "\[$current\] *** $unick has left $mchannel ($stripped_arg)"
}
topic {
set add "\[$current\] *** $unick changes topic to '$stripped_arg'"
}
kick {
set target [lindex $arg 0]
set reason [strip [lrange $arg 1 end]]
set add "\[$current\] *** $target was kicked by $unick ($reason)"
}
nick {
set add "\[$current\] *** $unick is now known as $arg"
}
mode {
set newmode [lindex $arg 0]
set victim [lrange $arg 1 end]
set add "\[$current\] *** $unick sets mode: $newmode $victim"
}
action {
set add "\[$current\] * $unick $stripped_arg"
}
}
set adding [open ${statslogdir}${chan}.log a]
puts $adding "$add"
close $adding
}
proc mel_chatter {nick host handle channel text} {
mel_event chat $nick $host $handle $channel $text
}
proc mel_enter {nick host handle channel} {
mel_event join $nick $host $handle $channel nothing
}
proc mel_partinga {nick host handle channel partmsg} {
mel_event part $nick $host $handle $channel $partmsg
}
proc mel_signoff {nick host handle channel reason} {
mel_event quit $nick $host $handle $channel $reason
}
proc mel_ctopic {nick host handle channel topic} {
mel_event topic $nick $host $handle $channel $topic
}
proc mel_kicked {nick host handle channel target reason} {
mel_event kick $nick $host $handle $channel "$target $reason"
}
proc mel_nickchange {nick host handle channel newnick} {
mel_event nick $nick $host $handle $channel $newnick
}
proc mel_cmode {nick host handle channel change victim} {
mel_event mode $nick $host $handle $channel "$change $victim"
}
proc mel_caction {nick host handle dest keyword arg} {
mel_event action $nick $host $handle $dest $arg
}
#### End_loggingprocs
#### Start_globvarstat_b
if {$upgrade == 1} {
if {[file exists ${statsdir}${melinitfile}]} {
file rename -force ${statsdir}${melinitfile} ${statsdir}${melinitfile}.before
}
set create_init [open ${statsdir}${melinitfile} a]
puts $create_init "\[channels\]"
if {[file exists ${statsdir}channels.mel]} {
set read_old [open ${statsdir}channels.mel r]
while {![eof $read_old]} {
set old_data [gets $read_old]
if {[eof $read_old]} {break}
puts $create_init $old_data
}
close $read_old
file rename -force ${statsdir}channels.mel ${statsdir}channels.pre
set mel_chn_upd 1
} else {set mel_chn_upd 0}
puts $create_init "\[keepers\]"
if {[file exists ${statsdir}keepers.mel]} {
set read_old [open ${statsdir}keepers.mel r]
while {![eof $read_old]} {
set old_data [gets $read_old]
if {[eof $read_old]} {break}
puts $create_init $old_data
}
close $read_old
file rename -force ${statsdir}keepers.mel ${statsdir}keepers.pre
set mel_kep_upd 1
} else {set mel_kep_upd 0}
puts $create_init "\[end of file\]"
close $create_init
switch $mel_chn_upd {
1 {putlog "Imported channels from pre 1.5.4 version"}
0 {putlog "Channels import from pre 1.5.4 version failed: file not found"}
}
switch $mel_kep_upd {
1 {putlog "Imported keepers from pre 1.5.4 version"}
0 {putlog "Keepers import from pre 1.5.4 version failed: file not found"}
}
putlog "Ignores are no longer supported and thus not imported."
putlog "$logver DO NOT FORGET TO SET 'UPGRADE' TO 0!!! DO IT NOW!!!"
}
mel_arrayinit
readdays
datestamp
if {![file exists ${statsdir}${macfile}]} {
timestarter
set macmode 0
} else { set macmode 1 }
putlog "\002mIRCStats Eggdrop Logger (mEL)\002 $logver by Jules loaded!"
putlog "\002mIRCStats Eggdrop Logger (mEL)\002 $logver Multi-Channel Edition by SirSir loaded!"
### http://mel.angelbears.org
### Feel free to alter this tcl to your personal flavour... just don't forget who wrote the
### original code... Also, if you find bugs, or even fix some.. then please let me know!
#### End_globvarstat_b
Thanks in advance, I appreciate any kind of help.