#by wiebe @ QuakeNet (for eggdrop1.6.17 and above)

#kickbans users who send an away action to the channel where +noaway is set
#ban is set for 10 minutes
#check removes control codes and spaces
#users with flags bfvhomn are excluded
#ops / halfops on the channel are excluded
#bans *!*@account.users.quakenet.org / *!*@account.users.undernet.org host, else *!user@host

setudef flag noaway

bind ctcp - ACTION no-away

proc no-away { nick uhost handle chan key text } {
  if { ![validchan $chan] } { return 0 }
  if { ![channel get $chan noaway] } { return 0 }
  if { ![botisop $chan] && ![botishalfop $chan] } { return 0 }
  if { ![onchan $nick $chan] } { return 0 }
  if { [matchattr $handle bfvhomn|fvhomn $chan] } { return 0 }
  if { [isop $nick $chan] || [ishalfop $nick $chan] } { return 0 }
  set text [string tolower $text]
  set text [string map [list " " "" "search" "replace" "search" "replace"] $text]
  set text [string map [list "\017" "" "search" "replace" "search" "replace"] $text]
  set text [stripcodes bcru $text]
  if { [string match *away* $text] || [string match *gone* $text] || [string match *offline* $text] || [string match *online* $text] || [string match *leaving* $text] || [string match *useroff* $text] || [string match *bncon* $text] } {
    set mask *!$uhost
    if { [string match *@*.users.quakenet.org $uhost] || [string match *@*.users.undernet.org $uhost] } {
      set mask *!*@[lindex [split $uhost @] 1]
    }
    newchanban $chan $mask no-away "away actions are not wanted here. feel free to join when you are back." 5
  }
}
