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.

dumbasses tcl add/list/del

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
mrdr
Halfop
Posts: 42
Joined: Thu Jun 16, 2005 2:20 pm
Location: Lithuania / Vilnius / Underground
Contact:

dumbasses tcl add/list/del

Post by mrdr »

Hi,

I have dumbasses.tcl but it can only add ant list dumbasses.
Can anyone make that tcl could delete nick from the file. If nick isn't in the dumbasses file bot sents msg that he is not dumbass. :D

Code: Select all

set quoteitpubprefix "!"
set quoteitfile "quoteit.data"
# 0 = Channel
# 1 = Notice
set quoteitvianotice "1"

if { ![info exists toolbox_loaded] } { source scripts/alltools.tcl }

bind pub - [string trim $quoteitpubprefix]dumbasses quoteit:pub:dumbasses
bind pub G|G [string trim $quoteitpubprefix]dumbass quoteit:pub:dumbass

proc quoteit:pub:dumbass {nick uhost hand chan arg} {
 global quoteitfile quoteitvianotice
 set quotes ""
 if { [file exists $quoteitfile] } { set file [open $quoteitfile r] 
 } else {
  if { $quoteitvianotice == 0 } { putmsg $chan "$quoteitfile does not exist. You'll need to add quotes to the database first by typing \002!dumbass <nick>\002" }
  if { $quoteitvianotice == 1 } { putnotc $nick "$quoteitfile does not exist. You'll need to add quotes to the database first by typing \002!dumbass <nick>\002" }
  return 0
 }
 while { ![eof $file] } {
  set quote [gets $file]
  if { $quote != "" } {
   set quotes [linsert $quotes end $quote]
  }
 }
 close $file
 set row [rand [llength $quotes]]
   set quote [list $quotes]
 
 if { $quote != "" } {
  if { $quoteitvianotice == 0 } {
   putmsg $chan "Dumbasses: $quote"
  }
  if { $quoteitvianotice == 1 } {
   putnotc $nick "Dumbasses: $quote"
  }
  return 1
 }
}

proc quoteit:pub:dumbasses {nick uhost hand chan arg} {
 global quoteitfile
 if { $arg == "" } {
  putnotc $nick "Usage: !dumbass <nick>"
  return 0
 }
 set file [open $quoteitfile a]
 puts $file "$arg"
 close $file
 putmsg $chan "{$arg dumbassed}"
 return 1
}

putlog "*** dumbasses.tcl loaded"
IRC: #egghelp @ Aitvaras.NET
IRC: #NASA @ Aitvaras.NET
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

talk about rightly named scripts ;)
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
Post Reply