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 - help please?

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
salyn
Voice


Joined: 17 Jun 2006
Posts: 6

PostPosted: Wed Jun 28, 2006 8:38 pm    Post subject: publicnotes1.0.1 - help please? Reply with quote

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

Code:


Last edited by salyn on Thu Jun 29, 2006 11:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Wed Jun 28, 2006 8:45 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
salyn
Voice


Joined: 17 Jun 2006
Posts: 6

PostPosted: Wed Jun 28, 2006 10:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
rosc2112
Revered One


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

PostPosted: Thu Jun 29, 2006 4:15 am    Post subject: Reply with quote

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
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Thu Jun 29, 2006 4:20 am    Post subject: Reply with quote

and if you use "file delete" from TCL it will run even on both Very Happy.

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
View user's profile Send private message MSN Messenger
rosc2112
Revered One


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

PostPosted: Thu Jun 29, 2006 4:25 am    Post subject: Reply with quote

According to another post, 'file delete' doesn't work either in windows. See:
http://forum.egghelp.org/viewtopic.php?p=62509
Back to top
View user's profile Send private message
salyn
Voice


Joined: 17 Jun 2006
Posts: 6

PostPosted: Thu Jun 29, 2006 9:27 am    Post subject: Reply with quote

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
View user's profile Send private message
salyn
Voice


Joined: 17 Jun 2006
Posts: 6

PostPosted: Thu Jun 29, 2006 9:54 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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