#
# upload the 'pda.tcl' to your shell in the 'scripts/' directory of your eggdrop
# load the script by adding 'source scripts/pda.tcl' to eggdrop's config file
# .rehash the eggdrop
# and type '!addtext' in the (public) channel where the eggdrop is
#
##
proc pda {what} {
global pda pdacount
switch -- [string tolower [lindex [split $what] 0]] {
"get_id" {
set string [join [lrange [split $what] 1 end]]
foreach ids [array names pda] {
set tt [join [lrange [split $pda($ids) ","] 3 end]]
if {[string match -nocase "$tt" "$string"]} {
return $ids
}
}
}
"valid_id" {return [info exists pda([lindex [split $what] 1])]}
"kill_id" {
set pid [lindex [split $what] 1]
if {[info exists pda($pid)]} {
unset pda($pid)
pda_killtimers -matching "*$pid*"
return 1
} else {
return 0
}
}
"display_id" {
set did [lindex [split $what] 1]
if {[info exists pda($did)]} {
set chan [join [lrange [split $pda($did) ","] 1 1]]
set rest [join [lrange [split $pda($did) ","] 3 end]]
puthelp "PRIVMSG $chan :$rest"
unset pda($did)
return
} else {
error "PDA: \"$did\" is not a valid ID"
}
}
"current_id" {
if {![info exists pdacount(current)]} {
set pdacount(current) 1
return $pdacount(current)
} else {
set pdacount(current) [expr {$pdacount(current)+1}]
return $pdacount(current)
}
}
default {error "should be: pda \[what\]"}
}
}
proc pda_killtimers {type {args ""}} {
global pda
switch -- [string tolower $type] {
"-matching" {
if {$args != ""} {
foreach t [timers] {
set sc [lindex $t 1]
if {[string match -nocase "*$sc*" "$args"]} {
killtimer [lindex $t 2]
}
}; return 1
} else {
return 0
}
}
"-all" {
foreach t [timers] {
set ss [lindex $t 1]
if {[string match -nocase "*pda*" "$ss"]} {
killtimer [lindex $t 2]
}
}
}
default {
error "invalid type: should be: pda_killters ?-all? ?-matching? ?string?"
}
}
}
proc addtext:pub {nick uhost hand chan text} {
global pda
if {[isop $nick $chan]} {
if {[llength [lindex [split $text] 0]] == 0} {
puthelp "NOTICE $nick :\002Usage\002: !addtext \[Text\] \[Time\]"
return 0
}
if {![regexp -- {^([0-9]*[dhm])([0-9]*[dhm])?([0-9]*[dhm])?$} "[join [lrange [split $text] end end]]"]} {
puthelp "NOTICE $nick :\002Error\002: No Time Given/Invaild Time"
return 0
}
set t_note [join [lrange [split $text] 0 end-1]]
set t_time [join [lrange [split $text] end end]]
set e $t_time
if {($e == "") || ($e == 0)} {
puthelp "NOTICE $nick :\002Error\002: Time to low or invalid."
return 0
}
if {![regexp -- {([0-9]*)m} "$e" -> min] || ($min == "")} {set min 0}
if {![regexp -- {([0-9]*)h} "$e" -> hour] || ($hour == "")} {set hour 0}
if {![regexp -- {([0-9]*)d} "$e" -> day] || ($day == "")} {set day 0}
set t_hours [expr ($min*60)+($hour*3600)+($day*86400)]
set t_mins [expr {$t_hours/60}]
if {$t_mins>0} {
set t_ts [clock scan "$t_mins min"]
set id [pda current_id]
set pda($id) "$nick,$chan,$t_ts,$t_note"
timer $t_mins [list pda "display_id $id"]
puthelp "NOTICE $nick :Thank You, '$t_note' has been added."
return 1
} else {
puthelp "NOTICE $nick :\002Error\002: Time to lower"
return 0
}
}
}
proc text:pub {nick uhost hand chan text} {
global pda
if {[llength [array names pda]] == 0} {
puthelp "PRIVMSG $chan :\002No Text's\002"
puthelp "PRIVMSG $chan :Please add one by typing \002!addtext <text> <time>\002 (Ops Only!)"
return 1
} else {
set m [llength [array names pda]]
set c 0
while {$c != $m} {
set id [lindex [array names pda] $c]
set t_by [lindex [split $pda($id) ","] 0]
set t_ch [lindex [split $pda($id) ","] 1]
set t_ts [lindex [split $pda($id) ","] 2]
set t_note [join [lrange [split $pda($id) ","] 3 end]]
puthelp "PRIVMSG $chan :\002$t_note\002 Added By $t_by@$t_ch [duration [expr { $t_ts - [clock seconds]}]] ago. (#ID:$id)"
set c [expr {$c+1}]
}
return 1
}
}
proc deltext:pub {nick uhost hand chan text} {
global pda
set string [lindex [split $text] 0]
if {$string == ""} {
puthelp "NOTICE $nick :USage: !deltext <id | *string*>"
return 0
}
if {[regexp {^[0-9]} "$string"]} {
set gid $string
if {[pda "valid_id $gid"]} {
if {[pda "kill_id $gid"]} {
puthelp "NOTICE $nick :Removed '$gid'"
return 1
} else {
puthelp "NOTICE $nick :Failed (unable to remove '$gid')"
return 0
}
} else {
puthelp "NOTICE $nick :unable to find '$gid' --it may be invalid"
return 0
}
} else {
set gid [pda "get_id $string"]
if {[pda "valid_id $gid"]} {
if {[pda "kill_id $gid"]} {
puthelp "NOTICE $nick :Removed '$string' ($gid)"
return 1
} else {
puthelp "NOTICE $nick :Failed (unable to remove '$string')"
return 0
}
} else {
puthelp "NOTICE $nick :unable to find '$string' --it may be invalid"
return 0
}
}
}
bind pub o !addtext addtext:pub
bind pub n !deltext deltext:pub
bind pub - !text text:pub
putlog "loaded pda.tcl version 2.6(alpha) by TCL_no_TK"
return
I've got it working without any errors that would cause problems for the bot, or prevent the scrip from working. If you get an error thats not in the script, let me know and i'll try and fix it.