| View previous topic :: View next topic |
| Author |
Message |
Tannn3r Voice

Joined: 23 Dec 2010 Posts: 25
|
Posted: Mon Aug 20, 2012 7:52 pm Post subject: Command to add text to a file |
|
|
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 |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Mon Aug 20, 2012 11:55 pm Post subject: Re: Command to add text to a file |
|
|
| 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 |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Tue Aug 21, 2012 12:14 am Post subject: Try This. |
|
|
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 |
|
 |
Tannn3r Voice

Joined: 23 Dec 2010 Posts: 25
|
Posted: Tue Aug 21, 2012 4:52 pm Post subject: Re: Try This. |
|
|
| That's perfect. Thanks! |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Tue Aug 21, 2012 6:33 pm Post subject: Re: Try This. |
|
|
Let's also message the bot operator, if is online,
| 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 |
|
 |
|