Code: Select all
####################################################
# Quran #
####################################################
### Variables
set quran(interval) "2"
set quran(intervall) "20"
set quran(characters) "190"
set quran(database.txt) "tmp/Quran.txt"
### Events
bind pub - "!quran" quran:proc
bind pub - "!autoplay" autoplay:proc
### Commands
proc quran:proc {nick uhost handle chan text} {
global quran
if {[lindex [split "$text" ":"] 0] != "" && [lindex [split "$text" ":"] 1] != ""} {
if {[file exists "$quran(database.txt)"] == "1"} {
set quran(found) "NO"
set txt "[open "$quran(database.txt)" r]"
for {set x 0} {![eof $txt]} {incr x} {
gets $txt line
if {[lindex [split "$text" ":"] 0] == [lindex [split $line ":"] 1] && [lindex [split "$text" ":"] 1] == [lindex [split $line ":"] 2]} {
set quran(found) "YES"
set line "[lindex [split $line "¤"] 0]"
if {[string length "$line"] > "200"} { quran:divide $nick $chan $line } else { puthelp "PRIVMSG $chan :[lindex "$line" 0] [lrange "$line" 1 end]" }
break
}
}
if {$quran(found) == "NO"} { puthelp "PRIVMSG $chan :INVALID ENTRY: Retry!" }
close $txt
} else { putlog "ERROR: File \"$quran(database.txt)\" not found!" }
} else { puthelp "PRIVMSG $chan :Use: !quran <Surah>:<Ayat>" }
}
proc quran:divide {nick chan text} {
global quran
set word "1"
set sentence "1"
while {$sentence <= [expr [string length "$text"] / $quran(characters)]} {
set line "[lindex "$text" $word]"
while {$word < "2000"} {
incr word
set line "$line [lindex "$text" $word]"
if {[string length "$line"] > "$quran(characters)"} { utimer [expr $sentence * $quran(interval)] "puthelp {PRIVMSG $chan :[lindex "$text" 0] $line}" ; break }
}
incr word
incr sentence
}
if {[lrange "$text" $word end] != ""} { utimer [expr $sentence * $quran(interval)] "puthelp {PRIVMSG $chan :[lindex "$text" 0] [lrange "$text" $word end]}" }
}
proc autoplay:proc {nick uhost handle chan text} {
global quran
if {[isop $nick $chan] || [isvoice $nick $chan]} {
if {$text != ""} {
if {$text == "stop"} {
foreach utimer [utimers] { if {[string match "*quran:proc *" $utimer]} { killutimer [lindex $utimer end] } }
puthelp "PRIVMSG $chan :All TIMERS stopped!"
} else {
foreach utimer [utimers] { if {[string match "*quran:proc *" $utimer]} { puthelp "PRIVMSG $chan :Busy: Retry later!" ; return 0 } }
if {[file exists "$quran(database.txt)"] == "1"} {
set t "0"
set quran(found) "NO"
set txt "[open "$quran(database.txt)" r]"
for {set x 0} {![eof $txt]} {incr x} {
gets $txt line
if {$text == [lindex [split $line ":"] 1]} {
set quran(found) "YES"
utimer [expr $t * $quran(intervall)] "quran:proc $nick $uhost $handle $chan [lindex [split $line ":"] 1]:[lindex [split $line ":"] 2]"
incr t
}
}
if {$quran(found) == "NO"} { puthelp "PRIVMSG $chan :INVALID ENTRY: Retry!" }
close $txt
} else { putlog "ERROR: File \"$quran(database.txt)\" not found!" }
}
} else { puthelp "PRIVMSG $chan :Use: !autoplay <Surah>" }
}
}
putlog "TCL Quran.tcl Loaded!"
I have already uploaded the Database see the link please. Database means the whole Quran, which is not easy to write.awyeah wrote:This script is a normal script saying out random lines at different intervals and reads a database from the text file @ "tmp/Quran.txt"
So basically Hesham, you have to build your own database (if you cannot find an archive online) and the rest you can use this script (rather obsolete and too over complicated though) display your ayat and hadeeth lines from quran on your channels.