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:
36  bool echo;
37 
38  /* Whether to send the original message back to clients with echo-message support. */
39  bool echo_original;
40 
42  CUList exemptions;
43 
44  /* The original message as sent by the user. */
45  const std::string original_text;
46 
49 
52 
54  std::string text;
55 
57  const MessageType type;
58 
65  virtual bool IsCTCP(std::string& name, std::string& body) const = 0;
66 
71  virtual bool IsCTCP(std::string& name) const = 0;
72 
74  virtual bool IsCTCP() const = 0;
75 
76  protected:
77  MessageDetails(MessageType mt, const std::string& msg, const ClientProtocol::TagMap& tags)
78  : echo(true)
79  , echo_original(false)
80  , original_text(msg)
81  , tags_in(tags)
82  , text(msg)
83  , type(mt)
84  {
85  }
86 };
87 
89 class CoreExport MessageTarget
90 {
91  public:
94  {
97 
100 
102  TYPE_SERVER
103  };
104 
105  private:
107  void* dest;
108 
109  public:
111  char status;
112 
118 
123  MessageTarget(Channel* channel, char statuschar)
124  : dest(channel)
125  , status(statuschar)
126  , type(TYPE_CHANNEL)
127  {
128  }
129 
134  : dest(user)
135  , status(0)
136  , type(TYPE_USER)
137  {
138  }
139 
143  MessageTarget(std::string* server)
144  : dest(server)
145  , status(0)
146  , type(TYPE_SERVER)
147  {
148  }
149 
151  template<typename T>
152  T* Get() const
153  {
154  return static_cast<T*>(dest);
155  }
156 };
TargetType
Definition: message.h:93
Definition: message.h:89
Definition: users.h:224
MessageTarget::TargetType type
Definition: message.h:117
MessageTarget(User *user)
Definition: message.h:133
Definition: message.h:32
Definition: message.h:99
char status
Definition: message.h:111
CUList exemptions
Definition: message.h:42
MessageTarget(std::string *server)
Definition: message.h:143
T * Get() const
Definition: message.h:152
MessageTarget(Channel *channel, char statuschar)
Definition: message.h:123
const ClientProtocol::TagMap tags_in
Definition: message.h:48
bool echo
Definition: message.h:36
Definition: message.h:96
ClientProtocol::TagMap tags_out
Definition: message.h:51
std::string text
Definition: message.h:54
const MessageType type
Definition: message.h:57
Definition: channels.h:37