diff options
| author | C. McEnroe | 2020-02-25 02:54:15 -0500 | 
|---|---|---|
| committer | C. McEnroe | 2020-02-25 02:54:15 -0500 | 
| commit | e9524b4af39e6b83acd2a54d67dfec3c3a41d8cc (patch) | |
| tree | 12addbf469a1cbf814fdb6f7a34ef3d93be87137 | |
| parent | 431945614da363f1e89463ea5cadbf882c3c64d6 (diff) | |
Handle changing setParamModes, paramModes and other channel modes
| -rw-r--r-- | handle.c | 42 | 
1 files changed, 39 insertions, 3 deletions
@@ -488,6 +488,18 @@ static void handleTopic(struct Message *msg) {  	}  } +static const char *ModeNames[256] = { +	['i'] = "invite-only", +	['k'] = "key", +	['l'] = "client limit", +	['m'] = "moderated", +	['n'] = "no external messages", +	['o'] = "operator", +	['s'] = "secret", +	['t'] = "protected topic", +	['v'] = "voice", +}; +  static void handleMode(struct Message *msg) {  	require(msg, true, 2);  	if (!strchr(network.chanTypes, msg->params[0][0])) { @@ -500,6 +512,8 @@ static void handleMode(struct Message *msg) {  	uint param = 2;  	char buf[1024] = "";  	for (char *ch = msg->params[1]; *ch; ++ch) { +		const char *name = ModeNames[(byte)*ch]; +		if (!name) name = (const char[]) { *ch, '\0' };  		if (*ch == '+') {  			set = true;  		} else if (*ch == '-') { @@ -541,11 +555,33 @@ static void handleMode(struct Message *msg) {  			);  		} else if (strchr(network.paramModes, *ch)) { -			// TODO +			assert(param < ParamCap); +			catf( +				buf, sizeof(buf), ", %ssets \3%02d%s\3 %s %s %s", +				(set ? "" : "un"), hash(msg->params[0]), msg->params[0], name, +				(set ? "to" : "from"), msg->params[param++] +			); +  		} else if (strchr(network.setParamModes, *ch)) { -			// TODO +			if (set) { +				assert(param < ParamCap); +				catf( +					buf, sizeof(buf), ", sets \3%02d%s\3 %s to %s", +					hash(msg->params[0]), msg->params[0], name, +					msg->params[param++] +				); +			} else { +				catf( +					buf, sizeof(buf), ", unsets \3%02d%s\3 %s", +					hash(msg->params[0]), msg->params[0], name +				); +			} +  		} else { -			// TODO +			catf( +				buf, sizeof(buf), ", %ssets \3%02d%s\3 %s", +				(set ? "" : "un"), hash(msg->params[0]), msg->params[0], name +			);  		}  	}  	if (strlen(buf) < 2) return;  | 
