Multi-user Away System

By Nonborn on Jan 25, 2011

This away system is meant to be put into a bot and used by users in the same channel. Will read brb with or without a following message. "brb going out". Has !amsg to see another's away message, and users are registered as back from saying anything besides !amsg. The bottom block of coding (noted in snippet) should be the last segment of your bot.

;Thanks to Jethro_
on 1:quit:delete
on 1:part:#:delete
alias -l delete {
  if ($read(awaynames.txt,s,$nick) != $null) {
    write -ds $+ $nick awaynames.txt
  }
}
on *:text:*:#:{
  tokenize 32 $strip($1-)
  if ($regex($1,/^!?\b(brb|amsg)\b/i)) {
    if ($regml(1) = brb) {
      var %check = $read(awaynames.txt, s, $nick)
      if ($null != %check) notice $nick You're already recorded as being away.
      elseif ($2- = $null) {
        write awaynames.txt $nick - None.
        notice $nick You have been marked as away.
      }
      else {  
        write awaynames.txt $nick - $2-
        notice $nick You have been marked as away.
      }
    }
    else {
      var %check = $read(awaynames.txt,s,$$2)
      if ($$2 ison $chan) {
        if ($null != %check) notice $nick  $+ $$2 $+  $+ : %check
        else notice $nick  $+ $$2 isn't recorded as being away
      }
      else notice $nick That person is not in this room.
    }
  }
  else {
    var %check = $read(awaynames.txt,s,$nick)
    if ($null < %check) {   
      msg #  $+ $nick $+  is back from: %check
      write -ds $nick awaynames.txt
    }
  }
}

Comments

Sign in to comment.
Nonborn   -  Jan 25, 2011

Ok, thank you so much for revision and explanation. Guess I need to study up on consolidation.

 Respond  
Jethro   -  Jan 25, 2011

My example replaces your current code and it works the same as yours. The only difference I've made is adding a delete alias so you don't repeat the same routine twice and consolidating three text events into one. This way, you don't have to worry about the conflict caused by text events, especially the one without the match text section of event filled, to position it on top or bottom of another text event based script in the same remote. You may try my example and see for yourself.

 Respond  
Nonborn   -  Jan 25, 2011

Fixed the QUIT, and I have to admit that I'm not advanced enough yet to even comprehend your code. The method shown above is pretty much the only way I can work it out in my head. Thanks anyways, Jethro_. Will the "I'm back" check at the end of your script interfere with events added after the code, like in my version?

 Respond  
Jethro   -  Jan 25, 2011

Nonborn, there is no # in the quit event. You can combine all the text events into one:

on 1:quit:delete
on 1:part:#:delete
alias -l delete {
  if ($read(awaynames.txt,s,$nick) != $null) {
    write -ds $+ $nick awaynames.txt
  }
}
on *:text:*:#:{
  tokenize 32 $strip($1-)
  if ($regex($1,/^!?\b(brb|amsg)\b/i)) {
    if ($regml(1) = brb) {
      var %check = $read(awaynames.txt, s, $nick)
      if ($null != %check) notice $nick You're already recorded as being away.
      elseif ($2- = $null) {
        write awaynames.txt $nick - None.
        notice $nick You have been marked as away.
      }
      else {  
        write awaynames.txt $nick - $2-
        notice $nick You have been marked as away.
      }
    }
    else {
      var %check = $read(awaynames.txt,s,$$2)
      if ($$2 ison $chan) {
        if ($null != %check) notice $nick  $+ $$2 $+  $+ : %check
        else notice $nick  $+ $$2 isn't recorded as being away
      }
      else notice $nick That person is not in this room.
    }
  }
  else {
    var %check = $read(awaynames.txt,s,$nick)
    if ($null < %check) {   
      msg #  $+ $nick $+  is back from: %check
      write -ds $nick awaynames.txt
    }
  }
}
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.