aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2016-09-23 15:26:09 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2016-09-23 15:26:09 +0200
commit663fe641bae1c5349e62fd8d964960fdebb97f9c (patch)
tree87f4f3323e573c74c1eb4f08aca267907ba80d64
parent7e8cb867ba9ca9d0f533a8329712117ba38115a6 (diff)
downloadzero-of-one-663fe641bae1c5349e62fd8d964960fdebb97f9c.zip
zero-of-one-663fe641bae1c5349e62fd8d964960fdebb97f9c.tar.bz2
Improves support for CTCP ACTIONs.
-rw-r--r--src/io/network.c38
-rw-r--r--src/tool/strings.c22
2 files changed, 51 insertions, 9 deletions
diff --git a/src/io/network.c b/src/io/network.c
index 0c9cf33..edafd4f 100644
--- a/src/io/network.c
+++ b/src/io/network.c
@@ -500,14 +500,36 @@ int ZoO_network_send (struct ZoO_network net [const restrict static 1])
{
int const old_errno = errno;
- snprintf
- (
- net->in,
- 512,
- "PRIVMSG %s :%s\r\n",
- net->channel,
- net->out
- );
+ if (ZoO_IS_PREFIX("\001action", net->out))
+ {
+
+ net->out[1] = 'A';
+ net->out[2] = 'C';
+ net->out[3] = 'T';
+ net->out[4] = 'I';
+ net->out[5] = 'O';
+ net->out[6] = 'N';
+
+ snprintf
+ (
+ net->in,
+ 512,
+ "PRIVMSG %s :%s\001\r\n",
+ net->channel,
+ net->out
+ );
+ }
+ else
+ {
+ snprintf
+ (
+ net->in,
+ 512,
+ "PRIVMSG %s :%s\r\n",
+ net->channel,
+ net->out
+ );
+ }
errno = 0;
diff --git a/src/tool/strings.c b/src/tool/strings.c
index 9fe13f6..73a5cdd 100644
--- a/src/tool/strings.c
+++ b/src/tool/strings.c
@@ -224,6 +224,26 @@ int ZoO_strings_parse
w_start = i;
+ if (input[i] == '\001')
+ {
+ /* This is an CTCP command. */
+ /* We'll remove the trailing '\001' so that only the first word */
+ /* indicates the need for CTCP (uppercase) syntax. */
+
+ if ((input_size >= 1) && (input[input_size - 1] == '\001'))
+ {
+ input[input_size - 1] = ' ';
+ }
+ else
+ {
+ ZoO_WARNING
+ (
+ "CTCP sequence '%s' did not end with a \\001 character.",
+ input
+ );
+ }
+ }
+
for (; i < input_size; ++i)
{
if (input[i] == ' ')
@@ -265,7 +285,7 @@ int ZoO_strings_parse
s,
punctuations_count,
punctuations,
- /* overflow-safe: w_start < i */
+ /* overflow-safe: w_start =< i */
(i - w_start),
(input + w_start)
) < 0