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 

Mirc Strip Help

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Rolet
Voice


Joined: 01 Dec 2008
Posts: 3

PostPosted: Sat Dec 06, 2008 10:41 am    Post subject: Mirc Strip Help Reply with quote

any idea why this will strip <> from text?? trying to get a quote script to work but cant cause if i have <NICK> it strips the lot. but if its <+NICK> its fine

Code:


proc replace {{args ""}} {
   set switches ""
   for {set i 0} {[string match -* [set arg [lindex $args $i]]]} {incr i} {
      if {![regexp -- {^-(nocase|-)$} $arg -> switch]} {
         error "bad switch \"$arg\": must be -nocase, or --"
      }
      if {$switch == "-"} {
         incr i
         break
      }; lappend switches $switch
   }
   set nocase [expr {([lsearch -exact $switches "nocase"] >= "0") ? 1 : 0}]
   set text [lindex $args $i]
   set substitutions [lindex $args [expr $i+1]]
      # Check to see if $substitutions is in list format, if not make it so.
   set substitutions [split $substitutions]
      if {[info tclversion] >= "8.1"} {
      return [expr {($nocase)?
         [string map -nocase $substitutions $text]:
         [string map $substitutions $text]}]
   }
      set re_syntax {([][\\\*\+\?\{\}\,\(\)\:\.\^\$\=\!\|])}
   foreach {a b} $substitutions {
      regsub -all -- $re_syntax $a {\\\1} a
      if {$nocase} {regsub -all -nocase -- $a $text $b text} \
      else {regsub -all -- $a $text $b text}
   }; return $text
}



proc mirc_strip {{args ""}} {
   set switches ""
   if {$switches == ""} {set switches all}
   set arg [lindex $args 0]
   set all [expr {([lsearch -exact $switches all] >= 0) ? 1 : 0}]
   set list [list \002 "" \017 "" \026 "" \037 ""]
   regsub -all -- "\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?" $arg "" arg
   set arg [replace -- $arg [join $list]]
   return $arg
}

proc mq:filter {data} {
  regsub -all -- "(\002|\017|\026|\037|\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?)"  $data "" data
  set data [mirc_strip $data]
  return $data
}
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Dec 06, 2008 1:35 pm    Post subject: Reply with quote

To be honest, I can't see how this piece of code would affect <> in any way.
I must, however, say that it feels somewhat overworked, doing the very same replacements over and over, and using the built-in stripcodes command should yield the very same (if not better) result, although probably much faster.

If you simply wish to remove <> from the first word in the line, I'd suggest using something like this (having the string being stripped in $text) :
Code:
regsub -- {^<([^[:space:]])>} $text {\1}

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Rolet
Voice


Joined: 01 Dec 2008
Posts: 3

PostPosted: Sat Dec 06, 2008 2:29 pm    Post subject: Reply with quote

no i want to leave all <> in lol
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Dec 06, 2008 11:20 pm    Post subject: Reply with quote

Well, the pasted code really shouldn't remove them either...
Nevertheless, I still suggest using the stripcodes command to remove control characters such as colours, bold, etc. instead of using the posted script.
_________________
NML_375, idling at #eggdrop@IrcNET
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 -> Scripting Help 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