19 set diatheke "/usr/bin/diatheke"
20 set dict "/usr/bin/dict"
24 proc publookupverse {vlookup} {
25 global botnick chan bibver diatheke
28 set n [
string first "@" $vlookup]
29 if {$n > -1 && $n < 2} {
33 set n [
string first "#" $vlookup]
34 if {$n > -1 && $n < 2} {
37 set vlookup [
string trimleft $vlookup "#"]
38 set vlookup [
string trimleft $vlookup "@"]
39 set vlookup [
string trimleft $vlookup "#"]
41 regsub -all {[\[\]\{\}\#\%\\\$\'\"\/\s]} $vlookup { } vlookup
42 catch {exec $diatheke -f plaintext -o $arg -b $bibver -k "$vlookup" >& /tmp/fooout.$botnick}
43 catch {set foofile [open /tmp/fooout.$botnick]}
44 while {[gets $foofile fooverse] >= 0} {
45 set len [
string length $fooverse]
49 if {[regexp ">" $fooverse]} {
50 while {[string index $fooverse $j] != ">" && [
string index $fooverse $j] != "\n"} {
set j [
expr $j - 1]}
52 while {[string index $fooverse $j] != " " && [
string index $fooverse $j] != "\n"} {
set j [
expr $j - 1]}
54 set foo2 [
string range $fooverse $i $j]
55 set foo2 [
string trim $foo2]
56 regsub -all -nocase {(<FI>|<CM>|<FB>)} $foo2 {} foo2
57 regsub -all {<RF>} $foo2 {(footnote: } foo2
58 regsub -all {<Rf>} $foo2 {)} foo2
62 if {$j > $len} {
set j $len}
64 set foo2 [
string range $fooverse $i end]
65 set foo2 [
string trim $foo2]
66 regsub -all -nocase {(<FI>|<CM>|<FB>)} $foo2 {} foo2
67 regsub -all {<RF>} $foo2 {(footnote: } foo2
68 regsub -all {<Rf>} $foo2 {)} foo2
72 catch {close $foofile}
73 exec rm /tmp/fooout.$botnick
77 proc pub_lookup {nick uhost hand channel arg} {
78 global von chan bibver
81 putmsg $nick "Verse display is currently off."
84 if {($von==2) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
85 putmsg $nick "Only ops can display verses at this time."
94 proc pubsearchword {vlookup} {
95 global botnick chan bibver diatheke
96 regsub -all {[\[\]\{\}\#\%\\\$\'\"\/\s]} $vlookup { } vlookup
97 catch {exec $diatheke -s $bibver "$vlookup" >& /tmp/fooout.$botnick}
98 catch {set foofile [open /tmp/fooout.$botnick]}
100 while {[gets $foofile fooverse] >= 0} {
101 set len [
string length $fooverse]
105 while {[string index $fooverse $j] != ";" && [
string index $fooverse $j] != ")" && [
string index $fooverse $j] != "\n"} {
set j [
expr $j + 1]}
106 set foo2 [
string range $fooverse $i $j]
107 set foo2 [
string trim $foo2]
111 if {$j > $len} {
set j $len}
113 set foo2 [
string range $fooverse $i end]
114 set foo2 [
string trim $foo2]
117 catch {close $foofile}
119 putmsg $chan "$fooverse"
120 exec rm /tmp/fooout.$botnick
124 proc pub_lookups {nick uhost hand channel arg} {
125 global von chan bibver
128 putmsg $nick "Verse display is currently off."
131 if {($von==3) && (![matchattr $hand 3]) && (![matchattr $hand o]) && (![isvoice $nick $chan])} {
132 putmsg $nick "Sorry, only ops and voiced users can do searches right now."
135 if {($von==2) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
136 putmsg $nick "Sorry, only ops can do searches right now."
145 proc publookupdict {vlookup} {
146 global botnick chan bibver diatheke
147 regsub -all {[\[\]\{\}\#\%\\\$\'\"\/\s]} $vlookup { } vlookup
148 catch {exec $diatheke -f plaintext -b $bibver -k "$vlookup" >& /tmp/fooout.$botnick}
149 catch {set foofile [open /tmp/fooout.$botnick]}
151 while {[gets $foofile fooverse] >= 0} {
152 putmsg $chan "$fooverse"
154 catch {close $foofile}
155 exec rm /tmp/fooout.$botnick
159 proc pub_lookupd {nick uhost hand channel arg} {
160 global von chan bibver
163 putmsg $nick "Verse display is currently off."
166 if {($von==3) && (![matchattr $hand 3]) && (![matchattr $hand o]) && (![isvoice $nick $chan])} {
167 putmsg $nick "Sorry, only ops and voiced users can use dictionaries and indices right now."
170 if {($von==2) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
171 putmsg $nick "Sorry, only ops can use dictionaries and indices right now."
192 proc publookupcomm {vlookup} {
193 global botnick chan bibver diatheke
194 regsub -all {[\[\]\{\}\#\%\\\$\'\"\/\s]} $vlookup { } vlookup
195 catch {exec $diatheke -c $bibver "$vlookup" >& /tmp/fooout.$botnick}
196 catch {set foofile [open /tmp/fooout.$botnick]}
197 while {[gets $foofile fooverse] >= 0} {
198 set len [
string length $fooverse]
202 while {[string index $fooverse $j] != " " && [
string index $fooverse $j] != "\n"} {
set j [
expr $j + 1]}
203 set foo2 [
string range $fooverse $i $j]
204 set foo2 [
string trim $foo2]
205 regsub -all -nocase {(<FI>|<CM>|<FB>)} $foo2 {} foo2
206 regsub -all {<RF>} $foo2 {(footnote: } foo2
207 regsub -all {<Rf>} $foo2 {)} foo2
211 if {$j > $len} {
set j $len}
213 set foo2 [
string range $fooverse $i end]
214 set foo2 [
string trim $foo2]
215 regsub -all -nocase {(<FI>|<CM>|<FB>)} $foo2 {} foo2
216 regsub -all {<RF>} $foo2 {(footnote: } foo2
217 regsub -all {<Rf>} $foo2 {)} foo2
220 catch {close $foofile}
221 exec rm /tmp/fooout.$botnick
225 proc pub_lookupc {nick uhost hand channel arg} {
226 global von chan bibver
229 putmsg $nick "Verse display is currently off."
232 if {($von==3) && (![matchattr $hand 3]) && (![matchattr $hand o]) && (![isvoice $nick $chan])} {
233 putmsg $nick "Sorry, only ops and voiced users can use commentaries right now."
236 if {($von==2) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
237 putmsg $nick "Sorry, only ops can use commentaries right now."
246 bind pub - !dict dictlookup
248 proc dictlookup {nick uhost hand channel arg} {
249 global botnick von dict
252 putmsg $nick "Verse display is currently off."
255 if {($von==3) && (![matchattr $hand 3]) && (![matchattr $hand o]) && (![isvoice $nick $channel])} {
256 putmsg $nick "Sorry, only ops and voiced users can use dictionaries and indices right now."
259 if {($von==2) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
260 putmsg $nick "Only ops can use dictionaries and indices right now."
264 regsub -all {[\[\]\{\}\#\%\\\$\'\"\/\s]} $arg { } arg
265 catch {exec $dict "$arg" >& /tmp/fooout.$botnick}
266 catch {set foofile [open /tmp/fooout.$botnick]}
267 catch {set fooverse [
gets $foofile]}
268 while {[gets $foofile fooverse] >= 0} {
269 set fooverse [
string trim $fooverse]
270 putmsg $channel "$fooverse"
272 catch {close $foofile}
273 exec rm /tmp/fooout.$botnick
279 bind pub - !biblehelp pub_help
280 bind msg - biblehelp pub_help
282 proc pub_help {nick uhost hand channel arg} {
285 putserv "NOTICE $nick :Diatheke/Tcl BibleBot version $diaver"
287 if {(($von==0) || ($von==2)) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
288 putserv "NOTICE $nick :BibleBot displays are currently turned off."
292 putserv "NOTICE $nick :Supported commands:"
293 putserv "NOTICE $nick :Help, using \"!biblehelp\""
294 putserv "NOTICE $nick :Book list, using \"!books\" (it's long)"
295 putserv "NOTICE $nick :Check display status, using \"!status\""
296 putserv "NOTICE $nick :Bible lookups, using \"!<bible version> <book> <chapter>:<verse>\""
297 putserv "NOTICE $nick :verse ranges can be specified by adding \"-<last verse>\" to this"
298 putserv "NOTICE $nick :To turn Strong's numbers and/or footnotes on, use @ and/or # respectively before the book name. For example \"!kjv @#Gen 1:4\" will retrieve Genesis 1:3 with the Strong's numbers and footnotes associated with it."
300 if {($von==3) && (![matchattr $hand 3]) && (![matchattr $hand o]) && (![isvoice $nick $channel])} {
304 putserv "NOTICE $nick :Commentary lookups, using \"!<commentary> <book> <chapter>:<verse>\""
305 putserv "NOTICE $nick :Dictionary/index lookups, using \"!<dictionary> <word or number>\""
306 putserv "NOTICE $nick :Bible searches, using \"!s<bible version> <word>\""
307 putserv "NOTICE $nick :Diatheke/Tcl defaults to PHRASE search mode. To use MULTI-WORD search mode, preface your search with an @. To use REGEX mode, preface your search with a #. For example: \"!skjv @Jesus love\" will print a list of all verses in the KJV containing the words Jesus and love."
309 if {(![matchattr $hand 3]) && (![matchattr $hand o])} {
313 putserv "NOTICE $nick :To turn verse display off, use \"!verseoff\""
314 putserv "NOTICE $nick :To turn all displays on for all users, use \"!verseon\""
315 putserv "NOTICE $nick :To turn all displays on for ops only, use \"!verseon o\""
316 putserv "NOTICE $nick :To turn verse diaplays on for regular users and all other displays on for ops and voiced users only, use \"!verseon v\" (default)"
319 bind pub - !books pub_books
320 bind msg - books pub_books
322 proc pub_books {nick uhost hand channel arg} {
325 if {(($von==0) || ($von==2)) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
326 putserv "NOTICE $nick :BibleBot displays are currently turned off."
332 if {($von==3) && (![matchattr $hand 3]) && (![matchattr $hand o]) && (![isvoice $nick $channel])} {
342 bind pub - !status pub_status
343 bind msg - status pub_status
345 proc pub_status {nick uhost hand channel arg} {
349 putserv "NOTICE $nick :All BibleBot displays are currently off."
351 putserv "NOTICE $nick :All BibleBot displays are currently on."
353 putserv "NOTICE $nick :All BibleBot displays are currently on for ops only."
355 putserv "NOTICE $nick :Verse displays are currently on for all users, but other BibleBot displays are currently restricted to ops and voiced users."
362 proc pub_verseon {nick uhost hand channel arg} {
364 if {![matchattr $hand 3] && ![matchattr $hand o]} {
366 }
elseif {$arg=="v"} {
369 }
elseif {$arg=="o"} {
379 bind pub - !verseon pub_verseon
380 bind msg - verseon pub_verseon
382 proc pub_verseoff {nick uhost hand channel arg} {
385 if {![matchattr $hand 3] && ![matchattr $hand o]} {
393 bind pub - !verseoff pub_verseoff
394 bind msg - verseoff pub_verseoff
396 proc dcc_verseoff {hand idx arg} {
399 if {![matchattr $hand 3] && ![matchattr $hand o]} {
406 bind dcc - verseoff dcc_verseoff
408 proc dcc_verseon {hand idx arg} {
410 if {![matchattr $hand 3] && ![matchattr $hand o]} {
423 bind dcc - verseon dcc_verseon