mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 03:13:01 +01:00
Updated chat.c to bring /status inline with prompt.c status command
This commit is contained in:
parent
90acd2dfef
commit
d6468d7d0c
40
chat.c
40
chat.c
@ -154,15 +154,47 @@ void execute(ToxWindow *self, ChatContext *ctx, char *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(cmd, "/status ", strlen("/status "))) {
|
else if (!strncmp(cmd, "/status ", strlen("/status "))) {
|
||||||
|
char *status = strchr(cmd, ' ');
|
||||||
char *msg;
|
char *msg;
|
||||||
msg = strchr(cmd, ' ');
|
char *status_text;
|
||||||
if (msg == NULL) {
|
if (status == NULL) {
|
||||||
wprintw(ctx->history, "Invalid syntax.\n");
|
wprintw(ctx->history, "Invalid syntax.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
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++;
|
msg++;
|
||||||
|
m_set_userstatus(status_kind);
|
||||||
m_set_statusmessage((uint8_t*) msg, strlen(msg)+1);
|
m_set_statusmessage((uint8_t*) msg, strlen(msg)+1);
|
||||||
wprintw(ctx->history, "Status set to: %s\n", msg);
|
wprintw(ctx->history, "Status set to: %s, %s\n", status_text, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(cmd, "/nick ", strlen("/nick "))) {
|
else if (!strncmp(cmd, "/nick ", strlen("/nick "))) {
|
||||||
@ -231,7 +263,7 @@ void print_help(ChatContext *self)
|
|||||||
wprintw(self->history, "Commands:\n");
|
wprintw(self->history, "Commands:\n");
|
||||||
wattroff(self->history, A_BOLD);
|
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, " /nick <nickname> : Set your nickname\n");
|
||||||
wprintw(self->history, " /myid : Print your ID\n");
|
wprintw(self->history, " /myid : Print your ID\n");
|
||||||
wprintw(self->history, " /clear : Clear the screen\n");
|
wprintw(self->history, " /clear : Clear the screen\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user