egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] help with check for activity

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
asim
Voice


Joined: 21 Sep 2009
Posts: 3

PostPosted: Mon Sep 21, 2009 2:44 pm    Post subject: [SOLVED] help with check for activity Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Sep 21, 2009 5:46 pm    Post subject: Reply with quote

What exactly do you mean by activity? messages in the channel?
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
asim
Voice


Joined: 21 Sep 2009
Posts: 3

PostPosted: Mon Sep 21, 2009 5:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Tue Sep 22, 2009 7:46 am    Post subject: Reply with quote

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
View user's profile Send private message
asim
Voice


Joined: 21 Sep 2009
Posts: 3

PostPosted: Tue Sep 22, 2009 1:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Tue Sep 22, 2009 5:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber