# Bible.tcl # Version: 0.01 # Author: jrmu # # Description: # Over 100+ translations of the Bible # Except where otherwise specified, this entire work has been dedicated to the # public domain by the authors. Permission is granted to use, copy, modify, # and/or distribute this work for any purpose with or without fee. This work # is offered as-is, with absolutely no warranty whatsoever. The author is not # responsible for any damages that result from using this work. bind msg - !help help bind pub - !help help bind msg - !list listb bind pub - !list listb bind msgm - * lookup bind pubm - * lookup proc verse {trans book chap verse} { set book [format %02s [bookind $book]]; set chap [format %03s $chap]; set verse [format %03s $verse]; set infile [open "scripts/Bibles/${trans}" r] while { [gets $infile line] >= 0 } { if { [regexp "$book:$chap:$verse: (.*)" $line match text] } { close $infile return "$text" } } } proc bookind {name} { set infile [open "scripts/Bibles/books" r] while { [gets $infile line] >= 0 } { if { [regexp -nocase {^abb} $line] || [regexp -nocase {^en} $line] } { set books [split [regsub -all {, } $line ","] ","] for {set i 0} {$i < [llength $books]} {incr i} { if { [regexp -nocase $name [lindex $books $i]] } { close $infile return $i; } } } } } proc help {nick uhost hand args} { putserv "PRIVMSG $nick :!help -- show help menu"; putserv "PRIVMSG $nick :!list -- show list of translations. For example, to show all English translations: !list English"; putserv "PRIVMSG $nick :! : -- quote passage. For example, !kjv John 1:1"; } proc listb {nick uhost hand args} { if {[llength $args] == 1} { set target $nick; set text [lindex $args 0]; } elseif {[llength $args] == 2} { set target [lindex $args 0]; set text [lindex $args 1]; } if {[string length $text] < 5} { putserv "PRIVMSG $nick :Please type the full language name, such as: !list Chinese, !list Russian, !list Arabic"; return; } set infile [open "scripts/Bibles/LICENSE" r] while { [gets $infile line] >= 0 } { if { [regexp -nocase {^(Name): (.*)} $line match key val] } { set name $val; } elseif { [regexp -nocase {^([-_a-zA-Z0-9 ]+): (.*)} $line match key val] } { set tr($name,$key) $val; } } foreach {key val} [array get tr] { if { [regexp -nocase $text $val] } { if ([regexp {([^,]+),Language} $key match key]) { putserv "PRIVMSG $nick :$key: !$tr($key,File) :"; } } } } proc lookup {nick uhost hand args} { if {[llength $args] == 1} { set target $nick; set text [lindex $args 0]; } elseif {[llength $args] == 2} { set target [lindex $args 0]; set text [lindex $args 1]; } 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] } { if {$skip eq ""} { set verseEnd $verseStart; } if {![info exists trans]} { set trans "en-asv"; putlog "$trans $book $chap $verseStart $verseEnd"; } for {} {$verseStart <= $verseEnd} {incr verseStart} { if { [string length $v] > 0 } { set v [verse $trans $book $chap $verseStart]; putserv "PRIVMSG $target :$v"; } } } putlog "$nick :$text" } putlog "Bible.tcl v0.01 from IRCNow"