| View previous topic :: View next topic |
| Author |
Message |
asim Voice
Joined: 21 Sep 2009 Posts: 3
|
Posted: Mon Sep 21, 2009 2:44 pm Post subject: [SOLVED] help with check for activity |
|
|
Ok, i have a script and I would like to modify it to check for activity in the channel before giving credit.
Here is the code:
| Code: | proc out_bonus { min hour day month year} {
set sql [mysqlconnect -h HOST -u USERNAME -password PASSWD -db DBNAME ]
foreach user [chanlist #TheStash] {
if {$user != "velvet" && $user != "stash" && $user != "destiny"} {
set clock [ clock format [clock seconds] -format {%b. %d, %Y %I:%M:%S %p}]
set query [ mysqlquery $sql "UPDATE users SET seedbonus = seedbonus + 0.6 WHERE username=\'$user\'"]
}
}
set user [chanlist #thestash]
set clock [ exec sh -c { date +'%Y-%m-%d %R:%S'} ]
set query [ mysqlquery $sql "INSERT DELAYED INTO sitelog \(added, txt\) VALUES\(\'$clock\', \'Added 0.6 Point to $user for irc\'\)" ]
mysqlclose $sql
}
bind time - "?0 * * * *" out_bonus |
Velvet, Stash, Destiny are the name of bots in the channel. I am just not sure the best way to check for activity before awarding the bonus points.
Thanks in advance for the help.
Last edited by asim on Tue Sep 22, 2009 1:52 pm; edited 1 time in total |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Mon Sep 21, 2009 5:46 pm Post subject: |
|
|
What exactly do you mean by activity? messages in the channel? _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
asim Voice
Joined: 21 Sep 2009 Posts: 3
|
Posted: Mon Sep 21, 2009 5:51 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Tue Sep 22, 2009 7:46 am Post subject: |
|
|
Limited testing done, but seems OK
| Code: |
# 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
|
_________________ I must have had nothing to do |
|
| Back to top |
|
 |
asim Voice
Joined: 21 Sep 2009 Posts: 3
|
Posted: Tue Sep 22, 2009 1:52 pm Post subject: |
|
|
| Thanks, I am actually looking for activity by users, not the channel in general. but I should be able to adapt this. |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Tue Sep 22, 2009 5:02 pm Post subject: |
|
|
| asim wrote: | | Thanks, I am actually looking for activity by users, not the channel in general. but I should be able to adapt this. |
| Quote: | getchanidle <nickname> <channel>
Returns: number of minutes that person has been idle; 0 if the specified user isn't on the channel
Module: irc |
_________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
|