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.

Storing date, nick host and reason of quit

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Storing date, nick host and reason of quit

Post by simo »

greetz gents,

i wanted to store on new line date , nick , host and the quit message on certain
words detected in the quit message in this case spam message

i managed to get the words to search for and all (wich i took from another tcl script that was premade for quit message spam) just the part to store the above info in a text file i struggle with

heres what i have so far:

Code: Select all

set quitwords {
  "G-lined"
}


bind sign - * quit:check


proc quit:check {nick uhost hand chan reason} {
  global quitwords 
    foreach quitmatch $::quitwords {
        if {([string match -nocase *$quitmatch* $reason])} {
 
        ***** store DATE, $nick, $uhost and $reason of quit in a text file *****

      }
  }
}
 

the idea is to check for the text file glined-spam.txt if it exists and if it does to write the above info to it and if it doesnt exist to create the file and write above info to it
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Code: Select all

set openfile [open quits.log a]
puts $openfile "[ctime [unixtime]] - $nick $uhost $reason"
close $openfile
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

just a small idea: add a return after having write: without it, if you have several words matching, you'll have a line per word in your logfile
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tried your suggestion seems to work well thanks Spike^^



just a small idea: add a return after having write: without it, if you have several words matching, you'll have a line per word in your logfile
not sure what you mean CrazyCat ?

u mean : puts $openfile "[ctime [unixtime]] - $nick $uhost $reason" ; return
User avatar
CrazyCat
Revered One
Posts: 1236
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

after having close the file, before the } closing the if:

Code: Select all

set quitwords {
  "G-lined"
}


bind sign - * quit:check


proc quit:check {nick uhost hand chan reason} {
    foreach quitmatch $::quitwords {
        if {([string match -nocase *$quitmatch* $reason])} {
           set openfile [open quits.log a]
           puts $openfile "[ctime [unixtime]] - $nick $uhost $reason"
           close $openfile
           return
      }
  }
}
Note that you used "global quitwords" but after you use $::quitwords, the global is useless
s
simo
Revered One
Posts: 1078
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

thanks SPike^^ and CrazyCat seems to work as desired
Post Reply