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 

Split Message in different line

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
b00m
Voice


Joined: 02 Mar 2007
Posts: 3

PostPosted: Fri Mar 02, 2007 6:49 pm    Post subject: Split Message in different line Reply with quote

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 Razz

...and excuse me for my english Very Happy
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Fri Mar 02, 2007 7:46 pm    Post subject: Reply with quote

http://forum.egghelp.org/viewtopic.php?p=33031#33031
Back to top
View user's profile Send private message
b00m
Voice


Joined: 02 Mar 2007
Posts: 3

PostPosted: Fri Mar 02, 2007 8:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sat Mar 03, 2007 12:23 am    Post subject: Reply with quote

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
View user's profile Send private message
b00m
Voice


Joined: 02 Mar 2007
Posts: 3

PostPosted: Wed Mar 07, 2007 3:46 pm    Post subject: Reply with quote

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 Razz
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Wed Mar 07, 2007 5:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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