Use separate reply counts for automatic join topics/names

This restores showing the topic and names for automatic joined
channels, while still avoiding touching the windows, by using Cold
heat.
master
C. McEnroe 2021-02-21 14:23:17 -05:00
parent 4b26ae23cd
commit 761979d33e
2 changed files with 28 additions and 11 deletions

2
chat.h
View File

@ -262,7 +262,9 @@ enum Reply {
ReplyList, ReplyList,
ReplyMode, ReplyMode,
ReplyNames, ReplyNames,
ReplyNamesAuto,
ReplyTopic, ReplyTopic,
ReplyTopicAuto,
ReplyWho, ReplyWho,
ReplyWhois, ReplyWhois,
ReplyWhowas, ReplyWhowas,

View File

@ -239,12 +239,14 @@ static void handleReplyWelcome(struct Message *msg) {
set(&self.nick, msg->params[0]); set(&self.nick, msg->params[0]);
completeTouch(Network, self.nick, Default); completeTouch(Network, self.nick, Default);
if (self.join) { if (self.join) {
ircFormat("JOIN %s\r\n", self.join); uint count = 1;
if (!strchr(self.join, ',')) { for (const char *ch = self.join; *ch && *ch != ' '; ++ch) {
replies[ReplyJoin]++; if (*ch == ',') count++;
replies[ReplyTopic]++;
replies[ReplyNames]++;
} }
ircFormat("JOIN %s\r\n", self.join);
if (count == 1) replies[ReplyJoin]++;
replies[ReplyTopicAuto] += count;
replies[ReplyNamesAuto] += count;
} }
} }
@ -527,17 +529,26 @@ static void handleReplyNames(struct Message *msg) {
char *user = strsep(&name, "@"); char *user = strsep(&name, "@");
enum Color color = (user ? hash(user) : Default); enum Color color = (user ? hash(user) : Default);
completeAdd(id, nick, color); completeAdd(id, nick, color);
if (!replies[ReplyNames]) continue; if (!replies[ReplyNames] && !replies[ReplyNamesAuto]) continue;
catf(&cat, "%s\3%02d%s\3", (buf[0] ? ", " : ""), color, prefixes); catf(&cat, "%s\3%02d%s\3", (buf[0] ? ", " : ""), color, prefixes);
} }
if (!cat.len) return; if (!cat.len) return;
uiFormat( uiFormat(
id, Warm, tagTime(msg), id, (replies[ReplyNamesAuto] ? Cold : Warm), tagTime(msg),
"In \3%02d%s\3 are %s", "In \3%02d%s\3 are %s",
hash(msg->params[2]), msg->params[2], buf hash(msg->params[2]), msg->params[2], buf
); );
} }
static void handleReplyEndOfNames(struct Message *msg) {
(void)msg;
if (replies[ReplyNamesAuto]) {
replies[ReplyNamesAuto]--;
} else if (replies[ReplyNames]) {
replies[ReplyNames]--;
}
}
static char whoBuf[1024]; static char whoBuf[1024];
static struct Cat whoCat = { whoBuf, sizeof(whoBuf), 0 }; static struct Cat whoCat = { whoBuf, sizeof(whoBuf), 0 };
@ -593,11 +604,10 @@ static void handleReplyTopic(struct Message *msg) {
require(msg, false, 3); require(msg, false, 3);
uint id = idFor(msg->params[1]); uint id = idFor(msg->params[1]);
topicComplete(id, msg->params[2]); topicComplete(id, msg->params[2]);
if (!replies[ReplyTopic]) return; if (!replies[ReplyTopic] && !replies[ReplyTopicAuto]) return;
replies[ReplyTopic]--;
urlScan(id, NULL, msg->params[2]); urlScan(id, NULL, msg->params[2]);
uiFormat( uiFormat(
id, Warm, tagTime(msg), id, (replies[ReplyTopicAuto] ? Cold : Warm), tagTime(msg),
"The sign in \3%02d%s\3 reads: %s", "The sign in \3%02d%s\3 reads: %s",
hash(msg->params[1]), msg->params[1], msg->params[2] hash(msg->params[1]), msg->params[1], msg->params[2]
); );
@ -605,6 +615,11 @@ static void handleReplyTopic(struct Message *msg) {
id, tagTime(msg), "The sign in %s reads: %s", id, tagTime(msg), "The sign in %s reads: %s",
msg->params[1], msg->params[2] msg->params[1], msg->params[2]
); );
if (replies[ReplyTopicAuto]) {
replies[ReplyTopicAuto]--;
} else {
replies[ReplyTopic]--;
}
} }
static void swap(wchar_t *a, wchar_t *b) { static void swap(wchar_t *a, wchar_t *b) {
@ -1281,7 +1296,7 @@ static const struct Handler {
{ "349", -ReplyExcepts, NULL }, { "349", -ReplyExcepts, NULL },
{ "352", +ReplyWho, handleReplyWho }, { "352", +ReplyWho, handleReplyWho },
{ "353", 0, handleReplyNames }, { "353", 0, handleReplyNames },
{ "366", -ReplyNames, NULL }, { "366", 0, handleReplyEndOfNames },
{ "367", +ReplyBan, handleReplyBanList }, { "367", +ReplyBan, handleReplyBanList },
{ "368", -ReplyBan, NULL }, { "368", -ReplyBan, NULL },
{ "369", -ReplyWhowas, handleReplyEndOfWhowas }, { "369", -ReplyWhowas, handleReplyEndOfWhowas },