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.

Need help to remove color codes

Support & discussion of released scripts, and announcements of new releases.
Post Reply
c
cnecrea
Voice
Posts: 3
Joined: Sat Oct 08, 2022 9:01 am

Need help to remove color codes

Post by cnecrea »

hi there,

Can someone help me with this part of TCL? It is supposed to log all chat lines and actions (/me or /ame) to a file. The "problem" is that when someone writes with color code (CTRL+K) or BOLD/Underline also logs it and I don't want that.

CTRL+K+12 example

Code: Select all

10/08/22 14:49:52 CMSG #CHANNELLOG: user(user@12.12.12.12) 12this is CTRL+K+12
example what I want without inserting "12" or similar (strip codes)

Code: Select all

10/08/22 14:49:52 CMSG #CHANNELLOG: user(user@12.12.12.12) this is CTRL+K+12

Code: Select all

setudef flag chat
set logfile "logs/"

bind pubm - * spymsgecho
proc spymsgecho { nick uhost h chan text } {
   if {[channel get $chan chat]} {
     global logfile
     set r "[open "$logfile/$chan.log.log" a+]"
     puts $r "[strftime "%D %T"] CMSG $chan: $nick ($uhost) $text";
     close $r

   }
}


bind ctcp - action spyactionecho
proc spyactionecho {nick uhost h d k text} {
   global botnick
   if {$d == $botnick} {
       return 0
   } elseif {[lsearch -exact [channel info $d] {+chat}] != "-1"} {
     global logfile
     set r "[open "$logfile/$d.log.log" a+]"
     puts $r "[strftime "%D %T"] AMSG $d: $nick ($uhost) $text";
     close $r
   }
}

putlog "TCL LOG"
Any help would be a great help, thanks!!!
User avatar
CrazyCat
Revered One
Posts: 1305
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

If you want to strip any color or control char, just add:

Code: Select all

set text [stripcodes * $text]
You can have a look @ https://docs.eggheads.org/using/tcl-com ... ags-string if you want more informations about this command.
c
cnecrea
Voice
Posts: 3
Joined: Sat Oct 08, 2022 9:01 am

Post by cnecrea »

Many thanks!!! Worked!
Post Reply