This is a module for MySQL Bot Core system.
You'll need http://www.hawkee.com/snippet/8882/ in case for this to work.
[12:02] !seen wubwubwub
[12:02] -#DEV-SQL- Last seen wubwubwub before 34secs changing nickname to Hawkee
MySQL Database Structure:
CREATE TABLE `seen` (
`nickname` varchar(50) NOT NULL,
`address` varchar(200) NOT NULL,
`time` datetime NOT NULL,
`network` varchar(50) NOT NULL,
`action` enum('j','p','q','n','a','t') NOT NULL,
`extra` varchar(100) NOT NULL,
PRIMARY KEY (`nickname`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CHANGELOG:
1.00 STABLE -> 1.01 STABLE
; MySQL Bot Core
; Module: Seen System
; Version: 1.15 STABLE
; Author: Nils Putnins (Neisen@Neisen.lv)
; - aliases
alias -l m.seen.db return $qt($mircdirseen.mbc.ini)
alias -l m.seenres return $iif($readini($m.seen.db,$1,$2),$v1,$m.dbres($2,seen,nickname,$1))
alias -l m.seen {
if (!$isid && $3) {
writeini -n $m.seen.db $1 address $2
writeini -n $m.seen.db $1 time $ctime
writeini -n $m.seen.db $1 network $network
writeini -n $m.seen.db $1 action $left($3, 1)
$iif($4,writeini -n $m.seen.db $1 extra $v1)
}
else if ($prop == sync) {
var %records = $ini($m.seen.db,0), %sql = REPLACE INTO `seen` (`nickname`,`address`,`time`,`network`,`action`,`extra`) VALUES (?, ?, ?, ?, ?, ?)
while %records {
var %target = $ini($m.seen.db,%records)
noop $mysql_query(%m.sql, %sql, %target, $m.seenres(%target,address), $asctime($m.seenres(%target,time),yyyy-mm-dd HH:nn:ss), $m.seenres(%target,network), $m.seenres(%target,action), $m.seenres(%target,extra))
dec %records
}
.remove $m.seen.db
}
else if ($1) {
if ($1 == $me) return Uhm...?
else if ($1 == $nick) return Ehm...?
else if ($1 ison $2) return Erhm..?
var %result = $iif($m.seenres($1,time) !isnum,$ctime($v1),$v1)
$iif(!%result,return No seen results for this nickname.)
return Last seen $bold($1) before $duration($calc($ctime - %result),2) $m.seen.action($m.seenres($1,action)) $m.seenres($1,extra)
}
}
alias -l m.seen.action {
if ($1 = t) return saying something on
else if ($1 = a) return making action in
else if ($1 = q) return quitting
else if ($1 = j) return joining
else if ($1 = p) return parting
else if ($1 = n) return changing nickname to
}
; - actions
on *:JOIN:#:m.seen $nick $fulladdress join $chan
on *:PART:#:m.seen $nick $fulladdress part $chan
on *:QUIT:m.seen $nick $fulladdress quit
on *:NICK:m.seen $nick $fulladdress nick $newnick
on *:ACTION:*:#:m.seen $nick $fulladdress action $chan
on *:TEXT:*:*:{
if ($chan) m.seen $nick $fulladdress text $chan
if ($1 == $command(seen)) $iif($chan,notice,msg) $nick $m.seen($2,$chan)
}
; - communicating with core
on *:SIGNAL:m.modules:{
m.modules $+(Seen System,$chr(124),$command(seen),$chr(124),0,$chr(124),$remove($script,$mircdir))
noop $m.seen().sync
}
Note that this doesn't work without the Core - http://www.hawkee.com/snippet/8882/