### TextSplitter.tcl v2.5.1 fpx1Gx1Z #REQUIREMENTS # PatchChk.tcl Y5aZfqpT # #LICENSE # Copyright © 2013 Alberto Dietze "DoctorD90" # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt #PATERNITY #Coder or Developer?: DoctorD90 #Network: irc.OnlineGamesNet.net #Chan: #eHito #Mail: DoctorD90@EggTcl.tk # #Thanks to guys on #egghelp on irc.freenode.net #Special thanks to Speechles #PURPOSE #This script splits messages sended to irc server #in lines if it is over max chars network length #USAGE #To send message to server, use command #notice Target stringMessage speedqueque #or #privmsg Target stringMessage speedqueque #or #actmsg Target stringMessage speedqueque # 'speedqueque' is optional. If it isn't setted, #it will use default value setted in SETTINGS section. #SETTINGS #Set your own Max Char Network Length set textsplitter(netmaxchar) 512 #Set your default queque speed messages. #1 putserv #2 puthelp #3 putquick #4 putnow set textsplitter(speedqueque) 1 ### DON'T EDIT ANYTHING BELOW ### proc notice {who what {speed{$::textsplitter(speedqueque)}}} { if {[info exists ::BotPatchedChk] && $::BotPatchedChk} { set lines [bpatched_text $who 0 $what] } else { set lines [bunpatched_text $who 0 $what] } foreach line $lines { set text "NOTICE $who :$line" switch -glob -- $speed { "2" { puthelp $text } "3" { putquick $text } "4" { putnow $text } "default" { putserv $text } } } } proc privmsg {who what {speed{$::textsplitter(speedqueque)}}} { if {[info exists ::BotPatchedChk] && $::BotPatchedChk} { set lines [bpatched_text $who 1 $what] } else { set lines [bunpatched_text $who 1 $what] } foreach line $lines { set text "PRIVMSG $who :$line" switch -glob -- $speed { "2" { puthelp $text } "3" { putquick $text } "4" { putnow $text } "default" { putserv $text } } } } proc actmsg {who what {speed{$::textsplitter(speedqueque)}}} { if {[info exists ::BotPatchedChk] && $::BotPatchedChk} { set lines [bpatched_text $who 16 $what] } else { set lines [bunpatched_text $who 16 $what] } foreach line $lines { set text "PRIVMSG $who :\001ACTION $line\001" switch -glob -- $speed { "2" { puthelp $text } "3" { putquick $text } "4" { putnow $text } "default" { putserv $text } } } } proc bpatched_text {who typ what} { set max [expr {$::textsplitter(netmaxchar) - 7 - $typ - [string bytelength $who] - 2 - 2}] if {[string bytelength $what] <= $max} { lappend msg $what } else { while {[string bytelength $what] != "0"} { set a 0 set b 0 while {[string bytelength [string range $what 0 $a]] < $max && $a <= [string length $what]} { if {![string length [string trim [string index $what $a]]]} { set b $a } incr a } if {[string length [string trim [string index $what $a]]] && [string length [string trim [string index $what [expr {$a + 1}]]]] && [llength [split $what]] > "1"} { set a $b } if {[string length [string trim [string range $what 0 $a]]]} { lappend msg [string trim [string range $what 0 $a]] } set what [string range $what [expr {$a + 1}] end] } } return $msg } proc bunpatched_text {who typ what} { set ::textsplitter(netmaxchar) 512 set max [expr {$::textsplitter(netmaxchar) - 7 - $typ - [string length $who] - 2 - 2}] if {[string length $what] <= $max} { lappend msg $what } else { while {[string length $what] != "0"} { set a 0 set b 0 while {[string length [string range $what 0 $a]] < $max && $a <= [string length $what]} { if {![string length [string trim [string index $what $a]]]} { set b $a } incr a } if {[string length [string trim [string index $what $a]]] && [string length [string trim [string index $what [expr {$a + 1}]]]] && [llength [split $what]] > "1"} { set a $b } if {[string length [string trim [string range $what 0 $a]]]} { lappend msg [string trim [string range $what 0 $a]] } set what [string range $what [expr {$a + 1}] end] } } return $msg } ### putlog "TextSplitter.tcl LOADED"