The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
biblebot-diatheke.tcl File Reference

Go to the source code of this file.

Functions

 dcc_verseoff hand idx arg
 
 dcc_verseon hand idx arg
 
 dictlookup nick uhost hand channel arg
 
 pub_books nick uhost hand channel arg
 
 pub_help nick uhost hand channel arg
 
 pub_lookup nick uhost hand channel arg
 
 pub_lookupc nick uhost hand channel arg
 
 pub_lookupd nick uhost hand channel arg
 
 pub_lookups nick uhost hand channel arg
 
 pub_status nick uhost hand channel arg
 
 pub_verseoff nick uhost hand channel arg
 
 pub_verseon nick uhost hand channel arg
 
 publookupcomm vlookup
 
 publookupdict vlookup
 
 publookupverse vlookup
 
 pubsearchword vlookup
 

Function Documentation

dcc_verseoff   hand idx arg  

Definition at line 396 of file biblebot-diatheke.tcl.

396 
397 proc dcc_verseoff {hand idx arg} {
398  global von
399  global whovoff
400  if {![matchattr $hand 3] && ![matchattr $hand o]} {
401  return 0
402  }
403  set von 0
404  set whovoff $hand
405  return 1
406 }
dcc_verseon   hand idx arg  

Definition at line 408 of file biblebot-diatheke.tcl.

408 
409 proc dcc_verseon {hand idx arg} {
410  global von
411  if {![matchattr $hand 3] && ![matchattr $hand o]} {
412  return 0
413  }
414  elseif {$arg=="v"} {
415  set von 3
416  }
417  elseif {$arg=="o"} {
418  set von 2
419  } else {
420  set von 1
421  }
422  return 1
423 }
dictlookup   nick uhost hand channel arg  

Definition at line 248 of file biblebot-diatheke.tcl.

