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 

Makenote viewnotes makenote.txt help[Solved]

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


Joined: 23 Feb 2009
Posts: 201

PostPosted: Tue Dec 22, 2009 3:49 pm    Post subject: Makenote viewnotes makenote.txt help[Solved] Reply with quote

Been looking at tcl faq adding files to try and get a bit of help with this

Im trying to get this to work not having no success what im trying to is get the bot to write to a file when someone does /botnick makenote username text will then notice #ops Note left about $username to view type /msg trainingbot viewnote $username

next it will need need to read makenote.txt when someone does /botnick viewnote username matching the username given then notice nick the text/note that is left against username have tried some of the quote scripts but was enable to mod them seperately

Code:
bind msg SA|SA makenote cmd:makenote
bind msg SA|SA viewnote cmd:viewnote
set fname "makenote.txt"

proc cmd:makenote {nick uhost hand text} {
  set username [lindex [split $arg] 0]
  set text [lrange [split $arg] 1 end]
  putserv "PRIVMSG $username :$text"
  puthelp "NOTICE #Test :Note left about $username to view type /msg trainingbot viewnote $username"
}
set fp [open $fname "r"]
  set data [read -nonewline $fp]
  close $fp
  set lines [split $data "\n"]
  set where_to_insert 0
  set lines [linsert $lines $makenote.txt $text]
  set fp [open $fp "w"]
  puts $fp [join $lines "\n"]
  close $fp
  }
}

_________________
Blake
UKEasyHosting UKStormWatch


Last edited by blake on Thu Dec 24, 2009 11:43 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
BLaCkShaDoW
Op


Joined: 11 Jan 2009
Posts: 115
Location: Romania

PostPosted: Wed Dec 23, 2009 3:48 am    Post subject: Reply with quote

Code:
bind msg SA|SA makenote cmd:makenote
bind msg SA|SA viewnote cmd:viewnote

set channel "#Test"

set fname "makenote.txt"

if {[file exists $fname] == 0} {
set file [open $fname w]
close $file
}

proc cmd:makenote {nick uhost hand text} {
global botnick channel fname
set username [lindex [split $text] 0]
set text [lrange [split $text] 1 end]
set file [open $fname a]
puts $file "$username $text"
close $file
putserv "PRIVMSG $username :$text"
  puthelp "NOTICE $channel :Note left about $username to view type /msg $botnick viewnote $username"
}


proc cmd:viewnote {nick uhost hand text} {
global fname
set username [lindex [split $text] 0]
if {$username == ""} { puthelp "NOTICE $nick :Try viewnote <username>"
return 0
}

set file [open $fname "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
if {$database == ""} { puthelp "PRIVMSG $nick :There are no notes available"
return 0
}
foreach line $data {
set user [lindex [split $line] 0]
if {[string match -nocase $user $username]} {
set note [lrange [split $line] 1 end]
set found 1
puthelp "PRIVMSG $nick :The note for $username is :"
puthelp "PRIVMSG $nick :$note"
}
if {![info exists found]} {
puthelp "PRIVMSG $nick :There are no notes for $username"
}
}
}

try it Smile
_________________
BLaCkShaDoW Production @ WwW.TclScripts.Net
Back to top
View user's profile Send private message Send e-mail Visit poster's website
blake
Master


Joined: 23 Feb 2009
Posts: 201

PostPosted: Thu Dec 24, 2009 8:18 am    Post subject: Reply with quote

Brill thanks BLaCkShaDoW works nice 1 more thing how can i add delnote username to this or get it to overwrite the existing note for username
_________________
Blake
UKEasyHosting UKStormWatch
Back to top
View user's profile Send private message Visit poster's website
BLaCkShaDoW
Op


Joined: 11 Jan 2009
Posts: 115
Location: Romania

PostPosted: Thu Dec 24, 2009 10:56 am    Post subject: Reply with quote

Code:
bind msg SA|SA makenote cmd:makenote
bind msg SA|SA viewnote cmd:viewnote

set channel "#Test"

set fname "makenote.txt"

if {[file exists $fname] == 0} {
set file [open $fname w]
close $file
}

proc cmd:makenote {nick uhost hand text} {
global botnick channel fname
set username [lindex [split $text] 0]
set lin 0
set text [lrange [split $text] 1 end]
set file [open $fname "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
foreach line $data {
set lin [expr $lin +1]
set userline [lindex [split $line] 0]
if {[string match -nocase $userline $username]} {
if {$line != ""} {
set num [expr $lin - 1]
set delete [lreplace $data $num $num]
set files [open $fname "w"]
puts $files [join $delete "\n"]
close $files
}
}
}
set file [open $fname "a"]
puts $file "$username $text"
close $file
putserv "PRIVMSG $username :$text"
  puthelp "NOTICE $channel :Note left about $username to view type /msg $botnick viewnote $username"
}


proc cmd:viewnote {nick uhost hand text} {
global fname
set username [lindex [split $text] 0]
if {$username == ""} { puthelp "NOTICE $nick :Try viewnote <username>"
return 0
}

set file [open $fname "r"]
set database [read -nonewline $file]
close $file
set data [split $database "\n"]
if {$database == ""} { puthelp "PRIVMSG $nick :There are no notes available"
return 0
}
foreach line $data {
set user [lindex $line 0]
if {[string match -nocase $user $username]} {
set note [lrange [split $line] 1 end]
set found 1
puthelp "PRIVMSG $nick :The note for $username is :"
puthelp "PRIVMSG $nick :$note"
}
if {![info exists found]} {
puthelp "PRIVMSG $nick :There are no notes for $username"
}
}
}

Now it overwrites the message if the username is already in the makenote.txt Smile
try it
_________________
BLaCkShaDoW Production @ WwW.TclScripts.Net
Back to top
View user's profile Send private message Send e-mail Visit poster's website
blake
Master


Joined: 23 Feb 2009
Posts: 201

PostPosted: Thu Dec 24, 2009 11:32 am    Post subject: Reply with quote

Very Happy @ BLaCkShaDoW
_________________
Blake
UKEasyHosting UKStormWatch
Back to top
View user's profile Send private message Visit poster's website
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