This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Is this actual idle time in #channel or away duration?

Help for those learning Tcl or writing their own scripts.
Post Reply
r
roughnecks
Voice
Posts: 33
Joined: Sun Sep 14, 2008 9:33 am
Location: Italy

Is this actual idle time in #channel or away duration?

Post by roughnecks »

I've got this script but am not sure how it works related to idle time checking.
Is it calculating the time you haven't send a single message to chan or the actual away duration?

Trying to explain what I mean:
I'm away at night. The next morning I chat on #chan1 where the bot isn't joined and the away automatically lifts (have a script on weechat that does it).
Then I go away away for another hour or so and, before I come back, someone calls me on #chan2, where the bot is joined.. At this point the script says I've been idle for 15hrs, i.e. from the night before, while I was chatting this morning and the away was unset and then reset. I'd expect the script to say I was idle only for an hour or so, when the second away was set this morning..

Here's the script:

Code: Select all

# Fully Automated Away Detection by speechles
# Egghelp version v1.3 - tested and working.. yay!!
# Donate to slennox @ egghelp.org if you like this script!

# Fully automatic, you configure nothing.
# The script will decide based upon the length of the nicklist
# or the length of user input on which to scan with, it will
# use whichever is shorter which makes it faster, enjoy.

# MAKE SURE TO .chanset #yourchan +checkaway
# afterwards the script will function in #yourchan

# revision history
# v1.3 - added idle time duration to the away message reply
# v1.2 - now wont react if that nickname is away and
#        mentions their own nickname in channel. This prevents
#        public away messages, etc from making this script
#        spam channels.
# v1.1 - now fully automated, no more checklist
# v1.0 - scripted using checklist user sets in config.

# SCRIPT begins: there is no config this is 100% automatic.
# -------------

# initialize the global variables
variable checknick ""
variable checkchan ""

# flag to control behavior per channel
setudef flag checkaway

# bind to raw reply concerning away status of whois
bind RAW  -|-  301 checkaway

# bind to everything said in channel
bind pubm -|- * checkcriteria

# check which token to whois phrased from user input.
# if we have a match, discern which token to evaluate as nick
# and if they are indeed on the channel issue a whois request
proc checkcriteria {nick uhost hand chan text} {
   if {[lsearch -exact [channel info $chan] +checkaway] == -1} { return }
   set ::checkchan $chan
   set ::checknick ""
   set text [encoding convertto utf-8 $text]

   if {[llength [chanlist $chan]] < [llength [split $text]]} {
      foreach n [chanlist $chan] {
         if {[lsearch [split [string tolower $text]] [string tolower $n]] != -1} {
            if {[string equal [string length $n] [string length [lindex [split $text] [lsearch [split [string tolower $text]] [string tolower $n]]]]]} {
               set ::checknick $n
               break
            }
         }
      }
   } else {
      foreach n [split $text] {
         if {[lsearch [split [string tolower [join [chanlist $chan]]]] [string tolower $n]] != -1} {
            set ::checknick $n
            break
         }
      }
   }
   if {[string length $::checknick] && ![string equal $n $nick] && [onchan $::checknick $chan]} {
      putserv "WHOIS $::checknick"
   }
}

# interpret the whois request and make sure the nick requested matches
# the whois reply we are searching for. If the person is not away, a 301
# will not be sent, and the whois will be ignored as per requested.
proc checkaway {from key text} {
   if {![string match -nocase [lindex [split $text] 1] $::checknick]} { return }
   putserv "privmsg $::checkchan :[lindex [split $text] 1] is away: [string range [join [lrange [split $text] 2 end]] 1 end] \(idle: [duration [expr {[getchanidle $::checknick $::checkchan] * 60}]])"
   set ::checknick ""
}

putlog "Automated away detection Loaded"
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

The eggdrop only sees your idle on the chan it's on (it uses getchanidle).

If you want a real back from away notifier, and if your ircd has ircv3 CAP, I've a small script to manage the away
r
roughnecks
Voice
Posts: 33
Joined: Sun Sep 14, 2008 9:33 am
Location: Italy

Post by roughnecks »

CrazyCat wrote:The eggdrop only sees your idle on the chan it's on (it uses getchanidle).
Ah, that's it then.
CrazyCat wrote: If you want a real back from away notifier, and if your ircd has ircv3 CAP, I've a small script to manage the away
No, but thanks anyway.
Post Reply