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.

Fully Automated Away Detection [SOLVED]

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

holycrap wrote:Cool, can't thank you enough! :D

Anything that will make it works better are welcome.

I don't have that many nick in my channel, don't know if checking every word will slow the bot down or not.

:)
<speechles> i wonder if test123 is here or there or anywhere
<sp33chy> TEST123 is away: this is an away test for egghelp
<speechles> do any of you guys know if that test123 guy is away or anything?
<sp33chy> TEST123 is away: this is an away test for egghelp
<speechles> hey atest123
<speechles> is there anybody heretest123 that can answer a question?
<speechles> test123
<sp33chy> TEST123 is away: this is an away test for egghelp

Code: Select all

# Fully Automated Away Detection by speechles
# Egghelp version v1.0 - 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.

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

# flag to control behavior per channel
setudef flag checknames

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

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

# check which list is shorter, nicklist or text length
# and use that to scan for similarity and issue the whois
proc checkcriteria {nick uhost hand chan text} {
   if {![channel get $chan checknames]} { return }
   set ::checkchan $chan
   set ::checknick ""
   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] {
         # the join and split are used to emulate the behavior
         # of the -nocase switch which isn't allowed during lsearch
         # you can't string tolower a list, hence the join and split ;)
         if {[lsearch [split [string tolower [join [chanlist $chan]]]] [string tolower $n]] != -1} {
            set ::checknick $n
            break
         }
      }
   }
   if {[string length $::checknick] > 0 && [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]"
   set ::checknick ""
}

putlog "Fully Automated Away Detection loaded."
Here it is how you envisioned it. You configure nothing. The script will decide based on the length of the nicklist or length of text entered which to scan with. This will make it faster. It also is case insensitive as you can see in the example above. It also is smart enough not to react when the nickname is embedded as part of another word as shown in the examples above. This script should be more to your liking. Hope it doesn't lag your bot too badly ;)

Remember, to enable it, get on your bots partyline and .chanset #yourchan +checknames

Note: On actually using the script often, I've found it doesn't really lag the bot one bit even running in channels containing thousands of nicknames. It's instantaneous response and even faster than the other code I posted.
Last edited by speechles on Mon Sep 01, 2008 12:44 am, edited 3 times in total.
h
holycrap
Op
Posts: 152
Joined: Mon Jan 21, 2008 11:19 pm

Post by holycrap »

Hi,

It's not a major issue but I noticed this if you set:

/away :)

The colon does not show if it's at the "beginning" or the "end" of the away message. It does show in between though.

Anyway to fix this?

I've tried removing

Code: Select all

":"
from the line below, but it didn't fix it. It made it worst and show : every time.

Code: Select all

[join [lrange [split $text] 2 end]] ":"]"
Thank You!
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

holycrap wrote:Hi,

It's not a major issue but I noticed this if you set:

/away :)

The colon does not show if it's at the "beginning" or the "end" of the away message. It does show in between though.

Anyway to fix this?

I've tried removing

Code: Select all

":"
from the line below, but it didn't fix it. It made it worst and show : every time.

Code: Select all

[join [lrange [split $text] 2 end]] ":"]"
Thank You!
That actually was corrected awhile ago in the above code.. but here is the single line to change

Code: Select all

putserv "privmsg $::checkchan :[lindex [split $text] 1] is away: [string range [join [lrange [split $text] 2 end]] 1 end]" 
h
holycrap
Op
Posts: 152
Joined: Mon Jan 21, 2008 11:19 pm

Post by holycrap »

Hmm... It didn't really fixed it.

User: /away :)

Will show. User is away: )

It's still missing a colon in front. Shouldn't it be: User is away: :)

I guess what I'm asking is... I'm trying to get the colon to appear in front of the away message if I type /away :) as of now it will only show ) missing the the :

Thanks
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

holycrap wrote:Hmm... It didn't really fixed it.

User: /away :)

Will show. User is away: )

It's still missing a colon in front. Shouldn't it be: User is away: :)

I guess what I'm asking is... I'm trying to get the colon to appear in front of the away message if I type /away :) as of now it will only show ) missing the the :

Thanks
The way it works on irc, is that : delineates your message in the raw read reply the bot receives { nick:away message here }. It doesn't see :) as happy face (depends entirely on your irc client), the bot then sees this as an away message of ")" { nick:) } quite frankly, since all away messages have colons preceeding. But if you want this displayed change to:

Code: Select all

