Blame
Date:
Wed Dec 16 10:32:05 2020 UTC
Message:
Bug fix
001
2020-09-29
jrmu
# Bible.tcl
002
2020-09-29
jrmu
# Version: 0.01
003
2020-09-29
jrmu
# Author: jrmu <jrmu@ircnow.org>
004
2020-09-29
jrmu
#
005
2020-09-29
jrmu
# Description:
006
2020-09-29
jrmu
# Over 100+ translations of the Bible
007
2020-09-29
jrmu
# Except where otherwise specified, this entire work has been dedicated to the
008
2020-09-29
jrmu
# public domain by the authors. Permission is granted to use, copy, modify,
009
2020-09-29
jrmu
# and/or distribute this work for any purpose with or without fee. This work
010
2020-09-29
jrmu
# is offered as-is, with absolutely no warranty whatsoever. The author is not
011
2020-09-29
jrmu
# responsible for any damages that result from using this work.
012
2020-09-29
jrmu
013
2020-09-29
jrmu
bind msg - !help help
014
2020-09-29
jrmu
bind pub - !help help
015
2020-09-29
jrmu
bind msg - !list listb
016
2020-09-29
jrmu
bind pub - !list listb
017
2020-09-29
jrmu
bind msgm - * lookup
018
2020-09-29
jrmu
bind pubm - * lookup
019
2020-09-29
jrmu
020
2020-09-29
jrmu
proc verse {trans book chap verse} {
021
2020-09-29
jrmu
set book [format %02s [bookind $book]];
022
2020-09-29
jrmu
set chap [format %03s $chap];
023
2020-09-29
jrmu
set verse [format %03s $verse];
024
2020-09-29
jrmu
set infile [open "scripts/Bibles/${trans}" r]
025
2020-09-29
jrmu
while { [gets $infile line] >= 0 } {
026
2020-09-29
jrmu
if { [regexp "$book:$chap:$verse: (.*)" $line match text] } {
027
2020-09-29
jrmu
close $infile
028
2020-09-29
jrmu
return "$text"
029
2020-09-29
jrmu
}
030
2020-09-29
jrmu
}
031
2020-09-29
jrmu
}
032
2020-09-29
jrmu
033
2020-09-29
jrmu
proc bookind {name} {
034
2020-09-29
jrmu
set infile [open "scripts/Bibles/books" r]
035
2020-09-29
jrmu
while { [gets $infile line] >= 0 } {
036
2020-09-29
jrmu
if { [regexp -nocase {^abb} $line] || [regexp -nocase {^en} $line] } {
037
2020-09-29
jrmu
set books [split [regsub -all {, } $line ","] ","]
038
2020-09-29
jrmu
for {set i 0} {$i < [llength $books]} {incr i} {
039
2020-09-29
jrmu
if { [regexp -nocase $name [lindex $books $i]] } {
040
2020-09-29
jrmu
close $infile
041
2020-09-29
jrmu
return $i;
042
2020-09-29
jrmu
}
043
2020-09-29
jrmu
}
044
2020-09-29
jrmu
}
045
2020-09-29
jrmu
}
046
2020-09-29
jrmu
}
047
2020-09-29
jrmu
proc help {nick uhost hand args} {
048
2020-09-29
jrmu
putserv "PRIVMSG $nick :!help -- show help menu";
049
2020-09-29
jrmu
putserv "PRIVMSG $nick :!list <language> -- show list of translations. For example, to show all English translations: !list English";
050
2020-09-29
jrmu
putserv "PRIVMSG $nick :!<translation> <book> <chapter>:<verse> -- quote passage. For example, !kjv John 1:1";
051
2020-09-29
jrmu
}
052
2020-09-29
jrmu
proc listb {nick uhost hand args} {
053
2020-09-29
jrmu
if {[llength $args] == 1} {
054
2020-09-29
jrmu
set target $nick;
055
2020-09-29
jrmu
set text [lindex $args 0];
056
2020-09-29
jrmu
} elseif {[llength $args] == 2} {
057
2020-09-29
jrmu
set target [lindex $args 0];
058
2020-09-29
jrmu
set text [lindex $args 1];
059
2020-09-29
jrmu
}
060
2020-09-29
jrmu
if {[string length $text] < 5} {
061
2020-09-29
jrmu
putserv "PRIVMSG $nick :Please type the full language name, such as: !list Chinese, !list Russian, !list Arabic";
062
2020-09-29
jrmu
return;
063
2020-09-29
jrmu
}
064
2020-09-29
jrmu
set infile [open "scripts/Bibles/LICENSE" r]
065
2020-09-29
jrmu
while { [gets $infile line] >= 0 } {
066
2020-09-29
jrmu
if { [regexp -nocase {^(Name): (.*)} $line match key val] } {
067
2020-09-29
jrmu
set name $val;
068
2020-09-29
jrmu
} elseif { [regexp -nocase {^([-_a-zA-Z0-9 ]+): (.*)} $line match key val] } {
069
2020-09-29
jrmu
set tr($name,$key) $val;
070
2020-09-29
jrmu
}
071
2020-09-29
jrmu
}
072
2020-09-29
jrmu
foreach {key val} [array get tr] {
073
2020-09-29
jrmu
if { [regexp -nocase $text $val] } {
074
2020-09-29
jrmu
if ([regexp {([^,]+),Language} $key match key]) {
075
2020-09-29
jrmu
putserv "PRIVMSG $nick :$key: !$tr($key,File) <book> <chapter>:<verse>";
076
2020-09-29
jrmu
}
077
2020-09-29
jrmu
}
078
2020-09-29
jrmu
}
079
2020-09-29
jrmu
}
080
2020-09-29
jrmu
proc lookup {nick uhost hand args} {
081
2020-09-29
jrmu
if {[llength $args] == 1} {
082
2020-09-29
jrmu
set target $nick;
083
2020-09-29
jrmu
set text [lindex $args 0];
084
2020-09-29
jrmu
} elseif {[llength $args] == 2} {
085
2020-09-29
jrmu
set target [lindex $args 0];
086
2020-09-29
jrmu
set text [lindex $args 1];
087
2020-09-29
jrmu
}
088
2020-09-29
jrmu
if { [regexp {([a-zA-Z]+-[a-zA-Z0-9]+) ([0-9]*[ A-Za-z0-9]*) (\d+):(\d+)(-(\d+))?} $text match trans book chap verseStart skip verseEnd] || [regexp {([0-9]*[ A-Za-z0-9]*) (\d+):(\d+)(-(\d+))?} $text match book chap verseStart skip verseEnd] } {
089
2020-09-29
jrmu
if {$skip eq ""} {
090
2020-09-29
jrmu
set verseEnd $verseStart;
091
2020-09-29
jrmu
}
092
2020-09-29
jrmu
if {![info exists trans]} {
093
2020-09-29
jrmu
set trans "en-asv";
094
2020-09-29
jrmu
putlog "$trans $book $chap $verseStart $verseEnd";
095
2020-09-29
jrmu
}
096
2020-09-29
jrmu
for {} {$verseStart <= $verseEnd} {incr verseStart} {
097
2020-10-02
jrmu
if { [string length $v] > 0 } {
098
2020-12-16
jrmu
set v [verse $trans $book $chap $verseStart];
099
2020-10-02
jrmu
putserv "PRIVMSG $target :$v";
100
2020-10-02
jrmu
}
101
2020-09-29
jrmu
}
102
2020-09-29
jrmu
}
103
2020-09-29
jrmu
putlog "$nick :$text"
104
2020-09-29
jrmu
}
105
2020-09-29
jrmu
106
2020-09-29
jrmu
putlog "Bible.tcl v0.01 from IRCNow"