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.

read from stats.mod database

Old posts that have not been replied to for several years.
Locked
s
stammer
Voice
Posts: 31
Joined: Mon Mar 10, 2003 9:39 am
Location: Bulgaria

read from stats.mod database

Post by stammer »

Hi there,
i want to write a tcl for reading a channel peak from stats.mod database and when there is a peak my bot to tell it in the channel. Can enybody tell me how to access peak in stats 'dat' file?
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

What kind of peak and what does it look like in the dat file?
s
stammer
Voice
Posts: 31
Joined: Mon Mar 10, 2003 9:39 am
Location: Bulgaria

Post by stammer »

it looks like this for example:

Code: Select all

#Arakis ! 1047997200
#Arakis @ 23
@ peaks #Arakis 23 16 23 23
it's user peak for that channel. I'm not sure what is the meaning of this number after '!' sign. And second how to catch when stats.mod detects peak to display it on the channel.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Detecting the peak change from the file will be much harder and much more cpu intensive than just using a separate script for keeping track of and announcing the peak.
s
stammer
Voice
Posts: 31
Joined: Mon Mar 10, 2003 9:39 am
Location: Bulgaria

Post by stammer »

Ok i will get peak the way peak.tcl gets it but old peak have to be read from stats dat ot eliminate external file that peak.tcl writes. Statsmod takes care for writing peak values in his file.

Problem is how to access this peak values in statsmod.dat file?
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

stammer wrote:Statsmod takes care for writing peak values in his file.
So there's a separate file just for the peak? (i've never used the module)
s
stammer
Voice
Posts: 31
Joined: Mon Mar 10, 2003 9:39 am
Location: Bulgaria

Post by stammer »

My english is not so good because i'm from Bulgaria.

I was using a tcl for channel peak and it writes a separate file for peak values. Then i start to use statsmod. Stats writes peak values in his dat file too. So i remove peak.tcl and start to think how to read peak values from statsmod.dat thats it :)

and write my own peak procedure :)
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

What I'm trying to figure out is how you'll find the peak value. Will it be at a fixed position or will you have to look for it in a huge file containing lots of other crap?

I was going to suggest using a udef for storing the peak, but if the number is easily extracted from an existing file there's no point in that :)
s
stammer
Voice
Posts: 31
Joined: Mon Mar 10, 2003 9:39 am
Location: Bulgaria

Post by stammer »

Peak values are stored in dat file like this:

#Channel @ number

is there a command in tcl to search for pattren in text files like in C language

i think of binding 'join' and getting a channel name and search in dat file for '#chan @'
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

A search through a file each time someone joins? Your bot will scream in pain during net merges :P Why not read the file at startup and keep the value in a element of a global array? Then upon each join check if [llength [chanlist #chan]]>that_value and announce + change the var if it is.
s
stammer
Voice
Posts: 31
Joined: Mon Mar 10, 2003 9:39 am
Location: Bulgaria

Post by stammer »

My bot is in small IRC network an channel where it stays is 15-30 nicks in daytime and 10 in the night but this with array is good point :)

i thing i found how to search

Code: Select all

bind join - *      pub:speak

proc pub:speak {nick host hand chan} {
	set fid [open "statsmod.dat" r]
	while {![eof $fid]} {
		set ln [gets $fid]
		if {[eof $fid]} { break }
		if {[string match -nocase "*$chan \@*" $ln]} { putlog [lindex $ln 2] }
	}
	close $fid
}	 
Locked