Script
Code: Select all
# Fortune Interface
# by BarkerJr <http://barkerjr.net>
catch Fortune::uninstall
namespace eval Fortune {
##### SETTING #####
# Uncomments (remove the # from) the following set commands if you wish to
# change the defaults.
# Set this to what you wish to profex the command with ("" for none)
set cmdchar "!"
# [0/1] send via NOTICE (1=notice, 0=privmsg)
set notice 0
##### THE SCRIPT #####
if {[info exists notice]} {
if {($notice != 0) && ($notice != 1)} {
set notice 0
putlog "WARNING: Fortune::notice must be 0 or 1\
(setting to default of $notice)"
}
} else { set notice 0 }
if {![info exists cmdchar]} { set cmdchar {!} }
bind pub - ${cmdchar}fortune Fortune::doit
proc doit {nick uhost hand chan arg} {
variable notice
switch -- $arg {
{a} {set fortune {-a}}
{c} {set fortune {-c}}
{o} {set fortune {-o}}
default {set fortune {}}
}
regsub -all \t [split [exec {fortune} $fortune] \n] { } fortune
if {$notice} { set way {NOTICE} } else { set way {PRIVMSG} }
foreach line $fortune { puthelp "$way $chan :$line" }
return 1
}
bind evnt - prerehash Fortune::uninstall
proc uninstall {args} {
variable cmdchar
catch "unbind pub - ${cmdchar}fortune Fortune::doit"
global cmdchar
catch "unbind pub - ${cmdchar}fortune Fortune::doit"
unbind evnt - prerehash Fortune::uninstall
namespace delete ::Fortune
}
}
Code: Select all
[14:46:10] Tcl error [Fortune::doit]: couldn't execute "fortune": no such file or directory
.set errorInfo
[14:46:27] #Carlin0# set errorInfo
Currently: couldn't execute "fortune": no such file or directory
Currently: while executing
Currently: "exec {fortune} $fortune"
Currently: (procedure "Fortune::doit" line 9)
Currently: invoked from within
Currently: "Fortune::doit $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"