diff options
author | June McEnroe <june@causal.agency> | 2020-02-19 21:47:16 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-02-19 21:47:16 -0500 |
commit | 56de4668acf0c18e4cd0e2a9c53bc4fc2db98306 (patch) | |
tree | c68f60818fb436ed8f73c3d1a158b88547ca957e /command.c | |
parent | Format WHOIS signon date with %F %T (diff) | |
download | catgirl-56de4668acf0c18e4cd0e2a9c53bc4fc2db98306.tar.gz catgirl-56de4668acf0c18e4cd0e2a9c53bc4fc2db98306.zip |
Add /ban, /unban and handle ban list replies
Diffstat (limited to '')
-rw-r--r-- | command.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/command.c b/command.c index cc650da..c0b2ea2 100644 --- a/command.c +++ b/command.c @@ -143,6 +143,30 @@ static void commandKick(uint id, char *params) { } } +static void commandBan(uint id, char *params) { + if (params) { + int count = 1; + for (char *ch = params; *ch; ++ch) { + if (*ch == ' ') count++; + } + char b[ParamCap - 2] = "bbbbbbbbbbbbb"; + ircFormat("MODE %s +%.*s %s\r\n", idNames[id], count, b, params); + } else { + ircFormat("MODE %s +b\r\n", idNames[id]); + replies.ban++; + } +} + +static void commandUnban(uint id, char *params) { + if (!params) return; + int count = 1; + for (char *ch = params; *ch; ++ch) { + if (*ch == ' ') count++; + } + char b[ParamCap - 2] = "bbbbbbbbbbbbb"; + ircFormat("MODE %s -%.*s %s\r\n", idNames[id], count, b, params); +} + static void commandList(uint id, char *params) { (void)id; if (params) { @@ -264,6 +288,7 @@ static const struct Handler { bool restricted; } Commands[] = { { "/away", .fn = commandAway }, + { "/ban", .fn = commandBan }, { "/close", .fn = commandClose }, { "/copy", .fn = commandCopy, .restricted = true }, { "/cs", .fn = commandCS }, @@ -287,6 +312,7 @@ static const struct Handler { { "/quit", .fn = commandQuit }, { "/quote", .fn = commandQuote, .restricted = true }, { "/topic", .fn = commandTopic }, + { "/unban", .fn = commandUnban }, { "/whois", .fn = commandWhois }, { "/window", .fn = commandWindow }, }; |