| View previous topic :: View next topic |
| Author |
Message |
b00m Voice
Joined: 02 Mar 2007 Posts: 3
|
Posted: Fri Mar 02, 2007 6:49 pm Post subject: Split Message in different line |
|
|
Hi guys,
i have a little problem with my eggdrop.
I would want one small tcl that when my egg spam in my channel,if the message in too big, for example contain 200 caracters, i want that split the message in another line, without to cut the words, even split with the spaces, for example.
Please, if u can help me, help me
...and excuse me for my english  |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
|
| Back to top |
|
 |
b00m Voice
Joined: 02 Mar 2007 Posts: 3
|
Posted: Fri Mar 02, 2007 8:03 pm Post subject: |
|
|
thx for the reply rosc,
i have for example:
bind pub -|- !help pub_help
proc pub_test {nick host handle chan text} {
putserv "PRIVMSG $chan : !bla, !bla2, !bla3, !bla4, !bla5"
}
I increase the process 'proc wordwrap' in my codes?
It's possible only a tcl that allow this split? |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Sat Mar 03, 2007 12:23 am Post subject: |
|
|
Here's an example of using the wrapper from one of my scripts:
| Code: |
proc nlwordwrap {input} {
# word wrapper
set j 0
set tempdef ""
foreach line [split $input \n] {
if {$line != ""} {
set len 375
set splitChr " "
set out [set cur {}]; set i 0
foreach word [split $line $splitChr] {
if {[incr i [string len $word]]>$len} {
lappend out [join $cur $splitChr]
set cur [list $word]
set i [string len $word]
incr j
} else {
lappend cur $word
}
incr i
}
lappend out [join $cur $splitChr]
foreach line2 $out {
if {$j >= 1} {
set line2 [linsert $line2 end \002(con't)\002]
set j [expr $j -1]
}
lappend tempdef $line2
}
}
}
return $tempdef
}
|
To use it, you feed input to it from another proc, like:
| Code: |
# This line feeds text to the wrapper proc:
set missdesc [nlwordwrap $nlmissdesc]
# This line takes the wrapped text and pumps it out to privmsg:
foreach line $missdesc {
if {$line != ""} {
puthelp "PRIVMSG $chan :$line"
}
}
|
You could also put the wrapper inside of whatever proc you want:
| Code: |
# Example from my dream.tcl script, $dreammatch is set when regexp
# gets data from a website:
set j 0;set dhct 0
foreach line [split $dreammatch \n] {
if {$line != ""} {
set len 375
set splitChr " "
set out [set cur {}]; set i 0
foreach word [split $line $splitChr] {
if {[incr i [string len $word]]>$len} {
lappend out [join $cur $splitChr]
set cur [list $word]
set i [string len $word]
incr j
} else {
lappend cur $word
}
incr i
}
lappend out [join $cur $splitChr]
foreach line2 $out {
if {$dhct == 0} {
set line2 [linsert $line2 0 \002[string totitle $text]\002:]
incr dhct
if {$j >= 1} {
set line2 [linsert $line2 end \002(con't)\002]
set j [expr $j - 1]
}
} else {
set line2 [linsert $line2 0 \002([string totitle $text] con't)\002]
if {$j >= 1} {
set line2 [linsert $line2 end \002(con't)\002]
set j [expr $j - 1]
}
}
puthelp "PRIVMSG $chan :[join $line2]"
}
}
#######################################################################################################################
|
|
|
| Back to top |
|
 |
b00m Voice
Joined: 02 Mar 2007 Posts: 3
|
Posted: Wed Mar 07, 2007 3:46 pm Post subject: |
|
|
Sorry rosc2122, i try proc nlwordwrap with this in the same tcl and i have this error:
[20:41] Tcl error in file 'eggdrop.conf':
[20:41] can't read "nlmissdesc": no such variable
while executing
"nlwordwrap $nlmissdesc"
invoked from within
"set missdesc [nlwordwrap $nlmissdesc]"
(file "scripts/split.tcl" line 2)
invoked from within
"source scripts/split.tcl"
(file "eggdrop.conf" line 1340)
[20:41] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
If i use
# Example from my dream.tcl script, $dreammatch is set when regexp
# gets data from a website:
etc....
i have this error:
[20:44] Tcl error in file 'eggdrop.conf':
[20:44] missing close-brace
while executing
"foreach line [split $dreammatch \n] {
if {$line != ""} {
set len 375
..."
(file "scripts/split.tcl" line 5)
invoked from within
"source scripts/split.tcl"
(file "eggdrop.conf" line 1340)
[20:44] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
I have tried your code but there were some errors and I do not understand why... I would like to have a tlc that I can load into file .conf and my problem is that when the sentence is too long the BOT don't divide the sentence in two part such as two reply but stop it with a [censored] &... I want only that the bot divide the sentence in two part without breaking the WORD...
thank u, and sorry for my english  |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Mar 07, 2007 5:59 pm Post subject: |
|
|
The first error was a missing var.. Rename the vars to use whatever you are using.. The second error was a missing close brace, find the missing closed brace and fix it.
Those 2 procs work just fine, you either broke the 2nd one with the missing close brace, or you didn't rename the var in the 1st to suit YOUR script. |
|
| Back to top |
|
 |
|