This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Command to add text to a file

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
Tannn3r
Voice
Posts: 25
Joined: Thu Dec 23, 2010 11:58 pm

Command to add text to a file

Post by Tannn3r »

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!
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Re: Command to add text to a file

Post by willyw »

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? ... 5d349ca7b8

Particularly the part found under this heading:
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.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Try This.

Post by SpiKe^^ »

Let's try this.

Code: Select all

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
.
User avatar
Tannn3r
Voice
Posts: 25
Joined: Thu Dec 23, 2010 11:58 pm

Re: Try This.

Post by Tannn3r »

That's perfect. Thanks!
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Re: Try This.

Post by SpiKe^^ »

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

Code: Select all

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
.
Post Reply