mirror of
https://github.com/Tha14/toxic.git
synced 2024-12-23 12:13:24 +01:00
Merge pull request #394 from Nominate/patch-2
Updated chat.c to bring /status inline with prompt.c status command
This commit is contained in:
commit
90b4f9b98c
44
chat.c
44
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 <message> : Set your status\n");
|
||||
wprintw(self->history, " /status <type> <message> : Set your status\n");
|
||||
wprintw(self->history, " /nick <nickname> : Set your nickname\n");
|
||||
wprintw(self->history, " /myid : Print your ID\n");
|
||||
wprintw(self->history, " /clear : Clear the screen\n");
|
||||
|
Loading…
Reference in New Issue
Block a user