248 
249 proc dictlookup {nick uhost hand channel arg} {
250  global botnick von dict
251 
252  if {$von==0} {
253  putmsg $nick "Verse display is currently off."
254  return 0
255  }
256  if {($von==3) && (![matchattr $hand 3]) && (![matchattr $hand o]) && (![isvoice $nick $channel])} {
257  putmsg $nick "Sorry, only ops and voiced users can use dictionaries and indices right now."
258  return 0
259  }
260  if {($von==2) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
261  putmsg $nick "Only ops can use dictionaries and indices right now."
262  return 0
263  }
264 
265  regsub -all {[\[\]\{\}\#\%\\\$\'\"\/\s]} $arg { } arg
266  catch {exec $dict "$arg" >& /tmp/fooout.$botnick}
267  catch {set foofile [open /tmp/fooout.$botnick]}
268  catch {set fooverse [gets $foofile]}
269  while {[gets $foofile fooverse] >= 0} {
270  set fooverse [string trim $fooverse]
271  putmsg $channel "$fooverse"
272  }
273  catch {close $foofile}
274  exec rm /tmp/fooout.$botnick
275  return 1
276 }
pub_books   nick uhost hand channel arg  

Definition at line 322 of file biblebot-diatheke.tcl.

322 
323 proc pub_books {nick uhost hand channel arg} {
324  global von
325 
326  if {(($von==0) || ($von==2)) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
327  putserv "NOTICE $nick :BibleBot displays are currently turned off."
328  return 1
329  }
330 
331  printBibles $nick
332 
333  if {($von==3) && (![matchattr $hand 3]) && (![matchattr $hand o]) && (![isvoice $nick $channel])} {
334  return 1
335  }
336 
337  printComms $nick
338  printDicts $nick
339 }
pub_help   nick uhost hand channel arg  

Definition at line 282 of file biblebot-diatheke.tcl.

282 
283 proc pub_help {nick uhost hand channel arg} {
284  global diaver
285  global von
286  putserv "NOTICE $nick :Diatheke/Tcl BibleBot version $diaver"
287 
288  if {(($von==0) || ($von==2)) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
289  putserv "NOTICE $nick :BibleBot displays are currently turned off."
290  return 1
291  }
292 
293  putserv "NOTICE $nick :Supported commands:"
294  putserv "NOTICE $nick :Help, using \"!biblehelp\""
295  putserv "NOTICE $nick :Book list, using \"!books\" (it's long)"
296  putserv "NOTICE $nick :Check display status, using \"!status\""
297  putserv "NOTICE $nick :Bible lookups, using \"!<bible version> <book> <chapter>:<verse>\""
298  putserv "NOTICE $nick :verse ranges can be specified by adding \"-<last verse>\" to this"
299  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 
301  if {($von==3) && (![matchattr $hand 3]) && (![matchattr $hand o]) && (![isvoice $nick $channel])} {
302  return 1
303  }
304 
305  putserv "NOTICE $nick :Commentary lookups, using \"!<commentary> <book> <chapter>:<verse>\""
306  putserv "NOTICE $nick :Dictionary/index lookups, using \"!<dictionary> <word or number>\""
307  putserv "NOTICE $nick :Bible searches, using \"!s<bible version> <word>\""
308  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 
310  if {(![matchattr $hand 3]) && (![matchattr $hand o])} {
311  return 1
312  }
313 
314  putserv "NOTICE $nick :To turn verse display off, use \"!verseoff\""
315  putserv "NOTICE $nick :To turn all displays on for all users, use \"!verseon\""
316  putserv "NOTICE $nick :To turn all displays on for ops only, use \"!verseon o\""
317  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)"
318 }
pub_lookup   nick uhost hand channel arg  

Definition at line 77 of file biblebot-diatheke.tcl.

77 
78 proc pub_lookup {nick uhost hand channel arg} {
79  global von chan bibver
80  set chan $channel
81  if {$von==0} {
82  putmsg $nick "Verse display is currently off."
83  return 0
84  }
85  if {($von==2) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
86  putmsg $nick "Only ops can display verses at this time."
87  return 0
88  }
89 
90  publookupverse $arg
91 }
pub_lookupc   nick uhost hand channel arg  

Definition at line 225 of file biblebot-diatheke.tcl.

225 
226 proc pub_lookupc {nick uhost hand channel arg} {
227  global von chan bibver
228  set chan $channel
229  if {$von==0} {
230  putmsg $nick "Verse display is currently off."
231  return 0
232  }
233  if {($von==3) && (![matchattr $hand 3]) && (![matchattr $hand o]) && (![isvoice $nick $chan])} {
234  putmsg $nick "Sorry, only ops and voiced users can use commentaries right now."
235  return 0
236  }
237  if {($von==2) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
238  putmsg $nick "Sorry, only ops can use commentaries right now."
239  return 0
240  }
241 
242  publookupcomm $arg
243 }
pub_lookupd   nick uhost hand channel arg  

Definition at line 159 of file biblebot-diatheke.tcl.

159 
160 proc pub_lookupd {nick uhost hand channel arg} {
161  global von chan bibver
162  set chan $channel
163  if {$von==0} {
164  putmsg $nick "Verse display is currently off."
165  return 0
166  }
167  if {($von==3) && (![matchattr $hand 3]) && (![matchattr $hand o]) && (![isvoice $nick $chan])} {
168  putmsg $nick "Sorry, only ops and voiced users can use dictionaries and indices right now."
169  return 0
170  }
171  if {($von==2) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
172  putmsg $nick "Sorry, only ops can use dictionaries and indices right now."
173  return 0
174  }
175 
176  publookupdict $arg
177 }
pub_lookups   nick uhost hand channel arg  

Definition at line 124 of file biblebot-diatheke.tcl.

124 
125 proc pub_lookups {nick uhost hand channel arg} {
126  global von chan bibver
127  set chan $channel
128  if {$von==0} {
129  putmsg $nick "Verse display is currently off."
130  return 0
131  }
132  if {($von==3) && (![matchattr $hand 3]) && (![matchattr $hand o]) && (![isvoice $nick $chan])} {
133  putmsg $nick "Sorry, only ops and voiced users can do searches right now."
134  return 0
135  }
136  if {($von==2) && (![matchattr $hand 3]) && (![matchattr $hand o])} {
137  putmsg $nick "Sorry, only ops can do searches right now."
138  return 0
139  }
140 
141  pubsearchword $arg
142 }
pub_status   nick uhost hand channel arg  

Definition at line 345 of file biblebot-diatheke.tcl.

345 
346 proc pub_status {nick uhost hand channel arg} {
347  global von
348 
349  if {$von==0} {
350  putserv "NOTICE $nick :All BibleBot displays are currently off."
351  } elseif {$von==1} {
352  putserv "NOTICE $nick :All BibleBot displays are currently on."
353  } elseif {$von==2} {
354  putserv "NOTICE $nick :All BibleBot displays are currently on for ops only."
355  } else {
356  putserv "NOTICE $nick :Verse displays are currently on for all users, but other BibleBot displays are currently restricted to ops and voiced users."
357  }
358  return 1
359 }
pub_verseoff   nick uhost hand channel arg  

Definition at line 382 of file biblebot-diatheke.tcl.

382 
383 proc pub_verseoff {nick uhost hand channel arg} {
384  global von
385 
386  if {![matchattr $hand 3] && ![matchattr $hand o]} {
387  return 0
388  }
389  set von 0
390 # putserv "NOTICE $nick :Verse Display is now off!"
391  pub_status $nick $uhost $hand $channel $arg
392  return 1
393 }
pub_verseon   nick uhost hand channel arg  

Definition at line 362 of file biblebot-diatheke.tcl.

362 
363 proc pub_verseon {nick uhost hand channel arg} {
364  global von
365  if {![matchattr $hand 3] && ![matchattr $hand o]} {
366  return 0
367  } elseif {$arg=="v"} {
368  set von 3
369 # putserv "NOTICE $nick :Long Text Display is now on for voiced only!"
370  } elseif {$arg=="o"} {
371  set von 2
372 # putserv "NOTICE $nick :Verse Display is now on for ops only!"
373  } else {
374  set von 1
375 # putserv "NOTICE $nick :All Display is now on!"
376  }
377  pub_status $nick $uhost $hand $channel $arg
378  return 1
379 }
publookupcomm   vlookup  

Definition at line 192 of file biblebot-diatheke.tcl.

192 
193 proc publookupcomm {vlookup} {
194  global botnick chan bibver diatheke
195  regsub -all {[\[\]\{\}\#\%\\\$\'\"\/\s]} $vlookup { } vlookup
196  catch {exec $diatheke -c $bibver "$vlookup" >& /tmp/fooout.$botnick}
197  catch {set foofile [open /tmp/fooout.$botnick]}
198  while {[gets $foofile fooverse] >= 0} {
199  set len [string length $fooverse]
200  set i 0
201  set j 72
202  while {$j < $len} {
203  while {[string index $fooverse $j] != " " && [string index $fooverse $j] != "\n"} {set j [expr $j + 1]}
204  set foo2 [string range $fooverse $i $j]
205  set foo2 [string trim $foo2]
206  regsub -all -nocase {(<FI>|<CM>|<FB>)} $foo2 {} foo2
207  regsub -all {<RF>} $foo2 {(footnote: } foo2
208  regsub -all {<Rf>} $foo2 {)} foo2
209  putmsg $chan "$foo2"
210  set i [expr $j + 1]
211  set j [expr $j + 73]
212  if {$j > $len} {set j $len}
213  }
214  set foo2 [string range $fooverse $i end]
215  set foo2 [string trim $foo2]
216  regsub -all -nocase {(<FI>|<CM>|<FB>)} $foo2 {} foo2
217  regsub -all {<RF>} $foo2 {(footnote: } foo2
218  regsub -all {<Rf>} $foo2 {)} foo2
219  putmsg $chan "$foo2"
220  }
221  catch {close $foofile}
222  exec rm /tmp/fooout.$botnick
223  return 1
224 }
publookupdict   vlookup  

Definition at line 145 of file biblebot-diatheke.tcl.

145 
146 proc publookupdict {vlookup} {
147  global botnick chan bibver diatheke
148  regsub -all {[\[\]\{\}\#\%\\\$\'\"\/\s]} $vlookup { } vlookup
149  catch {exec $diatheke -f plaintext -b $bibver -k "$vlookup" >& /tmp/fooout.$botnick}
150  catch {set foofile [open /tmp/fooout.$botnick]}
151 
152  while {[gets $foofile fooverse] >= 0} {
153  putmsg $chan "$fooverse"
154  }
155  catch {close $foofile}
156  exec rm /tmp/fooout.$botnick
157  return 1
158 }
publookupverse   vlookup  

Definition at line 24 of file biblebot-diatheke.tcl.

24 
25 proc publookupverse {vlookup} {
26  global botnick chan bibver diatheke
27 
28  set arg "-b"
29  set n [string first "@" $vlookup]
30  if {$n > -1 && $n < 2} {
31  append arg n
32  }
33 
34  set n [string first "#" $vlookup]
35  if {$n > -1 && $n < 2} {
36  append arg f
37  }
38  set vlookup [string trimleft $vlookup "#"]
39  set vlookup [string trimleft $vlookup "@"]
40  set vlookup [string trimleft $vlookup "#"]
41 
42  regsub -all {[\[\]\{\}\#\%\\\$\'\"\/\s]} $vlookup { } vlookup
43  catch {exec $diatheke -f plaintext -o $arg -b $bibver -k "$vlookup" >& /tmp/fooout.$botnick}
44  catch {set foofile [open /tmp/fooout.$botnick]}
45  while {[gets $foofile fooverse] >= 0} {
46  set len [string length $fooverse]
47  set i 0
48  set j 255
49  while {$j < $len} {
50  if {[regexp ">" $fooverse]} {
51  while {[string index $fooverse $j] != ">" && [string index $fooverse $j] != "\n"} {set j [expr $j - 1]}
52  } else {
53  while {[string index $fooverse $j] != " " && [string index $fooverse $j] != "\n"} {set j [expr $j - 1]}
54  }
55  set foo2 [string range $fooverse $i $j]
56  set foo2 [string trim $foo2]
57  regsub -all -nocase {(<FI>|<CM>|<FB>)} $foo2 {} foo2
58  regsub -all {<RF>} $foo2 {(footnote: } foo2
59  regsub -all {<Rf>} $foo2 {)} foo2
60  putmsg $chan "$foo2"
61  set i [expr $j + 1]
62  set j [expr $j + 256]
63  if {$j > $len} {set j $len}
64  }
65  set foo2 [string range $fooverse $i end]
66  set foo2 [string trim $foo2]
67  regsub -all -nocase {(<FI>|<CM>|<FB>)} $foo2 {} foo2
68  regsub -all {<RF>} $foo2 {(footnote: } foo2
69  regsub -all {<Rf>} $foo2 {)} foo2
70  putmsg $chan "$foo2"
71  }
72 
73  catch {close $foofile}
74  exec rm /tmp/fooout.$botnick
75  return 1
76 }
pubsearchword   vlookup  

Definition at line 94 of file biblebot-diatheke.tcl.

94 
95 proc pubsearchword {vlookup} {
96  global botnick chan bibver diatheke
97  regsub -all {[\[\]\{\}\#\%\\\$\'\"\/\s]} $vlookup { } vlookup
98  catch {exec $diatheke -s $bibver "$vlookup" >& /tmp/fooout.$botnick}
99  catch {set foofile [open /tmp/fooout.$botnick]}
100 
101  while {[gets $foofile fooverse] >= 0} {
102  set len [string length $fooverse]
103  set i 0
104  set j 72
105  while {$j < $len} {
106  while {[string index $fooverse $j] != ";" && [string index $fooverse $j] != ")" && [string index $fooverse $j] != "\n"} {set j [expr $j + 1]}
107  set foo2 [string range $fooverse $i $j]
108  set foo2 [string trim $foo2]
109  putmsg $chan "$foo2"
110  set i [expr $j + 1]
111  set j [expr $j + 73]
112  if {$j > $len} {set j $len}
113  }
114  set foo2 [string range $fooverse $i end]
115  set foo2 [string trim $foo2]
116  putmsg $chan "$foo2"
117  }
118  catch {close $foofile}
119 
120  putmsg $chan "$fooverse"
121  exec rm /tmp/fooout.$botnick
122  return 1
123 }