View difference between Paste ID: LwhmLduG and fpx1Gx1Z
SHOW: | | - or go back to the newest paste.
1-
### TextSplitter.tcl v2.5.1 fpx1Gx1Z
1+
### TextSplitter.tcl 2.5.1 fpx1Gx1Z
2
3
#REQUIREMENTS
4
# PatchChk.tcl Y5aZfqpT
5
6
#LICENSE
7
# Copyright © 2013 Alberto Dietze "DoctorD90"
8
#
9
#    This program is free software: you can redistribute it and/or modify
10
#    it under the terms of the GNU General Public License as published by
11
#    the Free Software Foundation, either version 3 of the License, or
12
#    (at your option) any later version.
13
#
14
#    This program is distributed in the hope that it will be useful,
15
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
#    GNU General Public License for more details.
18
#
19
#    You should have received a copy of the GNU General Public License
20
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
#
22
# Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt
23
24
#PATERNITY
25
#Coder or Developer?: DoctorD90
26
#Network: irc.OnlineGamesNet.net
27
#Chan: #eHito
28
#Mail: [email protected]
29
#
30
#Thanks to guys on #egghelp on irc.freenode.net
31
#Special thanks to Speechles
32
33
#PURPOSE
34
#This script splits messages sended to irc server
35
#in lines if it is over max chars network length
36
37
#USAGE
38
#To send message to server, use command
39
#notice Target stringMessage speedqueque
40
#or
41
#privmsg Target stringMessage speedqueque
42
#or
43
#actmsg Target stringMessage speedqueque
44
# 'speedqueque' is optional. If it isn't setted,
45
#it will use default value setted in SETTINGS section.
46
47
#SETTINGS
48
#Set your own Max Char Network Length
49
set textsplitter(netmaxchar) 512
50
51
#Set your default queque speed messages.
52
#1 putserv
53
#2 puthelp
54
#3 putquick
55
#4 putnow
56
set textsplitter(speedqueque) 1
57
58
59
### DON'T EDIT ANYTHING BELOW ###
60
61
proc notice {who what {speed{$::textsplitter(speedqueque)}}} {
62
  if {[info exists ::BotPatchedChk] && $::BotPatchedChk} {
63
    set lines [bpatched_text $who 0 $what]
64
  } else {
65
    set lines [bunpatched_text $who 0 $what]
66
  }
67
  foreach line $lines {
68
    set text "NOTICE $who :$line"
69
    switch -glob -- $speed {
70
	  "2" {
71
        puthelp $text
72
      }
73
	  "3" {
74
        putquick $text
75
      }
76
	  "4" {
77
        putnow $text
78
      }
79
	  "default" {
80
        putserv $text
81
      }
82
    }
83
  }
84
}
85
86
proc privmsg {who what {speed{$::textsplitter(speedqueque)}}} {
87
  if {[info exists ::BotPatchedChk] && $::BotPatchedChk} {
88
    set lines [bpatched_text $who 1 $what]
89
  } else {
90
    set lines [bunpatched_text $who 1 $what]
91
  }
92
  foreach line $lines {
93
    set text "PRIVMSG $who :$line"
94
    switch -glob -- $speed {
95
	  "2" {
96
        puthelp $text
97
      }
98
	  "3" {
99
        putquick $text
100
      }
101
	  "4" {
102
        putnow $text
103
      }
104
	  "default" {
105
        putserv $text
106
      }
107
    }
108
  }
109
}
110
111
proc actmsg {who what {speed{$::textsplitter(speedqueque)}}} {
112
  if {[info exists ::BotPatchedChk] && $::BotPatchedChk} {
113
    set lines [bpatched_text $who 16 $what]
114
  } else {
115
    set lines [bunpatched_text $who 16 $what]
116
  }
117
  foreach line $lines {
118
    set text "PRIVMSG $who :\001ACTION $line\001"
119
    switch -glob -- $speed {
120
	  "2" {
121
        puthelp $text
122
      }
123
	  "3" {
124
        putquick $text
125
      }
126
	  "4" {
127
        putnow $text
128
      }
129
	  "default" {
130
        putserv $text
131
      }
132
    }
133
  }
134
}
135
136
proc bpatched_text {who typ what} {
137
  set max [expr {$::textsplitter(netmaxchar) - 7 - $typ - [string bytelength $who] - 2 - 2}]
138
  if {[string bytelength $what] <= $max} {
139
    lappend msg $what
140
  } else {
141
    while {[string bytelength $what] != "0"} {
142
      set a 0
143
      set b 0
144
      while {[string bytelength [string range $what 0 $a]] < $max && $a <= [string length $what]} {
145
        if {![string length [string trim [string index $what $a]]]} {
146
          set b $a
147
        }
148
        incr a
149
      }
150
      if {[string length [string trim [string index $what $a]]] && [string length [string trim [string index $what [expr {$a + 1}]]]] && [llength [split $what]] > "1"} {
151
        set a $b
152
      }
153
      if {[string length [string trim [string range $what 0 $a]]]} {
154
        lappend msg [string trim [string range $what 0 $a]]
155
       }
156
       set what [string range $what [expr {$a + 1}] end]
157
    }
158
  }
159
  return $msg
160
}
161
162
proc bunpatched_text {who typ what} {
163
  set ::textsplitter(netmaxchar) 512
164
  set max [expr {$::textsplitter(netmaxchar) - 7 - $typ - [string length $who] - 2 - 2}]
165
  if {[string length $what] <= $max} {
166
    lappend msg $what
167
  } else {
168
    while {[string length $what] != "0"} {
169
      set a 0
170
      set b 0
171
      while {[string length [string range $what 0 $a]] < $max && $a <= [string length $what]} {
172
        if {![string length [string trim [string index $what $a]]]} {
173
          set b $a
174
        }
175
        incr a
176
      }
177
      if {[string length [string trim [string index $what $a]]] && [string length [string trim [string index $what [expr {$a + 1}]]]] && [llength [split $what]] > "1"} {
178
        set a $b
179
      }
180
     if {[string length [string trim [string range $what 0 $a]]]} {
181
        lappend msg [string trim [string range $what 0 $a]]
182
     }
183
      set what [string range $what [expr {$a + 1}] end]
184
    }
185
  }
186
  return $msg
187
}
188
189
###
190
putlog "TextSplitter.tcl LOADED"