/* AWAY_MESSAGE_RETRIEVED processor */

myuser = ARG(1)
otheruser = ARG(2)
datestamp = ARG(3)
message = ARG(4)

newstring = ""
lastmacropos = 1
macropos = POS( "%n", message )
do while macropos > 0
  l = macropos - lastmacropos
  newstring = newstring || substr( message, lastmacropos, l) || myuser
  lastmacropos = macropos + 2
  macropos = POS( "%n", message, macropos + 2 )
end
message = newstring || substr( message, lastmacropos )

newstring = ""
lastmacropos = 1
macropos = POS( "%d", message )
do while macropos > 0
  l = macropos - lastmacropos
  newstring = newstring || substr( message, lastmacropos, l) || date('L')
  lastmacropos = macropos + 2
  macropos = POS( "%d", message, macropos + 2 )
end
message = newstring || substr( message, lastmacropos )

newstring = ""
lastmacropos = 1
macropos = POS( "%t", message )
do while macropos > 0
  l = macropos - lastmacropos
  newstring = newstring || substr( message, lastmacropos, l) || time('C')
  lastmacropos = macropos + 2
  macropos = POS( "%t", message, macropos + 2 )
end
message = newstring || substr( message, lastmacropos )

SET_AWAY_MESSAGE myuser otheruser message

