This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Memo System Problem....

Old posts that have not been replied to for several years.
Locked
s
sorgente

Memo System Problem....

Post by sorgente »

Code: Select all

set memo_userfile "scripts/memo.userfile"
set memo_msgfile "scripts/memo.messages"
set memo_botsname "botnick"

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 :Sie haben neue Nachrichten"
	putserv "NOTICE $nick :/msg $memo_botsname .get <password>"
    }
}

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
	} else {
	    putserv "NOTICE $nick : Ihre Mailbox ist bereits vorhanden!"
	}
    }
}

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 :Sie haben keine Mailbox eingerichtet!"
	putserv "NOTICE $nick :/msg $memo_botsname .new <password> command zum installieren"
    }

    if {[get $getnick $memo_userfile]!=$password} {
	putserv "NOTICE $nick : Invalid password"
    } else {
	set message [get $getnick $memo_msgfile]
	if {$message == "" } {
	    putserv "NOTICE $nick : Sie haben keine neue Nachrichten"
	} 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 #Easy.bnc <apex>";
    putserv "NOTICE $dest :/msg $memo_botsname .send <nick> <message> to send a message"
}

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
}
I have a little problem with these TCL script..
When a user wrote a sentence, then save the script this.
When another user ( ~5mins later ) which another sentence....
So Overwrite the Script the Last sentence in the memo.messages file...
And i don't know was the user write to me... Ohnly One Sentence was safed in the file and no more....

How Can i Change, that the Script safe all Sentences that post a user in a file with Date and Time...

so far.... thanks to help
Locked