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.

A very simple script that fills one file with certain lines.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
k
kmail
Voice
Posts: 8
Joined: Thu May 04, 2006 10:42 am

A very simple script that fills one file with certain lines.

Post by kmail »

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.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

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."
 }
}
k
kmail
Voice
Posts: 8
Joined: Thu May 04, 2006 10:42 am

Post by kmail »

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 :(
Post Reply