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 

Command to add text to a file

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Tannn3r
Voice


Joined: 23 Dec 2010
Posts: 25

PostPosted: Mon Aug 20, 2012 7:52 pm    Post subject: Command to add text to a file Reply with quote

I've seen something like this in many scripts, although I've been unable to extract it from them. Basically, I want a script that when a command is called (.report) in a channel, it will add all the text to a new line in a file and then tell the user that it's done. I use something else for this that allows users to report problems with the bot, but this method would be much better.

So, I want it to:
Create the file for the reports
When the command is initiated, it will create a new line in the file with: Nickname reported: report here
Then tell the user Thanks for reporting!

Thanks!
Back to top
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Mon Aug 20, 2012 11:55 pm    Post subject: Re: Command to add text to a file Reply with quote

Tannn3r wrote:

... although I've been unable to extract it from them.
...


Perhaps it will be easier to grasp here:
http://forum.egghelp.org/viewtopic.php?t=6885&sid=ac15bc225afd3c30f565335d349ca7b8

Particularly the part found under this heading:
Quote:

5. Add a line to the end of a file.

but there is a lot of useful information in the rest of that thread too.

I hope this helps.
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Tue Aug 21, 2012 12:14 am    Post subject: Try This. Reply with quote

Let's try this.
Code:
set report(file) "scripts/report.txt"

set report(thanks) "thanks for the report:)"

bind pub -|- .report report:tofile

proc report:tofile {nk uh hn ch tx} {
 global report
 set open [open $report(file) a]
 puts $open "$nk reported: $tx"
 close $open
 puthelp "PRIVMSG $ch :${nk}: $report(thanks)."
}

_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
Tannn3r
Voice


Joined: 23 Dec 2010
Posts: 25

PostPosted: Tue Aug 21, 2012 4:52 pm    Post subject: Re: Try This. Reply with quote

That's perfect. Thanks!
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Tue Aug 21, 2012 6:33 pm    Post subject: Re: Try This. Reply with quote

Let's also message the bot operator, if is online,Smile

Code:

set report(file) "scripts/report.txt"

set report(thanks) "thanks for the report:)"

set report(owner) ""  ;# set one nick to message, telling of the new report ("" = message off) #

bind pub -|- .report report:tofile

proc report:tofile {nk uh hn ch tx} {
 set open [open $report(file) a]
 puts $open "$nk reported: $tx"
 close $open
 puthelp "PRIVMSG $ch :${nk}: $report(thanks)."

 if {$report(owner) ne "" && [onchan $report(owner)]} {
   puthelp "PRIVMSG $report(owner) :$nk submitted a report."
 }
}

_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
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 -> Script Requests 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