putserv "privmsg $::checkchan :[lindex [split $text] 1] is away [join [lrange [split $text] 2 end]]" 
Conversely, you don't have to change a thing, and just set yourself /away ::) and that would also work (depends once again, on the irc client used to set the away message).
h
holycrap
Op
Posts: 152
Joined: Mon Jan 21, 2008 11:19 pm

Post by holycrap »

Cool, it works now. I was using v1.1 in the archive. The code is a bit different from the one above. I'm using the one below. I hope it works the same(efficiency of the script).

Thank you once again! :D

Code: Select all

# Fully Automated Away Detection by speechles
# Egghelp version v1.1 - 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.1 - now fully automated, no more checklist
# v1.0 - scripted using checklist user sets in config.

# SCRIPT begins
# 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 checklist against 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 ""
   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] > 0 && [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]"
   set ::checknick ""
}

putlog "*.Automated Away Detection v1.1* Loaded"
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

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 ""
   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 -nocase $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 has been loaded."
<speechles> where you at tweek?
<sp33chy> tweek is away: is away: (Auto-Away after 10 mins) [BX-MsgLog Off] (idle: 31 minutes)
<speechles> how about you norman, you around?
<sp33chy> norman is away: offline, leave a msg!!! (idle: 6 days 11 hours 50 minutes)
Updated the script a bit to help eliminate some problems and added in a new feature. If the person away mentions their own nickname, say a public away message, the script before would've spammed they were away which is redundant. This won't happen now, the person who is away can no longer type their own nick and watch the bot reply their status. Also added idle time duration to show up along with the away message. This helps determine how long the person might have been away.. For those using this script, it has also been uploaded to the archive. Enjoy and have a fun :D

Edit: corrected script above for problem mentioned below :wink:
Last edited by speechles on Sat Nov 08, 2008 2:46 pm, edited 1 time in total.
h
holycrap
Op
Posts: 152
Joined: Mon Jan 21, 2008 11:19 pm

Post by holycrap »

If the person away mentions their own nickname, say a public away message, the script before would've spammed they were away which is redundant.
This version of the script is nick case sensitive. If your nick is "Java" and you type "java" it will still read the away message.

:D
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

my bad.. lmao..

Code: Select all

if {[string length $::checknick] && ![string equal $n $nick] && [onchan $::checknick $chan]} { 
Change that to look like below and solved, I forgot the -nocase.. :D

Code: Select all

if {[string length $::checknick] && ![string equal -nocase $n $nick] && [onchan $::checknick $chan]} { 
d
deadweasel
Voice
Posts: 1
Joined: Thu Jan 01, 2009 8:27 pm

Post by deadweasel »

I'm currently trying to get this little bad boy running with my own bot, but I can't set the channel mode specified.

Neither of these work:

.chanset #channame +checkaway
.chanset #channame +checknames

Both return "invalid mode". Of course, the bot is unresponsive when I am set to away.

What am I missing here?
l
lenooxx
Voice
Posts: 27
Joined: Tue Mar 24, 2009 10:56 am
Location: Hungarian
Contact:

hi

Post by lenooxx »

i got same problem :(
Error trying to set +checknames for #***, invalid mode.

what happend? :S
c
c0re
Voice
Posts: 16
Joined: Sun Jan 18, 2009 4:45 pm

Post by c0re »

omg the bot keep whoising people :(

isnt there any other way?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

This fixes a slight problem the automated away had detecting nicknames placed up against punctuation.

<nick> hey guy are you there?
if the nickname "guy" was in the channel, and set to away, the script works.

<nick> hey guy, are you there?
The script would fail, it will look for "guy,". The new version will not, it has a list of punctuation you can alter and these will be stripped before comparing to nicknames. New version will look for "guy" correctly in these instances.

Enjoy and have a fun. :P

Code: Select all

# Fully Automated Away Detection by speechles
# Egghelp version v1.4 - 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.4 - added a single config option to enter characters
#        that need to be stripped from text that are
#        placed up against nicknames.
# 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.


# set the characters you wish to strip when prefixed or
# appended to nicknames
# ----
variable auto_strip ":;,.?"

# 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 ""
   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 [string trim [lindex [split $text] [lsearch [split [string tolower $text]] [string tolower $n]]] $::auto_strip]]]} {
               set ::checknick $n
               break
            }
         }
      }
   } else {
      foreach n [split $text] {
         if {[lsearch [split [string tolower [join [chanlist $chan]]]] [string trim [string tolower $n] $::auto_strip]] != -1} {
            set ::checknick [string trim $n $::auto_strip]
            break
         }
      }
   }
   if {[string length $::checknick] && ![string equal -nocase $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 v1.4 has been loaded."
Post Reply