This is a module for MySQL Bot Core system.
You'll need http://www.hawkee.com/snippet/8882/ in case for this to work.
No extra MySQL structure needed.
[15:19] !peak
[15:19] -##SQL- Peak of 4 users made before 8mins by rootsecure
; MySQL Bot Core
; Module: Channel Peak
; Version: 1.00 STABLE
; Author: Nils Putnins (Neisen@Neisen.lv)
; - aliases
alias -l m.chanpeak.db return $qt($mircdirchanpeak.mbc.ini)
alias -l m.chanpeak {
if ($prop == sync) {
var %channels = $chan(0)
while %channels {
var %channel = $chan(%channels), %remotedata = $m.setting($+(peak_,%channel))
if ($zero($readini($m.chanpeak.db,%channel,peak)) > $zero($gettok(%remotedata,1,255))) m.setting $+(peak_,%channel) $+($v1,$chr(255),$readini($m.chanpeak.db,%channel,last),$chr(255),$readini($m.chanpeak.db,%channel,time))
else if (%remotedata) { writeini -n $m.chanpeak.db %channel peak $zero($gettok(%remotedata,1,255)) | writeini -n $m.chanpeak.db %channel last $gettok(%remotedata,2,255) | writeini -n $m.chanpeak.db %channel time $gettok(%remotedata,3,255) }
dec %channels
}
}
else if ($prop == output && $1) { return $iif($readini($m.chanpeak.db,$1,peak),Peak of $v1 users made before $duration($calc($ctime - $readini($m.chanpeak.db,$1,time)),2) by $readini($m.chanpeak.db,$1,last),Currently no peak stats for $1 $+ .) }
else if (!$2) return $zero($readini($m.chanpeak.db,$1,peak))
else if ($2 isnum && $2 > $zero($readini($m.chanpeak.db,$1,peak))) { writeini -n $m.chanpeak.db $1 peak $2 | writeini -n $m.chanpeak.db $1 last $3 | writeini -n $m.chanpeak.db $1 time $ctime }
}
; - actions
on *:JOIN:#:if ($nick($chan,0) > $m.chanpeak($chan)) m.chanpeak $chan $nick($chan,0) $nick
on *:TEXT:*:*:{
if ($1 == $command(peak)) {
var %target = $iif($2,$v1,$chan)
if (!%target) msg $nick $m.notify(error) Usage: !peak #channel or !peak if messaging in channel.
else $iif($chan,notice,msg) $nick $m.chanpeak(%target).output
}
}
; - communicating with core
on *:SIGNAL:m.modules:{
m.modules $+(Channel Peak,$chr(124),$command(peak),$chr(124),0)
noop $m.chanpeak().sync
}