#include "command.h"
#include "client.h"
#include "channel.h"
#include "str.h"

void cmd_away(struct client* c, struct token* p, int n) {
  if(n == 0) {
    c->is_away = 0;
    c->away_reason[0] = '\0';

    client_reply_start(c, "305");
    client_puts(c, ":You are back.\r\n");

    return;
  }

  str_copyn(c->away_reason, MAX_AWAY_REASON, p[0].s, p[0].len);
  c->is_away = 1;

  client_reply_start(c, "306");
  client_puts(c, ":Hasta la vista, baby!\r\n");

  return;
}
