Send a WHO in response to NAMES to get usernames

Other than this slight hack, I think coloring by username rather than
nick is a much better idea.
master
Curtis McEnroe 2018-08-03 18:58:19 -04:00
parent 3b490562d4
commit c609684d2b
No known key found for this signature in database
GPG Key ID: CEA2F97ADCFCD77C
1 changed files with 31 additions and 5 deletions

36
chat.c
View File

@ -294,14 +294,38 @@ static void handleTopic(char *prefix, char *params) {
uiTopic(topic); uiTopic(topic);
} }
static void handle353(char *prefix, char *params) { static void handle366(char *prefix, char *params) {
(void)prefix;
shift(&params);
char *chan = shift(&params);
clientFmt("WHO %s\r\n", chan);
}
static char whoBuf[4096];
static size_t whoLen;
static void handle352(char *prefix, char *params) {
(void)prefix; (void)prefix;
shift(&params); shift(&params);
shift(&params); shift(&params);
char *user = shift(&params);
shift(&params);
shift(&params);
char *nick = shift(&params);
whoLen += snprintf(
&whoBuf[whoLen], sizeof(whoBuf) - whoLen,
"%s\3%d%s\3",
(whoLen ? ", " : ""), color(user), nick
);
}
static void handle315(char *prefix, char *params) {
(void)prefix;
shift(&params);
char *chan = shift(&params); char *chan = shift(&params);
char *names = shift(&params); whoLen = 0;
// TODO: Do a WHO instead to get usernames uiFmt(
uiFmt("In %s are %s", chan, names); "In \3%d%s\3 are %s",
color(chan), chan, whoBuf
);
} }
static void handlePrivmsg(char *prefix, char *params) { static void handlePrivmsg(char *prefix, char *params) {
@ -324,8 +348,10 @@ static const struct {
Handler handler; Handler handler;
} HANDLERS[] = { } HANDLERS[] = {
{ "001", handle001 }, { "001", handle001 },
{ "315", handle315 },
{ "332", handle332 }, { "332", handle332 },
{ "353", handle353 }, { "352", handle352 },
{ "366", handle366 },
{ "JOIN", handleJoin }, { "JOIN", handleJoin },
{ "NOTICE", handleNotice }, { "NOTICE", handleNotice },
{ "PART", handlePart }, { "PART", handlePart },