Skip to content

Commit

Permalink
Misc module updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
SadieCat committed Oct 13, 2023
1 parent ed95462 commit 0a3a058
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions 3/m_antiknocker.cpp
Expand Up @@ -20,6 +20,7 @@

/// $ModAuthor: Sadie Powell
/// $ModAuthorMail: sadie@witchery.services
/// $ModConfig: <antiknock nickregex="(st|sn|cr|pl|pr|fr|fl|qu|br|gr|sh|sk|tr|kl|wr|bl|[bcdfgklmnprstvwz])([aeiou][aeiou][bcdfgklmnprstvwz])(ed|est|er|le|ly|y|ies|iest|ian|ion|est|ing|led|inger|[abcdfgklmnprstvwz])" docmd="yes" donick="yes" donotice="yes" shunduration="15" shunreason="User was caught in an antiknock trap">
/// $ModDesc: Attempts to block a common IRC spambot.
/// $ModDepends: core 3

Expand All @@ -33,6 +34,9 @@ class ModuleAntiKnocker CXX11_FINAL
: public Module
{
public:
bool docmd;
bool donick;
bool donotice;
std::regex nickregex;
LocalIntExt seenmsg;
unsigned long shunduration;
Expand Down Expand Up @@ -84,13 +88,16 @@ class ModuleAntiKnocker CXX11_FINAL
throw ModuleException(InspIRCd::Format("<antiknock:nickregex> is invalid: %s", err.what()));
}

shunduration = tag->getDuration("shunduration", 60*60, 60);
docmd = tag->getBool("docmd", true);
donick = tag->getBool("donick", true);
donotice = tag->getBool("donotice", false);
shunduration = tag->getDuration("shunduration", 60*15, 60);
shunreason = tag->getString("shunreason", "User was caught in an antiknock trap", 1);
}

ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
{
if (!validated || user->registered != REG_ALL)
if (!docmd || !validated || user->registered != REG_ALL)
return MOD_RES_PASSTHRU;

if (command == "PRIVMSG" && irc::equals(parameters[0], "NickServ"))
Expand Down Expand Up @@ -119,7 +126,7 @@ class ModuleAntiKnocker CXX11_FINAL

ModResult OnUserPreNick(LocalUser* user, const std::string& newnick) CXX11_OVERRIDE
{
if (!std::regex_match(newnick, nickregex))
if (!donick || !std::regex_match(newnick, nickregex))
return MOD_RES_PASSTHRU;

ServerInstance->SNO.WriteToSnoMask('a', "User %s (%s) was prevented from using a knocker nick: %s",
Expand All @@ -128,6 +135,12 @@ class ModuleAntiKnocker CXX11_FINAL
PunishUser(user);
return MOD_RES_DENY;
}

void OnUserConnect(LocalUser* user) CXX11_OVERRIDE
{
if (donotice)
user->WriteNotice("*** You are not welcome on this network if you are a malicious bot. If you are not a malicious bot bot please ignore this message.");
}
};

MODULE_INIT(ModuleAntiKnocker)
Expand Down

0 comments on commit 0a3a058

Please sign in to comment.