Code: Select all
bind PUBM - "#from *" bigtoe:pubm
set temp(chan) "#to"
proc bigtoe:pubm {nick uhost hand chan arg} {
if {[string match "*\0034*" $arg]} {
set arg [string map [list "\0034" ""] $arg]
putserv "PRIVMSG $::temp(chan) :Found $arg on chan $chan"
}
}
Code: Select all
bind PUBM - "#from *" bigtoe:pubm
set bigtoetx(chan) "#to"
proc bigtoe:pubm {nick uhost hand chan arg} {
if {[string match "*\0034*" $arg]} {
set arg [string map [list "\0034" ""] $arg]
putserv "PRIVMSG $::bigtoetx(chan) :Found $arg on chan $chan"
}
}
[/code]I need a script that when someone writes a text on channel #Froglegs and all of it or part of it is colored in red - it will return only the part of the string that is colored
Code: Select all
bind PUBM - "#from *" bigtoe:pubm
set bigtoetx(chan) "#to"
proc bigtoe:pubm {nick uhost hand chan arg} {
foreach a $arg {
if {[string match "*\0034*" $a]} {
set a [string map [list "\0034" ""] $a]
putserv "PRIVMSG $::bigtoetx(chan) :Found $a on chan $chan"
}
}
}
Code: Select all
bind PUBM - "#from *" bigtoe:pubm
set bigtoetx(chan) "#to"
proc bigtoe:pubm {nick uhost hand chan arg} {
if {[string match "*\0034*" $arg]} {
set start [expr {[string first "\0034" $arg]+2}]
set x [string first "\003" $arg $start]
if {$x>"-1"} { set end [incr x -1] } else { set end "end" }
set arg [string range $arg $start $end]
putserv "PRIVMSG $::bigtoetx(chan) :Found $arg on chan $chan"
}
}
Hopefully this is what you had in mind. Enjoysfrom irc wrote:** in #chanA **
<speechles> hi there <control-k>4this is red <control-k>this isnt <control-k>04but this is red again<control-k> then it isnt
** which appears in #chanA **
<speechles> hi there this is red this isnt but this is red again then it isnt
** moments later in #chanB **
<bot> Found results: this is red, but this is red again.
Code: Select all
# BigToe Tracker v0.1
# Captures all text with a certain color, in channels you want and
# relays this to a control channel where you can see it appear
namespace eval big_toe {
variable track
# --> config starts
# what color are we tracking? for colors 0 thru 9 you need to use both
# 0-9 and 00-09. for example red is [list "4" "04"]. the number with the
# leading zero must be last. for colors 10 and onward there is no issue
# like this so you would use a single number for example, pink would
# be [list "13"]
set track(color) [list "4" "04"]
# Which channel are we relay the tracked messages to?
set track(relaychan) #relaychannel
# <-- config ends
}
bind pubm - * big_toe::track
setudef flag bigtoetrack
namespace eval big_toe {
proc track {nick uhost hand chan text} {
if {![channel get $chan bigtoetrack]} { return 1 }
variable track
set stext [split $text \003]
set matches [lsearch -glob -all -inline $stext [lindex $track(color) 0]*]
if {[llength $track(color)] > 1} {
set morematches [lsearch -glob -all -inline $stext [lindex $track(color) 1]*]
set iterate [list matches 1 morematches 2]
} else {
set iterate [list matches 1]
}
foreach {n v} $iterate {
foreach r [set $n] {
lappend result [string range [string trim $r] $v end]
}
}
if {[info exists result]} {
putserv "privmsg $track(relaychan) :Found results: [join $result ", "]."
}
return 1
}
}
putlog "*** BigToeTracker v0.1 Loaded."
#eof
Code: Select all
bind pubm - "#froglegs *" big_toe::track
namespace eval big_toe {
proc track {nick uhost hand chan text} {
set text [split $text \003]
foreach sentence $text {
if {[string match 4* $sentence]} {
set addme [string range $sentence 1 end]
} elseif {[string match 04* $sentence]} {
set addme [string range $sentence 2 end]
}
if {[info exists addme]} {
lappend result [string trim $addme]
unset addme
}
}
if {[info exists result]} {
putserv "privmsg #goahead :#Froglegs: <$nick> [join $result " "]"
}
}
}
The first way, gives priority to 4* appearing first in the result list. This may be a problem if the red text isn't given back in the order it was in the text. If this is a problem, the second way alleviates this issue and is a more simple approach to the exact same idea. Hopefully combined you gain a better grasp of tcl by exposing you to several ways to accomplish this.from irc wrote:*** in #Frogslegs ***
<speechles> blsh nlssdfhi there this is red again this isnt but this is red andnow its cyan then its red again :D
*** moments later in #goahead ***
<bot> #Froglegs: <speechles> this is red again but this is red and then its red again :D