# Set your channel here so the bot can msg it
set yourchan "#somedays"
# leave this alone this is needed to .chanset #channel +torrent
setudef flag torrent
# Set the torrent db and templist here
set torrent_db "tlist.db"
set torrent_temp "templist.db"
# Public bind commands
bind pub - !tadd torrent_add
bind pub - !thelp torrent_help
bind pub - !info torrent_info
bind pub - !stats torrent_stats
# Dcc Chat commands
bind dcc p checktemp dcc_torrent_check_temp
proc torrent_add {nick host hand chan arg} {
global site torrent_temp
if {[ischanset $chan "+torrent"]} {
set site [lindex $arg 0]
putserv "NOTICE $nick :$nick The torrent site has been added to the templist, please wait untell an admin checks it."
putserv "PRIVMSG $chan :New torrent site in the templist, an admin will check it soon."
addtemp
}
}
proc addtemp {} {
global torrent_temp file site
set file [open $torrent_temp a]
puts $file "Site: $site"
close $file
return 0
}
proc torrent_help {hand uhost nick chan arg} {
if {[ischanset $chan "+torrent"]} {
putserv "PRIVMSG $chan :To add a torrent site type: !tadd site <info about what they serv> <signup_info>."
}
}
proc torrent_info {nick host hand chan text} {
global torrent_db botnick site
set find [lrange [split $text] 0 end]
set fid [open $torrent_db r]
set data [read $fid]
set data1 [string tolower [split $data "\n"]]
set data2 [lsearch -inline -all $data1 *$find*]
if {$data2 == ""} {
putserv "NOTICE $nick : Sorry nothing was found!"
return
}
set data3 [lindex $data2 [rand [llength $data2]]]
set results [split $data3]
close $fid
putserv "PRIVMSG $chan :$results"
}
proc torrent_stats {nick host hand chan text} {
global torrent_db
if {[ischanset $chan "+torrent"]} {
set linecount 0
set input [open $torrent_db r]
set lines [split [read $input] \n]
catch {close $input}
foreach line $lines {
incr linecount
}
puthelp "PRIVMSG $chan :i have toldel of $linecount Torrent sites in my database."
}
}
proc dcc_torrent_check_temp {args} {
global checktemp torrent_temp l yourchan
checktemp
foreach l [checktemp $torrent_temp] {
putlog "$l"
putserv "PRIVMSG $yourchan :An admin is checking the templist, please hold while the sites are being checked then added."
}
}
proc checktemp {args} {
global torrent_temp
set file [open "$torrent_temp" r]
set data [read -nonewline $file]
close $file
return "[split $data \n]"
}