Add /window
parent
7c0e9cf3d2
commit
b2cf873304
1
chat.h
1
chat.h
|
@ -123,6 +123,7 @@ void uiShow(void);
|
||||||
void uiHide(void);
|
void uiHide(void);
|
||||||
void uiDraw(void);
|
void uiDraw(void);
|
||||||
void uiShowID(size_t id);
|
void uiShowID(size_t id);
|
||||||
|
void uiShowNum(size_t num);
|
||||||
void uiRead(void);
|
void uiRead(void);
|
||||||
void uiWrite(size_t id, enum Heat heat, const time_t *time, const char *str);
|
void uiWrite(size_t id, enum Heat heat, const time_t *time, const char *str);
|
||||||
void uiFormat(
|
void uiFormat(
|
||||||
|
|
20
command.c
20
command.c
|
@ -57,9 +57,16 @@ static void commandMe(size_t id, char *params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void commandQuit(size_t id, char *params) {
|
static void commandQuit(size_t id, char *params) {
|
||||||
|
(void)id;
|
||||||
set(&self.quit, (params ? params : "Goodbye"));
|
set(&self.quit, (params ? params : "Goodbye"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void commandWindow(size_t id, char *params) {
|
||||||
|
(void)id;
|
||||||
|
if (!params) return;
|
||||||
|
uiShowNum(strtoul(params, NULL, 10));
|
||||||
|
}
|
||||||
|
|
||||||
static const struct Handler {
|
static const struct Handler {
|
||||||
const char *cmd;
|
const char *cmd;
|
||||||
Command *fn;
|
Command *fn;
|
||||||
|
@ -68,6 +75,7 @@ static const struct Handler {
|
||||||
{ "/notice", commandNotice },
|
{ "/notice", commandNotice },
|
||||||
{ "/quit", commandQuit },
|
{ "/quit", commandQuit },
|
||||||
{ "/quote", commandQuote },
|
{ "/quote", commandQuote },
|
||||||
|
{ "/window", commandWindow },
|
||||||
};
|
};
|
||||||
|
|
||||||
static int compar(const void *cmd, const void *_handler) {
|
static int compar(const void *cmd, const void *_handler) {
|
||||||
|
@ -97,14 +105,13 @@ const char *commandIsAction(size_t id, const char *input) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void command(size_t id, char *input) {
|
void command(size_t id, char *input) {
|
||||||
if (id == Debug) {
|
if (id == Debug && input[0] != '/') {
|
||||||
commandQuote(id, input);
|
commandQuote(id, input);
|
||||||
return;
|
} else if (commandIsPrivmsg(id, input)) {
|
||||||
}
|
|
||||||
if (commandIsPrivmsg(id, input)) {
|
|
||||||
commandPrivmsg(id, input);
|
commandPrivmsg(id, input);
|
||||||
return;
|
} else if (input[0] == '/' && isdigit(input[1])) {
|
||||||
}
|
commandWindow(id, &input[1]);
|
||||||
|
} else {
|
||||||
char *cmd = strsep(&input, " ");
|
char *cmd = strsep(&input, " ");
|
||||||
const struct Handler *handler = bsearch(
|
const struct Handler *handler = bsearch(
|
||||||
cmd, Commands, ARRAY_LEN(Commands), sizeof(*handler), compar
|
cmd, Commands, ARRAY_LEN(Commands), sizeof(*handler), compar
|
||||||
|
@ -114,4 +121,5 @@ void command(size_t id, char *input) {
|
||||||
} else {
|
} else {
|
||||||
uiFormat(id, Hot, NULL, "No such command %s", cmd);
|
uiFormat(id, Hot, NULL, "No such command %s", cmd);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue