correct any message or action in the channel. just some sign of interaction, although if it makes it easier to just do activity based on chat text that is fine.
# logs a timestamp for the last channel event in all the bots channels
# an event is normal channel chat, channel notice or onotice, channel action
# calling 'pActivityReturn #channelname' will return 0 (inactive) or 1 (active)
# according to the preconfigured time limit
# example
# if {[pActivityReturn #botchannel]} {
# code here
# }
# set here a time limit in seconds
# if the last channel event occurred within this time limit, the channel is deemed active
set vActivityTime 3600
bind CTCP - ACTION pActivityCtcp
bind NOTC - * pActivityNotc
bind PUBM - * pActivityPubm
proc pActivityCtcp {nick uhost hand dest keyword text} {
global vActivityCurrent
set channel [string tolower $dest]
set vActivityCurrent($channel) [unixtime]
return 0
}
proc pActivityNotc {nick uhost hand text dest} {
global vActivityCurrent
if {[regexp -- {^#} [string trimleft $dest @]]} {
set channel [string tolower [string trimleft $dest @]]
set vActivityCurrent($channel) [unixtime]
}
return 0
}
proc pActivityPubm {nick uhost hand chan text} {
global vActivityCurrent
set channel [string tolower $chan]
set vActivityCurrent($channel) [unixtime]
return 0
}
proc pActivityReturn {chan} {
global vActivityCurrent vActivityTime
set channel [string tolower $chan]
if {[info exists vActivityCurrent($channel)]} {
set now [unixtime]
set elapsed [expr {$now - $vActivityCurrent($channel)}]
if {$elapsed <= $vActivityTime} {
return 1
}
}
return 0
}
# eof