| View previous topic :: View next topic |
| Author |
Message |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Wed Sep 29, 2021 9:13 am Post subject: Storing date, nick host and reason of quit |
|
|
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: |
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 |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Wed Sep 29, 2021 9:42 am Post subject: |
|
|
| Code: | 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
. |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Wed Sep 29, 2021 9:51 am Post subject: |
|
|
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 _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Wed Sep 29, 2021 10:01 am Post subject: |
|
|
tried your suggestion seems to work well thanks Spike^^
| Quote: |
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 |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Wed Sep 29, 2021 10:09 am Post subject: |
|
|
after having close the file, before the } closing the if:
| Code: | 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 _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Wed Sep 29, 2021 11:23 am Post subject: |
|
|
| thanks SPike^^ and CrazyCat seems to work as desired |
|
| Back to top |
|
 |
|