Hi, does any one know working memo tcl for all users??
advance thanks
Code: Select all
# MemoScript v1.0
# This script saves memos from user to user
# Onjoin - script checks for messages
#
# Syntax (msg):
# !send nick message send a message to nick
# !get [nickname] password get messages using [nickname] or current nickname and password
# !new password new mailbox with password
#
#############
set memo_userfile "scripts/memo.userfile"
set memo_msgfile "scripts/memo.messages"
set memo_botsname "|TpE-cs|"
bind join - * eggmemo_checkmsg
proc eggmemo_checkmsg {nick host hand channel} {
global memo_msgfile
global memo_botsname
if {[get $nick $memo_msgfile]!=""} {
putserv "NOTICE $nick :You have new messages"
putserv "NOTICE $nick :/msg $memo_botsname !get <password> to retrieve"
}
}
bind msgm - "!new*" eggmemo_new
proc eggmemo_new {nick host hand text} {
# new mailbox
global memo_userfile
set password [lindex $text 1]
if {$password==""} {
putserv "NOTICE $nick : No password given";
} else {
if {[get $nick $memo_userfile] == ""} {
add $nick $password $memo_userfile
putserv "NOTICE $nick : Your mailbox has been created"
} else {
putserv "NOTICE $nick : Your mailbox already exists"
}
}
}
bind msgm - "!get*" eggmemo_get
proc eggmemo_get {nick host hand text} {
# get yer own messages
global memo_msgfile
global memo_userfile
global memo_botsname
set password [lindex $text 2]
set getnick [lindex $text 1]
if {$password == ""} {
set password [lindex $text 1]
set getnick $nick
}
if {[get $getnick $memo_userfile]==""} {
putserv "NOTICE $nick :You have not setup a mailbox."
putserv "NOTICE $nick :/msg $memo_botsname !new <password> to setup"
}
if {[get $getnick $memo_userfile]!=$password} {
putserv "NOTICE $nick : Invalid password"
} else {
set message [get $getnick $memo_msgfile]
if {$message == "" } {
putserv "NOTICE $nick : You have no messages"
} else {
putserv "NOTICE $nick : $message"
remove $getnick $memo_msgfile
set message [get $getnick $memo_msgfile]
while {$message != ""} {
putserv "NOTICE $nick : $message"
remove $getnick $memo_msgfile
}
}
}
}
bind msg - !memohelp eggmemo_help
proc eggmemo_help {nick host hand text} {
global memo_botsname
set dest $nick
putserv "NOTICE $dest :MemoScript by Krystar <yruan4@uic.edu>";
putserv "NOTICE $dest :/msg $memo_botsname !new <password> to setup mailbox under current nickname"
putserv "NOTICE $dest :/msg $memo_botsname !send <recipient> <message> to send a message"
putserv "NOTICE $dest :/msg $memo_botsname !get \133<nickname>\135 <password> to retrieve messages. optional nickname parameter"
}
bind msg - !send eggmemo_send
proc eggmemo_send {nick host hand text} {
global memo_msgfile
global memo_userfile
# send a message
set recipient [lindex $text 0]
set message "$nick says: [lrange $text 1 end]"
putserv "NOTICE $nick :Message sent"
putlog "message to $recipient: $message"
add $recipient $message $memo_msgfile
}
proc add {key value file} {
exec "touch" $file
set fh [open $file a]
puts $fh "$key => $value"
close $fh
}
proc get {key file} {
exec "touch" $file
set fh [open $file r]
set returnword {}
while {![eof $fh]} {
set stdin [string trim [gets $fh]]
if {[eof $fh]} { break }
set breaker [lsearch -exact $stdin "=>"]
set getkey [lrange $stdin 0 [expr $breaker - 1]]
set getresult [lrange $stdin [expr $breaker + 1] end]
if {[string tolower $getkey] == [string tolower $key]} { set returnword $getresult }
}
close $fh
return $returnword
}
proc remove {word file} {
exec "touch" $file
set fh [open $file r]
set return {}
set del 0
while {![eof $fh]} {
set stdin [string trim [gets $fh]]
if {[eof $fh]} { break }
if {![regexp -nocase $word $stdin]} {
lappend return $stdin
} {
incr del 1
}
}
close $fh;
set fh [open $file w]
foreach a $return {
puts $fh $a
}
close $fh
return $del
}