egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help to remove color codes

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
cnecrea
Voice


Joined: 08 Oct 2022
Posts: 3

PostPosted: Sat Oct 08, 2022 9:07 am    Post subject: Need help to remove color codes Reply with quote

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:

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:

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




Code:
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!!!
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1059
Location: France

PostPosted: Sat Oct 08, 2022 9:24 am    Post subject: Reply with quote

If you want to strip any color or control char, just add:
Code:
set text [stripcodes * $text]


You can have a look @ https://docs.eggheads.org/using/tcl-commands.html#stripcodes-strip-flags-string if you want more informations about this command.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
cnecrea
Voice


Joined: 08 Oct 2022
Posts: 3

PostPosted: Sat Oct 08, 2022 5:59 pm    Post subject: Reply with quote

Many thanks!!! Worked!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber