egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

publicnotes1.0.1.tcl can't erase notes.

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
DarkStar723
Voice


Joined: 09 Sep 2005
Posts: 11

PostPosted: Sun Apr 30, 2006 10:33 pm    Post subject: publicnotes1.0.1.tcl can't erase notes. Reply with quote

I am trying to get this script working under windows, and can't figure out how to get a tcl script to delete a file, this is what i have so far for the erase_notes process.
Code:
 proc erase_notes { nick uhost hand chan text } {
  set lowercasenick [string tolower $nick]
  set a [dosearchnote $nick]
  if ($a>0) {
  putserv "NOTICE $nick :All your notes have been deleted"
  eval "exec cmd.exe >&@stdout <@stdin /c del .\publicnotes\public$lowercasenick.txt"
  return 1
  } else {
    putserv "NOTICE $nick :You didnt have any notes :P"
    return 0
  }
}

I know the problem is somewhere in this line (or i think it is):
Code:
eval "exec cmd.exe >&@stdout <@stdin /c del .\publicnotes\public$lowercasenick.txt"

Im just not sure what to change to get it working. Any changes just get me one of these two errors:

[22:21] Tcl error [erase_notes]: couldn't create error file for command: no such file or directory
[22:17] Tcl error [erase_notes]: child process exited abnormally

Original Script: http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&id=273
Back to top
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Sun Apr 30, 2006 10:36 pm    Post subject: Re: publicnotes1.0.1.tcl can't erase notes. Reply with quote

DarkStar723 wrote:

Original Script: http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&id=273

If you want help post the original script within code tags. People are not going to download a script to help when they could more easily read it on the forum.
Back to top
View user's profile Send private message
DarkStar723
Voice


Joined: 09 Sep 2005
Posts: 11

PostPosted: Mon May 01, 2006 1:46 am    Post subject: Reply with quote

umm, okay, i thought it would be easier to just post the problematic part in forum so as to not be all spammy, and leave the complete script as a link in case anyone wanted to look at it, but heres the whole thing:
Note: i have modified the erase_notes proc in an attempt to get it working under windows, see first post (it doesnt work in its form here, or there).
Code:
#################################
# Public notes by Sergio100 1.01 #
#################################

#You should make a directory named publicnotes where the eggdrop lives :)
#It's messy, i know... But i wrote it without help and without knowing TCL :)
#TO DO: Check users by host, not by nick.
#1.01: I was using string wordend for nicks, but it doesnt work with some characters.
#      So i now use lindex and lrange. It's quite faster too :D

bind join - * onjoin_notes
bind msg - .erasenotes erase_notes
bind msg - .leavenote leave_notes
bind msg - .getnotes get_notes
bind msg - .noteshelp help_notes

#This is the per user limit on notes received at one time (not sent! :).
set limitnotes 2

proc help_notes { nick uhost hand text } {
  global botnick
  puthelp "PRIVMSG $nick :Use /msg $botnick .leavenote <nick> <text> to send a note. 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 2)."
  return 1
}

proc onjoin_notes { nick uhost hand chan } {
  global botnick
  set n [dosearchnote $nick]
    if ($n>0) {
      putserv "NOTICE $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 "NOTICE $nick :All your notes have been deleted"
  eval "exec rm ./publicnotes/public$lowercasenick.txt"
  return 1
  } else {
    putserv "NOTICE $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 "NOTICE $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 "NOTICE $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 "NOTICE $nick :You didnt have any notes."
    return 1
  }
  set notesfile [open "./publicnotes/public$lowercasenick.txt" "r+"]
  if {[eof $notesfile]} {
    putserv "NOTICE $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 "NOTICE $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 "NOTICE $nick :You have a note from $sendnick -> $msg"
        set yes 1
      }
    }
    if { $yes==0 } {
      putserv "NOTICE $nick :You dont have any notes. Stop bugging me."
    }
    close $notesfile
  }
  return 1
}

##############################
# Show load statement        #
##############################
putlog "Public Notes 1.0 by Sergio100 (EFNet)"
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Fri May 05, 2006 1:57 am    Post subject: Reply with quote

I massively re-wrote this script myself, because it was so very unsecure.

But my changes rely on undernet, and users using a *!*@name.users.undernet.org mask, and made it work only with known-users (known to the bot) ...

I also changed it to handle special chars properly, because as it was, it does not handle them. I figured my changes were too specific to my own needs, so I haven't published the script publically. If there is interest, I can post my version publically.

In my version, I use:

file delete -force /full/path/to/publicnotes/note.$uhostname.txt

I assume that should work with tcl under windows? I do not recommend using exec!!! Razz

Peronally, if I had to use eggdrop under windows (not even if it was the last OS on earth ;p) I would install cygwin and use tcl/eggdrop under cygwin, which gives you a unix-like OS under windows, so you would not have these problems with pathname differences and such Smile
Back to top
View user's profile Send private message
DarkStar723
Voice


Joined: 09 Sep 2005
Posts: 11

PostPosted: Sun May 07, 2006 12:59 am    Post subject: Reply with quote

Thanks for the reply rosc2112, unfortunately that didnt work either, think im cursed with this script (would help if i knew what i was doing). I'm not sure about anyone else, but i personally would like to see your script.

(and tcl/eggdrop under cygwin, oh god, dont get me started on that, it caused so incredibly many bugs that i just gave up, and still has about the same problems *cries*.)
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sun May 07, 2006 4:54 am    Post subject: Reply with quote

I posted my copy here:

http://members.dandy.net/~fbn/publicnotes.rosc2112.tcl.txt
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sun May 07, 2006 10:12 am    Post subject: Reply with quote

Did a bit of updating on the script, since that was one of my first script re-writes..Amazing how much ya revise once you're more experienced Wink

(edit)
Made the notes saved path a configurable variable today..

Same url as above.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber