diff options
-rw-r--r-- | testing/toxic/chat.c | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c index 28c5de6c..669fd14d 100644 --- a/testing/toxic/chat.c +++ b/testing/toxic/chat.c | |||
@@ -154,15 +154,47 @@ void execute(ToxWindow *self, ChatContext *ctx, char *cmd) | |||
154 | } | 154 | } |
155 | 155 | ||
156 | else if (!strncmp(cmd, "/status ", strlen("/status "))) { | 156 | else if (!strncmp(cmd, "/status ", strlen("/status "))) { |
157 | char *status = strchr(cmd, ' '); | ||
157 | char *msg; | 158 | char *msg; |
158 | msg = strchr(cmd, ' '); | 159 | char *status_text; |
159 | if (msg == NULL) { | 160 | if (status == NULL) { |
160 | wprintw(ctx->history, "Invalid syntax.\n"); | 161 | wprintw(ctx->history, "Invalid syntax.\n"); |
161 | return; | 162 | return; |
162 | } | 163 | } |
163 | msg++; | 164 | status++; |
164 | m_set_statusmessage((uint8_t*) msg, strlen(msg)+1); | 165 | USERSTATUS status_kind; |
165 | wprintw(ctx->history, "Status set to: %s\n", msg); | 166 | if (!strncmp(status, "online", strlen("online"))) { |
167 | status_kind = USERSTATUS_NONE; | ||
168 | status_text = "ONLINE"; | ||
169 | } | ||
170 | |||
171 | else if (!strncmp(status, "away", strlen("away"))) { | ||
172 | status_kind = USERSTATUS_AWAY; | ||
173 | status_text = "AWAY"; | ||
174 | } | ||
175 | |||
176 | else if (!strncmp(status, "busy", strlen("busy"))) { | ||
177 | status_kind = USERSTATUS_BUSY; | ||
178 | status_text = "BUSY"; | ||
179 | } | ||
180 | |||
181 | else | ||
182 | { | ||
183 | wprintw(ctx->history, "Invalid status.\n"); | ||
184 | return; | ||
185 | } | ||
186 | |||
187 | msg = strchr(status, ' '); | ||
188 | if (msg == NULL) { | ||
189 | m_set_userstatus(status_kind); | ||
190 | wprintw(ctx->history, "Status set to: %s\n", status_text); | ||
191 | } | ||
192 | else { | ||
193 | msg++; | ||
194 | m_set_userstatus(status_kind); | ||
195 | m_set_statusmessage((uint8_t*) msg, strlen(msg)+1); | ||
196 | wprintw(ctx->history, "Status set to: %s, %s\n", status_text, msg); | ||
197 | } | ||
166 | } | 198 | } |
167 | 199 | ||
168 | else if (!strncmp(cmd, "/nick ", strlen("/nick "))) { | 200 | else if (!strncmp(cmd, "/nick ", strlen("/nick "))) { |
@@ -231,7 +263,7 @@ void print_help(ChatContext *self) | |||
231 | wprintw(self->history, "Commands:\n"); | 263 | wprintw(self->history, "Commands:\n"); |
232 | wattroff(self->history, A_BOLD); | 264 | wattroff(self->history, A_BOLD); |
233 | 265 | ||
234 | wprintw(self->history, " /status <message> : Set your status\n"); | 266 | wprintw(self->history, " /status <type> <message> : Set your status\n"); |
235 | wprintw(self->history, " /nick <nickname> : Set your nickname\n"); | 267 | wprintw(self->history, " /nick <nickname> : Set your nickname\n"); |
236 | wprintw(self->history, " /myid : Print your ID\n"); | 268 | wprintw(self->history, " /myid : Print your ID\n"); |
237 | wprintw(self->history, " /clear : Clear the screen\n"); | 269 | wprintw(self->history, " /clear : Clear the screen\n"); |