- Command(InspIRCd* Instance, const std::string &cmd, const char *flags, int minpara, int before_reg = false, int penalty = 1) : ServerInstance(Instance), command(cmd), flags_needed(flags ? *flags : 0), min_params(minpara), disabled(false), works_before_reg(before_reg), Penalty(penalty)
- {
- use_count = 0;
- total_bytes = 0;
- source = "<core>";
- syntax = "";
- translation.clear();
- }
+ CommandBase(Module* me, const std::string& cmd, unsigned int minpara = 0, unsigned int maxpara = 0);
+
+ virtual RouteDescriptor GetRouting(User* user, const CommandBase::Params& parameters);
+
+ /** Encode a parameter for server->server transmission.
+ * Used for parameters for which the translation type is TR_CUSTOM.
+ * @param parameter The parameter to encode. Can be modified in place.
+ * @param index The parameter index (0 == first parameter).
+ */
+ virtual void EncodeParameter(std::string& parameter, unsigned int index);
+
+ virtual ~CommandBase();
+};
+
+class CoreExport Command : public CommandBase
+{
+ protected:
+ /** Initializes a new instance of the Command class.
+ * @param me The module which created this instance.
+ * @param cmd The name of the command.
+ * @param minpara The minimum number of parameters that the command accepts.
+ * @param maxpara The maximum number of parameters that the command accepts.
+ */
+ Command(Module* me, const std::string& cmd, unsigned int minpara = 0, unsigned int maxpara = 0);
+
+ public:
+ /** Unregisters this command from the command parser. */
+ ~Command() CXX11_OVERRIDE;
+
+ /** The user modes required to be able to execute this command. */
+ unsigned char flags_needed;
+
+ /** Whether the command will not be forwarded by the linking module even if it comes via ENCAP. */
+ bool force_manual_route;
+
+ /** The number of seconds worth of penalty that executing this command gives. */
+ unsigned int Penalty;
+
+ /** The number of times this command has been executed. */
+ unsigned long use_count;
+
+ /** If non-empty then the syntax of the parameter for this command. */
+ std::string syntax;
+
+ /** Whether the command can be issued before registering. */
+ bool works_before_reg;