mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 22:53:03 +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 "))) {
|
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;
|
||||||
}
|
}
|
||||||
msg++;
|
status++;
|
||||||
m_set_statusmessage((uint8_t*) msg, strlen(msg)+1);
|
USERSTATUS status_kind;
|
||||||
wprintw(ctx->history, "Status set to: %s\n", msg);
|
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 "))) {
|
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