aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGravatar Sadie Powell2019-12-08 17:38:47 +0000
committerGravatar Sadie Powell2019-12-08 17:47:07 +0000
commit034dad6ab0df48172a70de70a9d0de4a9092112e (patch)
tree0e852f3554dbce37d8e2e360fa099148155e8cab /include
parentMove the nationalchars locale files to the docs directory. (diff)
parentClean up the initialisation of the InspIRCd class. (diff)
Merge branch 'insp3' into master.
Diffstat (limited to 'include')
-rw-r--r--include/channels.h3
-rw-r--r--include/dynref.h2
-rw-r--r--include/modules/ircv3_replies.h86
-rw-r--r--include/numericbuilder.h4
-rw-r--r--include/protocol.h20
5 files changed, 87 insertions, 28 deletions
diff --git a/include/channels.h b/include/channels.h
index d346db8ef..5957ae668 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -283,8 +283,9 @@ class CoreExport Channel : public Extensible
/** Write a NOTICE to all local users on the channel
* @param text Text to send
+ * @param status The minimum status rank to send this message to.
*/
- void WriteNotice(const std::string& text);
+ void WriteNotice(const std::string& text, char status = 0);
};
inline bool Channel::HasUser(User* user)
diff --git a/include/dynref.h b/include/dynref.h
index 6e2e17423..44829164b 100644
--- a/include/dynref.h
+++ b/include/dynref.h
@@ -43,7 +43,7 @@ class CoreExport dynamic_reference_base : public interfacebase, public insp::int
ModuleRef creator;
dynamic_reference_base(Module* Creator, const std::string& Name);
~dynamic_reference_base();
- inline const std::string& GetProvider() { return name; }
+ inline const std::string& GetProvider() const { return name; }
void SetProvider(const std::string& newname);
/** Set handler to call when the target object becomes available
diff --git a/include/modules/ircv3_replies.h b/include/modules/ircv3_replies.h
index fc7a7dac9..6a490c4d1 100644
--- a/include/modules/ircv3_replies.h
+++ b/include/modules/ircv3_replies.h
@@ -45,6 +45,16 @@ class IRCv3::Replies::Reply
/** The event provider for this reply. */
ClientProtocol::EventProvider evprov;
+ /** Wraps a message in an event and sends it to a user.
+ * @param user The user to send the message to.
+ * @param msg The message to send to the user.
+ */
+ void SendInternal(LocalUser* user, ClientProtocol::Message& msg)
+ {
+ ClientProtocol::Event ev(evprov, msg);
+ user->Send(ev);
+ }
+
protected:
/** Initializes a new instance of the Reply class.
* @param Creator The module which created this instance.
@@ -70,20 +80,88 @@ class IRCv3::Replies::Reply
msg.PushParamRef(command->name);
msg.PushParam(code);
msg.PushParam(description);
+ SendInternal(user, msg);
+ }
- ClientProtocol::Event ev(evprov, msg);
- user->Send(ev);
+ template<typename T1>
+ void Send(LocalUser* user, Command* command, const std::string& code, const T1& p1, const std::string& description)
+ {
+ ClientProtocol::Message msg(cmd.c_str(), ServerInstance->Config->ServerName);
+ msg.PushParamRef(command->name);
+ msg.PushParam(code);
+ msg.PushParam(ConvToStr(p1));
+ msg.PushParam(description);
+ SendInternal(user, msg);
+ }
+
+ template<typename T1, typename T2>
+ void Send(LocalUser* user, Command* command, const std::string& code, const T1& p1, const T2& p2,
+ const std::string& description)
+ {
+ ClientProtocol::Message msg(cmd.c_str(), ServerInstance->Config->ServerName);
+ msg.PushParamRef(command->name);
+ msg.PushParam(code);
+ msg.PushParam(ConvToStr(p1));
+ msg.PushParam(ConvToStr(p2));
+ msg.PushParam(description);
+ SendInternal(user, msg);
+ }
+
+ template<typename T1, typename T2, typename T3>
+ void Send(LocalUser* user, Command* command, const std::string& code, const T1& p1, const T2& p2,
+ const T3& p3, const std::string& description)
+ {
+ ClientProtocol::Message msg(cmd.c_str(), ServerInstance->Config->ServerName);
+ msg.PushParamRef(command->name);
+ msg.PushParam(code);
+ msg.PushParam(ConvToStr(p1));
+ msg.PushParam(ConvToStr(p2));
+ msg.PushParam(ConvToStr(p3));
+ msg.PushParam(description);
+ SendInternal(user, msg);
+ }
+
+ template<typename T1, typename T2, typename T3, typename T4>
+ void Send(LocalUser* user, Command* command, const std::string& code, const T1& p1, const T2& p2,
+ const T3& p3, const T4& p4, const std::string& description)
+ {
+ ClientProtocol::Message msg(cmd.c_str(), ServerInstance->Config->ServerName);
+ msg.PushParamRef(command->name);
+ msg.PushParam(code);
+ msg.PushParam(ConvToStr(p1));
+ msg.PushParam(ConvToStr(p2));
+ msg.PushParam(ConvToStr(p3));
+ msg.PushParam(ConvToStr(p4));
+ msg.PushParam(description);
+ SendInternal(user, msg);
+ }
+
+ template<typename T1, typename T2, typename T3, typename T4, typename T5>
+ void Send(LocalUser* user, Command* command, const std::string& code, const T1& p1, const T2& p2,
+ const T3& p3, const T4& p4, const T5& p5, const std::string& description)
+ {
+ ClientProtocol::Message msg(cmd.c_str(), ServerInstance->Config->ServerName);
+ msg.PushParamRef(command->name);
+ msg.PushParam(code);
+ msg.PushParam(ConvToStr(p1));
+ msg.PushParam(ConvToStr(p2));
+ msg.PushParam(ConvToStr(p3));
+ msg.PushParam(ConvToStr(p4));
+ msg.PushParam(ConvToStr(p5));
+ msg.PushParam(description);
+ SendInternal(user, msg);
}
/**
* Sends a standard reply to the specified user if they have the specified cap
- * or a notice if they do not.s
+ * or a notice if they do not.
* @param user The user to send the reply to.
* @param command The command that the reply relates to.
* @param code A machine readable code for this reply.
* @param description A human readable description of this reply.
*/
- void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code, const std::string& description)
+ void SendIfCap(LocalUser* user, const Cap::Capability& cap, Command* command, const std::string& code,
+ const std::string& description)
{
if (cap.get(user))
Send(user, command, code, description);
diff --git a/include/numericbuilder.h b/include/numericbuilder.h
index 4431fbc52..dc95cdaf7 100644
--- a/include/numericbuilder.h
+++ b/include/numericbuilder.h
@@ -257,7 +257,7 @@ class Numerics::NoSuchChannel : public Numeric::Numeric
NoSuchChannel(const std::string& chan)
: Numeric(ERR_NOSUCHCHANNEL)
{
- push(chan);
+ push(chan.empty() ? "*" : chan);
push("No such channel");
}
};
@@ -269,7 +269,7 @@ class Numerics::NoSuchNick : public Numeric::Numeric
NoSuchNick(const std::string& nick)
: Numeric(ERR_NOSUCHNICK)
{
- push(nick);
+ push(nick.empty() ? "*" : nick);
push("No such nick");
}
};
diff --git a/include/protocol.h b/include/protocol.h
index f98f6b37d..d1e43ef7f 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -117,28 +117,8 @@ class CoreExport ProtocolInterface
*/
virtual void SendMessage(User* target, const std::string& text, MessageType type = MSG_PRIVMSG) { }
- /** Send a notice to a channel.
- * @param target The channel to message.
- * @param status The status character (e.g. %) required to receive.
- * @param text The message to send.
- */
- void SendChannelNotice(Channel* target, char status, const std::string &text)
- {
- SendMessage(target, status, text, MSG_NOTICE);
- }
-
- /** Send a notice to a user.
- * @param target The user to message.
- * @param text The message to send.
- */
- void SendUserNotice(User* target, const std::string &text)
- {
- SendMessage(target, text, MSG_NOTICE);
- }
-
/** Fill a list of servers and information about them.
* @param sl The list of servers to fill.
- * XXX: document me properly, this is shit.
*/
virtual void GetServerList(ServerList& sl) { }
};