diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-01-26 15:05:22 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-01-26 15:05:22 +0100 |
commit | 045747290ba1088daf7f70d5d36d0eb4c8ba2b4e (patch) | |
tree | ed3798ff5f8606ab56edee40c37e84399d9fa736 /include/users.h | |
parent | 1ea821e8c1c7a65f826553bea7d5b7503f04243d (diff) | |
parent | 4d4306d8a91387baf642d6e4703f87246c688d2f (diff) |
Merge branch 'master+foreachneighbor'
Diffstat (limited to 'include/users.h')
-rw-r--r-- | include/users.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/include/users.h b/include/users.h index ceee4396b..fa8f610bc 100644 --- a/include/users.h +++ b/include/users.h @@ -248,6 +248,19 @@ class CoreExport User : public Extensible std::bitset<ModeParser::MODEID_MAX> modes; public: + /** To execute a function for each local neighbor of a user, inherit from this class and + * pass an instance of it to User::ForEachNeighbor(). + */ + class ForEachNeighborHandler + { + public: + /** Method to execute for each local neighbor of a user. + * Derived classes must implement this. + * @param user Current neighbor + */ + virtual void Execute(LocalUser* user) = 0; + }; + /** List of Memberships for this user */ typedef insp::intrusive_list<Membership> ChanList; @@ -535,12 +548,15 @@ class CoreExport User : public Extensible */ void WriteCommon(const char* text, ...) CUSTOM_PRINTF(2, 3); - /** Write a quit message to all common users, as in User::WriteCommonExcept but with a specific - * quit message for opers only. - * @param normal_text Normal user quit message - * @param oper_text Oper only quit message + /** Execute a function once for each local neighbor of this user. By default, the neighbors of a user are the users + * who have at least one common channel with the user. Modules are allowed to alter the set of neighbors freely. + * This function is used for example to send something conditionally to neighbors, or to send different messages + * to different users depending on their oper status. + * @param handler Function object to call, inherited from ForEachNeighborHandler. + * @param include_self True to include this user in the set of neighbors, false otherwise. + * Modules may override this. Has no effect if this user is not local. */ - void WriteCommonQuit(const std::string &normal_text, const std::string &oper_text); + void ForEachNeighbor(ForEachNeighborHandler& handler, bool include_self = true); /** Dump text to a user target, splitting it appropriately to fit * @param linePrefix text to prefix each complete line with |