I have redone this script a bit since I first uplaoded it, the timer was having issues, and forgot to include the highlight coding. This script was done with the help of GrimReaper using his away script,and parts of others. I encourage feed back, let me know what you think. Thank you.
If you modify this script be very careful! Its rather fragile as I have come to find out.lol
NOTE: Monitor timers, not sure if the timers will clear correclty, they should. But I have yet to test the new timer arrangement. The %away unsets fine thou, so thats good news. I was getting stuck variables with the $+ $nick, due to the way it was set up the variables were being set as %awaynickhere, and not %away NICKHERE. Small but big difference. I also found out that my highlight WAS based on the variable, and that trying to do it based on the .ini file is the thing I was having issues with. But long as the variable and timer clear, im sure the read.ini file is of lil concern. If you DO know how to have a way of checking that in chat, let me know. IE: !checknick NICK, and have it return result based on read.ini status instead of %away.
Thanks again for the input.
on $*:TEXT:/^(brb|gone|afk)/Si:#:{
if (!$readini(idle.ini, $nick, time)) {
set %away $nick
writeini idle.ini $nick time $ctime
msg $chan Alright, ill start my stop watch..
}
elseif ($readini(idle.ini, $nick, time) >= 1) {
msg $chan $nick $+ ,you are already marked as brb, Please say "back" when you return!
}
}
on *:text:back:#:{
if ($readini(idle.ini, $nick, time) >= 1) {
unset %away
msg $chan Welcome back $nick you were gone for $duration($calc($ctime -$readini(idle.ini, $nick, time) )) $+ , what took you so long?
remini idle.ini $nick
}
}
on *:TEXT:!ClearAway *:#:{
if (!$2) { msg $chan Please specify a nick!
}
else {
unset %away
remini idle.ini $2
msg $chan $2 $+ 's brb time has been cleared.
}
}
On *:TEXT:*:#: {
if (%away isin $1-) {
msg $chan Sorry $nick but there marked as brb at this time, they will say back when they return.
}
}
Xpl0reR, why so many text and action events? You can combine them using an alias so you don't repeat them unnecessarily. Also the %away isin $1- won't serve any purpose when someone calls your name when you are away. It simply won't work whatsoever. This is the improved, modified version of the code:
on $*:text:/^(brb|gone|afk)\b/Si:#:awaycheck $1-
on $*:action:/^(brb|gone|afk)\b/Si:#:awaycheck $1-
alias -l awaycheck {
if (!$readini(idle.ini, $nick, time)) {
set %away. $+ $nick $1-
hadd -m awaynick $+(*,$nick,*) $true
writeini idle.ini $nick time $ctime
msg # (BRB): $nick is now Away: $1-
}
}
on *:text:*:#:awaycheck2 $1-
on *:action:*:#:awaycheck2 $1-
alias -l awaycheck2 {
if ($hfind(awaynick,$1-,1,W)) {
msg # Sorry $nick $+ , but the user $remove($v1,*) is not available to respond to you at this time!
}
elseif ($readini(idle.ini, $nick, time) >= 1) {
msg # (BRB): $nick is now Back, you were gone for $&
$duration($calc($ctime -$readini(idle.ini, $nick, time) )) :: $($+(%,away.,$nick),2)
unset %away. $+ $nick | hdel awaynick $+(*,$nick,*) | remini idle.ini $nick
}
}
brb in a moment Xpl0reR is now Away: brb in a moment is Xpl0reR here? Sorry Jethro, but the user Xpl0reR is not available to respond to you at this time!The whole modified script is much smaller in bytes compared to yours.
i just did this for simple fun, and this is what i did with your snippet for my bot:
i removed the clearaway, and i added the ACTION event, because sometimes people will /me brb and then just type HELLO when they are back, so.. as soon someone talks, and it was afk the script sees them as "back". and i saved their "brb" reason
[11:59:35] * @xplo brb in a moment
[11:59:35] <@Ubot[02]> (BRB): xplo is now Away: brb in a moment
[11:59:39] <@xplo> Hello!
[11:59:40] <@Ubot[02]> (BRB): xplo is now Back, you were gone for 4secs :: brb in a moment
on $*:TEXT:/^(brb|gone|afk)/Si:#:{
if (!$readini(idle.ini, $nick, time)) {
set %away. $+ $nick $1-
writeini idle.ini $nick time $ctime
msg $chan (BRB): $nick is now Away: $1-
}
}
on *:text:*:#:{
if ($readini(idle.ini, $nick, time) >= 1) {
msg $chan (BRB): $nick is now Back, you were gone for $duration($calc($ctime -$readini(idle.ini, $nick, time) )) :: $($+(%,away.,$nick),2)
unset %away. $+ $nick
remini idle.ini $nick
}
}
On *:TEXT:*:#: {
if (%away isin $1-) { msg $chan Sorry $nick but there marked as brb at this time, they will say back when they return. }
}
on $*:action:/^(brb|gone|afk)/Si:#:{
if (!$readini(idle.ini, $nick, time)) {
set %away. $+ $nick $1-
writeini idle.ini $nick time $ctime
msg $chan (BRB): $nick is now Away: $1-
}
}
on *:action:*:#:{
if ($readini(idle.ini, $nick, time) >= 1) {
msg $chan (BRB): $nick is now Back, you were gone for $duration($calc($ctime -$readini(idle.ini, $nick, time) )) :: $($+(%,away.,$nick),2)
unset %away. $+ $nick
remini idle.ini $nick
}
}
On *:action:*:#: {
if (%away isin $1-) { msg $chan Sorry $nick but there marked as brb at this time, they will say back when they return. }
}
Your base code is nice, it gave me an idea, and i liked it.
+like
8/10
Zerg I tried that, but then the highlight wouldnt work, and that was one the features I wanted for my channel. Its very easy to modify to work with multiple users, but doing so makes it rather hard to get it to allow you to do highlights by %away due to $+ $nick sets it so the away is set as %awayuser, instead of %away user, I guess one could do $nick without the $+ I might try that soon. Love your snippet btw!
I had the same idea When i Scripted Terran on SwiftIRC. IF you would like to see a related code that works for more than one person,
http://www.hawkee.com/snippet/6811/
ohhh I see.
One more thing I'd like to add is that you can incorporate your back and !clearaway command into the regex match and then use the
if ($regeml(1) == back) {
and
if ($regml(1) == !clearaway)
to trigger the second and last on text event:
on $*:TEXT:/^(b(rb|ack)|gone|afk|[!]clearaway)/Si:#: {
This way you only use one text event instead of three, excluding the one for %away.
Jethro_ exactly it will work if some one types brb gone to the bathroom..etc As designed.
However you didnt mention that with $+ $Nick that if (%away isin $1-) wont work for highlighting, so I have removed the $+ +nick and returned to the older version which seems far more stable.
Your point is duely noted and thank you, but that was on purpose. :)