| View previous topic :: View next topic |
| Author |
Message |
kmail Voice
Joined: 04 May 2006 Posts: 8
|
Posted: Thu May 04, 2006 11:05 am Post subject: A very simple script that fills one file with certain lines. |
|
|
Okay, first of all, I don't know anything about TCL and because of that i am requesting a simple (it seems simple to a guy who knows TCL) script that must do the following:
When a user, named, for example "Uberpwner1", in certain channel writes "!banrequest Somenick http://someimagefileontheinternet.png A short comment" the bot adds a new line to some certain file. For example, a file banrequests.txt would get a line like this:
"Uberpwner1|Somenick|http://someimagefileontheinternet.png|A short comment|Currenttime"
And that would pretty much be it, that would be the MUST HAVE section
But also it would be very appreciated if the output file contained writers and Somenicks host and after they write that !banrequest line, there would be somekind of a feedback line msgd to them.
And one other appreciated feature would be that the script will announce "new request" or smth like that on a different channel. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Thu May 04, 2006 2:10 pm Post subject: |
|
|
| Code: | bind pub m !banrequest banrequest
proc banrequest {nick uhost hand chan arg} {
set file scripts/banrequests.txt
foreach {n w} [split $arg] {break}
set c [join [lrange [split $arg] 2 end]]
if {![file exists $file]} { close [open $file w] }
set l [split [read [set f [open $file]]][close $f] \n]
if {[lsearch $l *|$n|*] != -1} {
puthelp "notice $nick :$n is already added to my banrequests."
} {
lappend l "$nick|$n|$w|$c|[ctime [unixtime]]"
set f [open $file w]
foreach le $l {
if {$le != ""} { puts $f $le }
}
close $f
puthelp "notice $nick :Added $n to my banrequests."
}
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
kmail Voice
Joined: 04 May 2006 Posts: 8
|
Posted: Sun May 07, 2006 2:29 pm Post subject: |
|
|
Thank you Sir_Fz, the script seems to work just fine but would it be really hard to make it add these lines to a certain mySQL table?
The point is I just realized that it's very goddamn hard to edit a text file through PHP  |
|
| Back to top |
|
 |
|