egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Storing date, nick host and reason of quit

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Wed Sep 29, 2021 9:13 am    Post subject: Storing date, nick host and reason of quit Reply with quote

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
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Wed Sep 29, 2021 9:42 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Wed Sep 29, 2021 9:51 am    Post subject: Reply with 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
_________________
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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Wed Sep 29, 2021 10:01 am    Post subject: Reply with quote

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
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Wed Sep 29, 2021 10:09 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Wed Sep 29, 2021 11:23 am    Post subject: Reply with quote

thanks SPike^^ and CrazyCat seems to work as desired
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber