diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c index 56dfb050..83765777 100644 --- a/testing/toxic/chat.c +++ b/testing/toxic/chat.c @@ -154,15 +154,47 @@ void execute(ToxWindow *self, ChatContext *ctx, char *cmd) } else if (!strncmp(cmd, "/status ", strlen("/status "))) { + char *status = strchr(cmd, ' '); char *msg; - msg = strchr(cmd, ' '); - if (msg == NULL) { + char *status_text; + if (status == NULL) { wprintw(ctx->history, "Invalid syntax.\n"); return; } - msg++; - m_set_statusmessage((uint8_t*) msg, strlen(msg)+1); - wprintw(ctx->history, "Status set to: %s\n", msg); + status++; + USERSTATUS status_kind; + if (!strncmp(status, "online", strlen("online"))) { + status_kind = USERSTATUS_NONE; + status_text = "ONLINE"; + } + + else if (!strncmp(status, "away", strlen("away"))) { + status_kind = USERSTATUS_AWAY; + status_text = "AWAY"; + } + + else if (!strncmp(status, "busy", strlen("busy"))) { + status_kind = USERSTATUS_BUSY; + status_text = "BUSY"; + } + + else + { + wprintw(ctx->history, "Invalid status.\n"); + return; + } + + msg = strchr(status, ' '); + if (msg == NULL) { + m_set_userstatus(status_kind); + wprintw(ctx->history, "Status set to: %s\n", status_text); + } + else { + msg++; + m_set_userstatus(status_kind); + m_set_statusmessage((uint8_t*) msg, strlen(msg)+1); + wprintw(ctx->history, "Status set to: %s, %s\n", status_text, msg); + } } else if (!strncmp(cmd, "/nick ", strlen("/nick "))) { @@ -231,7 +263,7 @@ void print_help(ChatContext *self) wprintw(self->history, "Commands:\n"); wattroff(self->history, A_BOLD); - wprintw(self->history, " /status : Set your status\n"); + wprintw(self->history, " /status : Set your status\n"); wprintw(self->history, " /nick : Set your nickname\n"); wprintw(self->history, " /myid : Print your ID\n"); wprintw(self->history, " /clear : Clear the screen\n");