]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/modules/away.h
Remove the Kiwi links from the readme.
[user/henk/code/inspircd.git] / include / modules / away.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
5  *
6  * This file is part of InspIRCd.  InspIRCd is free software: you can
7  * redistribute it and/or modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation, version 2.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19
20 #pragma once
21
22 #include "event.h"
23
24 namespace Away
25 {
26         class EventListener;
27         class EventProvider;
28 }
29
30 class Away::EventListener
31         : public Events::ModuleEventListener
32 {
33  protected:
34         EventListener(Module* mod)
35                 : ModuleEventListener(mod, "event/away")
36         {
37         }
38
39  public:
40         /** Called when a user wishes to mark themselves as away.
41          * @param user The user who is going away.
42          * @param message The away message that the user set.
43          * @return Either MOD_RES_ALLOW to allow the user to mark themself as away, MOD_RES_DENY to
44          *         disallow the user to mark themself as away, or MOD_RES_PASSTHRU to let another module
45          *         handle the event.
46          */
47         virtual ModResult OnUserPreAway(LocalUser* user, std::string& message)
48         {
49                 return MOD_RES_PASSTHRU;
50         }
51
52         /** Called when a user wishes to mark themselves as back.
53          * @param user The user who is going away.
54          * @param message The away message that the user set.
55          * @return Either MOD_RES_ALLOW to allow the user to mark themself as back, MOD_RES_DENY to
56          *         disallow the user to mark themself as back, or MOD_RES_PASSTHRU to let another module
57          *         handle the event.
58          */
59         virtual ModResult OnUserPreBack(LocalUser* user)
60         {
61                 return MOD_RES_PASSTHRU;
62         }
63
64         /** Called when a user has marked themself as away.
65          * @param user The user who has gone away.
66          */
67         virtual void OnUserAway(User* user) = 0;
68
69         /** Called when a user has returned from being away.
70          * @param user The user who has returned from being away.
71          */
72         virtual void OnUserBack(User* user) = 0;
73 };
74
75 class Away::EventProvider
76         : public Events::ModuleEventProvider
77 {
78  public:
79         EventProvider(Module* mod)
80                 : ModuleEventProvider(mod, "event/away")
81         {
82         }
83 };