InspIRCd  3.0
message.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2017 Peter Powell <[email protected]>
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 
23 enum MessageType
24 {
26  MSG_PRIVMSG,
27 
29  MSG_NOTICE
30 };
31 
32 class CoreExport MessageDetails
33 {
34  public:
35  /* Whether to send the original message back to clients with echo-message support. */
36  bool echooriginal;
37 
39  CUList exemptions;
40 
41  /* The original message as sent by the user. */
42  const std::string originaltext;
43 
45  std::string text;
46 
48  const MessageType type;
49 
50  MessageDetails(MessageType mt, const std::string& msg)
51  : echooriginal(false)
52  , originaltext(msg)
53  , text(msg)
54  , type(mt)
55  {
56  }
57 };
58 
60 class CoreExport MessageTarget
61 {
62  public:
65  {
68 
71 
73  TYPE_SERVER
74  };
75 
76  private:
78  void* dest;
79 
80  public:
82  char status;
83 
89 
94  MessageTarget(Channel* channel, char statuschar)
95  : dest(channel)
96  , status(statuschar)
97  , type(TYPE_CHANNEL)
98  {
99  }
100 
105  : dest(user)
106  , status(0)
107  , type(TYPE_USER)
108  {
109  }
110 
114  MessageTarget(std::string* server)
115  : dest(server)
116  , status(0)
117  , type(TYPE_SERVER)
118  {
119  }
120 
122  template<typename T>
123  T* Get() const
124  {
125  return static_cast<T*>(dest);
126  }
127 };
TargetType
Definition: message.h:64
Definition: message.h:60
Definition: users.h:224
MessageTarget::TargetType type
Definition: message.h:88
MessageTarget(User *user)
Definition: message.h:104
Definition: message.h:32
Definition: message.h:70
char status
Definition: message.h:82
CUList exemptions
Definition: message.h:39
MessageTarget(std::string *server)
Definition: message.h:114
T * Get() const
Definition: message.h:123
MessageTarget(Channel *channel, char statuschar)
Definition: message.h:94
Definition: message.h:67
std::string text
Definition: message.h:45
const MessageType type
Definition: message.h:48
Definition: channels.h:37