Skip to content

Commit

Permalink
Add support for quits (duh!)
Browse files Browse the repository at this point in the history
  • Loading branch information
srd424 committed Dec 20, 2021
1 parent 066c124 commit c192bdb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ $ mv ignore.so ~/.znc/modules

### Usage

Command | Arguments | Description
------------|---------------------------------|--------------------------------------------------------------------------------
AddHost | [mMaAnNcCjp] `<nick!user@host>` | Ignore a hostmask from [m]essage, [a]ction, [n]otice, [c]tcp, [j]oins, [p]arts;
| | uppercase = private
AddPattern | [mMaAnNcCjp] `<regex>` | Ignore text matching a regular expression
Clear | | Clear all ignore entries
Del | `<n>` | Remove an ignore entry by index
Help | search | Generate this output
List | | Display the ignore list
Command | Arguments | Description
------------|----------------------------------|----------------------------------------------------------------------------
AddHost | [mMaAnNcCjpq] `<nick!user@host>` | Ignore a hostmask from [m]essage, [a]ction, [n]otice, [c]tcp, [j]oins,
| | [p]arts, [q]uits, uppercase = private
AddPattern | [mMaAnNcCjpq] `<regex>` | Ignore text matching a regular expression
Clear | | Clear all ignore entries
Del | `<n>` | Remove an ignore entry by index
Help | search | Generate this output
List | | Display the ignore list

The required arguments for AddHost and AddPattern should be "quoted" if they contain spaces.

Expand Down
27 changes: 17 additions & 10 deletions ignore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using namespace std;

enum {
enum IMode {
ModeMsg,
ModePrivMsg,
ModeAction,
Expand All @@ -13,7 +13,8 @@ enum {
ModeCTCP,
ModePrivCTCP,
ModeJoin,
ModePart
ModePart,
ModeQuit
};

class MatcherError : public runtime_error {
Expand Down Expand Up @@ -397,15 +398,21 @@ CModule::EModRet ModIgnore::check(CNick& nick, CString& message, int mode) {

CModule::EModRet ModIgnore::OnRawMessage(CMessage &message) {
CString msgtext;
if(message.GetType() == CMessage::Type::Join) {
msgtext = message.ToString(message.IncludeAll);
return check(message.GetNick(), msgtext, ModeJoin);
}
if(message.GetType() == CMessage::Type::Part) {
msgtext = message.ToString(message.IncludeAll);
return check(message.GetNick(), msgtext, ModePart);
IMode msgmode;
CMessage::Type mtype = message.GetType();

if (mtype == CMessage::Type::Join) {
msgmode = ModeJoin;
} else if (mtype == CMessage::Type::Part) {
msgmode = ModePart;
} else if (mtype == CMessage::Type::Quit) {
msgmode = ModeQuit;
} else {
return CONTINUE;
}
return CONTINUE;

msgtext = message.ToString(message.IncludeAll);
return check(message.GetNick(), msgtext, msgmode);
}

CModule::EModRet ModIgnore::OnChanMsg(CNick& nick, CChan& chan, CString& message) {
Expand Down
8 changes: 4 additions & 4 deletions ignore.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <bitset>
#include <iostream>

const int NUM_MODES = 10;
const char MODES[NUM_MODES+1] = "mMaAnNcCjp";
const int NUM_MODES = 11;
const char MODES[NUM_MODES+1] = "mMaAnNcCjpq";

class Matcher {
protected:
Expand Down Expand Up @@ -89,9 +89,9 @@ class ModIgnore : public CModule {
MODCONSTRUCTOR(ModIgnore) {
AddHelpCommand();
AddCommand("AddHost", static_cast<CModCommand::ModCmdFunc>(&ModIgnore::CmdAddHostMatcher),
"[mMaAnNcCjp] <nick!user@host>", "Ignore a hostmask from [m]essage, [a]ction, [n]otice, [c]tcp, [j]oins, [p]arts; uppercase = private");
"[mMaAnNcCjpq] <nick!user@host>", "Ignore a hostmask from [m]essage, [a]ction, [n]otice, [c]tcp, [j]oins, [p]arts, [q]uits; uppercase = private");
AddCommand("AddPattern",static_cast<CModCommand::ModCmdFunc>(&ModIgnore::CmdAddRegexMatcher),
"[mMaAnNcCjp] <regex>", "Ignore text matching a regular expression");
"[mMaAnNcCjpq] <regex>", "Ignore text matching a regular expression");
AddCommand("Del", static_cast<CModCommand::ModCmdFunc>(&ModIgnore::CmdDelIgnore),
"<n>", "Remove an ignore entry by index");
AddCommand("List", static_cast<CModCommand::ModCmdFunc>(&ModIgnore::CmdList),
Expand Down

0 comments on commit c192bdb

Please sign in to comment.