From 2816a3ff87c3c15848dfe7f71391a454992ecefe Mon Sep 17 00:00:00 2001 From: w00t Date: Mon, 10 Jul 2006 15:20:41 +0000 Subject: - Add usermode +n for notice masks - our implementation of snomasks. We're not sure how this will tie in with +s yet. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4274 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/modes/umode_n.h | 8 ++++++++ src/mode.cpp | 5 +++-- src/modes/umode_n.cpp | 26 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 include/modes/umode_n.h create mode 100644 src/modes/umode_n.cpp diff --git a/include/modes/umode_n.h b/include/modes/umode_n.h new file mode 100644 index 000000000..cf449f324 --- /dev/null +++ b/include/modes/umode_n.h @@ -0,0 +1,8 @@ +#include "mode.h" + +class ModeUserServerNoticeMask : public ModeHandler +{ + public: + ModeUserServerNoticeMask(); + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding); +}; diff --git a/src/mode.cpp b/src/mode.cpp index c3153dfee..18580a21e 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -63,6 +63,8 @@ using namespace std; #include "modes/umode_i.h" /* +o (operator) */ #include "modes/umode_o.h" +/* +n (notice mask - our implementation of snomasks) */ +#include "modes/umode_n.h" extern int MODCOUNT; extern std::vector modules; @@ -620,7 +622,6 @@ ModeParser::ModeParser() this->AddMode(new ModeUserWallops, 'w'); this->AddMode(new ModeUserInvisible, 'i'); this->AddMode(new ModeUserOperator, 'o'); - - /* TODO: User modes +swio */ + this->AddMode(new ModeUserServerNoticeMask, 'n'); } diff --git a/src/modes/umode_n.cpp b/src/modes/umode_n.cpp new file mode 100644 index 000000000..6c1b380f3 --- /dev/null +++ b/src/modes/umode_n.cpp @@ -0,0 +1,26 @@ +#include "inspircd.h" +#include "mode.h" +#include "channels.h" +#include "users.h" +#include "modes/umode_n.h" + +ModeUserServerNoticeMask::ModeUserServerNoticeMask() : ModeHandler('n', 1, 0, false, MODETYPE_USER, true) +{ +} + +ModeAction ModeUserServerNoticeMask::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) +{ + /* Only opers can change other users modes */ + if ((source != dest) && (!*source->oper)) + return MODEACTION_DENY; + + /* Set the bitfields */ + if (dest->modes[UM_SERVERNOTICE] != adding) + { + dest->modes[UM_SERVERNOTICE] = adding; + return MODEACTION_ALLOW; + } + + /* Allow the change */ + return MODEACTION_DENY; +} -- cgit v1.2.3