Add message to ignore patterns

weechat-hashes
C. McEnroe 2020-07-06 22:40:30 -04:00
parent 529028fe4a
commit cb84983dd1
2 changed files with 9 additions and 5 deletions

View File

@ -1,4 +1,4 @@
.Dd June 12, 2020
.Dd July 6, 2020
.Dt CATGIRL 1
.Os
.
@ -162,6 +162,7 @@ The format of the pattern is as follows:
.Ar nick Ns Op Ar !user@host
.Op Ar command
.Op Ar channel
.Op Ar message
.Ed
.
.It Fl j Ar join , Cm join = Ar join

View File

@ -46,10 +46,12 @@ const char *ignoreAdd(const char *pattern) {
}
char **dest = &ignore.patterns[ignore.len++];
if (!ex && !sp) {
asprintf(dest, "%s!*@* * *", pattern);
asprintf(dest, "%s!*@* * * *", pattern);
} else if (sp < 1) {
asprintf(dest, "%s * *", pattern);
asprintf(dest, "%s * * *", pattern);
} else if (sp < 2) {
asprintf(dest, "%s * *", pattern);
} else if (sp < 3) {
asprintf(dest, "%s *", pattern);
} else {
*dest = strdup(pattern);
@ -72,8 +74,9 @@ bool ignoreRemove(const char *pattern) {
enum Heat ignoreCheck(enum Heat heat, uint id, const struct Message *msg) {
char match[512];
snprintf(
match, sizeof(match), "%s!%s@%s %s %s",
msg->nick, msg->user, msg->host, msg->cmd, idNames[id]
match, sizeof(match), "%s!%s@%s %s %s %s",
msg->nick, msg->user, msg->host,
msg->cmd, idNames[id], (msg->params[1] ?: "")
);
for (size_t i = 0; i < ignore.len; ++i) {
if (fnmatch(ignore.patterns[i], match, FNM_CASEFOLD)) continue;