| View previous topic :: View next topic |
| Author |
Message |
salyn Voice

Joined: 17 Jun 2006 Posts: 6
|
Posted: Wed Jun 28, 2006 8:38 pm Post subject: publicnotes1.0.1 - help please? |
|
|
Script works great........except it won't erase the notes. ideas?
| Code: |
bind join - * onjoin_notes
bind msg - !erasenotes erase_notes
bind msg - !leavenote leave_notes
bind msg - !getnotes get_notes
bind msg - !noteshelp help_notes
bind msg - !delnotes erase_notes
bind msg - !sendnote leave_notes
bind msg - !notehelp help_notes
bind msg - !checknotes get_notes
bind msg - !notes help_notes
#This is the per user limit on notes received at one time (not sent! :).
set limitnotes 20
proc help_notes { nick uhost hand text } {
global botnick
puthelp "PRIVMSG $nick :Use /msg $botnick !leavenote <nick> <text> to send a note to any of the DJ's."
puthelp "PRIVMSG $nick :DJ's? Use /msg $botnick !getnotes to read your notes or /msg $botnick !erasenotes to delete them."
puthelp "PRIVMSG $nick :The script will let you know if you have notes when you join the channel. Please delete your notes after reading them. Otherwise you wont be able to get more (limit is 20)."
return 1
}
proc onjoin_notes { nick uhost hand chan } {
global botnick
set n [dosearchnote $nick]
if ($n>0) {
putserv "PRIVMSG $nick :You have $n notes waiting to be read. Use /msg $botnick !getnotes to read them."
return 1
}
return 0
}
proc erase_notes { nick uhost hand text } {
set lowercasenick [string tolower $nick]
set a [dosearchnote $nick]
if ($a>0) {
putserv "PRIVMSG $nick :All your notes have been deleted"
eval "exec rm ./publicnotes/public$lowercasenick.txt"
return 1
} else {
putserv "PRIVMSG $nick :You didnt have any notes :P"
return 0
}
}
proc dosearchnote {getnick} {
set lowercasenick [string tolower $getnick]
set notesf [file exists "./publicnotes/public$lowercasenick.txt"]
if ($notesf==0) {
return 0
}
set notesfile [open "./publicnotes/public$lowercasenick.txt" "r+"]
set numbernotes 0
while {[eof $notesfile] == 0} {
set line [gets $notesfile]
set nickline [lindex $line 0]
if {[string compare [string tolower $nickline] [string tolower $getnick]] == 0} {
set numbernotes [incr numbernotes]
}
}
close $notesfile
return $numbernotes
}
proc leave_notes { nick uhost hand text } {
global limitnotes
set getnick [lindex $text 0]
set msg [lrange $text 1 end]
set numbernotes [dosearchnote $getnick]
set cmp [expr $numbernotes >= $limitnotes]
if ($cmp>0) {
putserv "PRIVMSG $nick :The user already has $limitnotes notes. No more notes can be added to prevent spam."
} else {
set lowercasenick [string tolower $getnick]
set thereis [file exists "./publicnotes/public$lowercasenick.txt"]
set cmp [expr $thereis == 1]
if ($cmp) {
set notesfile [open "./publicnotes/public$lowercasenick.txt" "a"]
} else {
set notesfile [open "./publicnotes/public$lowercasenick.txt" "w+"]
}
puts $notesfile "$getnick $nick $msg"
putserv "PRIVMSG $nick :Note to $getnick has been stored."
close $notesfile
}
return 1
}
proc get_notes { nick uhost hand text } {
set lowercasenick [string tolower $nick]
set thereis [file exists "./publicnotes/public$lowercasenick.txt"]
if ($thereis==0) {
putserv "PRIVMSG $nick :You didnt have any notes."
return 1
}
set notesfile [open "./publicnotes/public$lowercasenick.txt" "r+"]
if {[eof $notesfile]} {
putserv "PRIVMSG $nick :You dont have any notes."
close $notesfile
} else {
set yes 0
set b [dosearchnote $nick]
set cmp [expr $b > 0]
if ($cmp<=0) {
putserv "PRIVMSG $nick :You dont have any notes."
close $notesfile
return 1
}
while {[eof $notesfile] == 0} {
set line [gets $notesfile]
set thisnick [lindex $line 0]
set cmpstr [string compare [string tolower $thisnick] [string tolower $nick]]
if ($cmpstr==0) {
set sendnick [lindex $line 1]
set msg [lrange $line 2 end]
putserv "PRIVMSG $nick :You have a note from $sendnick -> $msg"
set yes 1
}
}
if { $yes==0 } {
putserv "PRIVMSG $nick :You dont have any notes. Stop bugging me."
}
close $notesfile
}
return 1
}
|
so when i do the !erasenotes i get this error in the bot:
| Quote: | [17:28] Tcl error [erase_notes]: couldn't execute "rm": no such file or directory
|
Last edited by salyn on Thu Jun 29, 2006 11:06 pm; edited 1 time in total |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Wed Jun 28, 2006 8:45 pm Post subject: |
|
|
| Code: | | eval "exec rm ./publicnotes/public$lowercasenick.txt" |
It would appear the above folder, publicnotes, is not being created or the file is not being created within it (if it does indeed exist). _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
salyn Voice

Joined: 17 Jun 2006 Posts: 6
|
Posted: Wed Jun 28, 2006 10:00 pm Post subject: |
|
|
| Quote: | | It would appear the above folder, publicnotes, is not being created or the file is not being created within it (if it does indeed exist). |
yea the folder is there, and the file is created. i'm getting the notes
next idea? |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Thu Jun 29, 2006 4:15 am Post subject: |
|
|
Presumably this is on a windows box, which doesn't have an 'rm' command, it has 'del'
BTW, that script is exploitable, since it does not handle tcl-special chars, and especially since you're using 'exec'
I rewrote that script to be safe. If you want to look it over for ideas, it's at:
http://members.dandy.net/~fbn/publicnotes.rosc2112.tcl.txt |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Thu Jun 29, 2006 4:20 am Post subject: |
|
|
and if you use "file delete" from TCL it will run even on both .
Edit: has it been tried to be used with the full functional TCL like 8.4.9 was? Meaning no need for that stdin/ou thing. _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Last edited by De Kus on Thu Jun 29, 2006 5:20 am; edited 1 time in total |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
|
| Back to top |
|
 |
salyn Voice

Joined: 17 Jun 2006 Posts: 6
|
Posted: Thu Jun 29, 2006 9:27 am Post subject: |
|
|
Hmm, tried your script, and maybe i'm just not awake enough to think this through, but when i tested it, i got
| Quote: | | 06:18 <decadent`pleasure> You must have a *.users.undernet.org hostmask to use notes, sorry! |
i'm not using this on undernet |
|
| Back to top |
|
 |
salyn Voice

Joined: 17 Jun 2006 Posts: 6
|
Posted: Thu Jun 29, 2006 9:54 am Post subject: |
|
|
| Quote: | and if you use "file delete" from TCL it will run even on both Very Happy.
De Kus |
Ok, little more awake.......forget about using that other script, one small little change worked.
thanks so much |
|
| Back to top |
|
 |
|