diff options
author | June McEnroe <june@causal.agency> | 2021-03-17 13:34:33 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2021-03-17 13:34:33 -0400 |
commit | 8ea881a097360a8ed7dd07ee15dbe264ad5a0912 (patch) | |
tree | eff988adf922992cd8b1560b81b75e349b016032 /command.c | |
parent | Allow multi-line /me and split long /me messages (diff) | |
download | catgirl-8ea881a097360a8ed7dd07ee15dbe264ad5a0912.tar.gz catgirl-8ea881a097360a8ed7dd07ee15dbe264ad5a0912.zip |
Show where too-long-messages will be automatically split
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/command.c b/command.c index 5af3e25..0aefb2b 100644 --- a/command.c +++ b/command.c @@ -582,6 +582,33 @@ const char *commandIsAction(uint id, const char *input) { return &input[4]; } +size_t commandWillSplit(uint id, const char *input) { + int chunk; + const char *params; + if (NULL != (params = commandIsPrivmsg(id, input))) { + chunk = splitChunk("PRIVMSG", id); + } else if (NULL != (params = commandIsNotice(id, input))) { + chunk = splitChunk("NOTICE", id); + } else if (NULL != (params = commandIsAction(id, input))) { + chunk = splitChunk("PRIVMSG \1ACTION\1", id); + } else if (id != Network && id != Debug && !strncmp(input, "/say ", 5)) { + params = &input[5]; + chunk = splitChunk("PRIVMSG", id); + } else { + return 0; + } + if (strlen(params) <= (size_t)chunk) return 0; + for ( + int split; + params[(split = splitLen(chunk, params))]; + params = ¶ms[split + 1] + ) { + if (params[split] == '\n') continue; + return (params - input) + split; + } + return 0; +} + void command(uint id, char *input) { if (id == Debug && input[0] != '/' && !self.restricted) { commandQuote(id, input); |