Add OnParameterMissing to modehandler, called when the mode handler should have a parameter, but the parser found none

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10149 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2008-08-17 16:16:49 +00:00
parent e9b7d71c55
commit 985c2bd1e6
4 changed files with 20 additions and 0 deletions

View File

@ -232,6 +232,14 @@ class CoreExport ModeHandler : public Extensible
*/ */
virtual void DisplayList(User* user, Channel* channel); virtual void DisplayList(User* user, Channel* channel);
/** In the event that the mode should be given a parameter, and no parameter was provided, this method is called.
* This allows you to give special information to the user, or handle this any way you like.
* @param user The user issuing the mode change
* @param dest For user mode changes, the target of the mode. For channel mode changes, NULL.
* @param channel For channel mode changes, the target of the mode. For user mode changes, NULL.
*/
virtual void OnParameterMissing(User* user, User* dest, Channel* channel);
/** /**
* If your mode is a listmode, this method will be called to display an empty list (just the end of list numeric) * If your mode is a listmode, this method will be called to display an empty list (just the end of list numeric)
* @param user The user issuing the command * @param user The user issuing the command

View File

@ -22,4 +22,5 @@ class ModeUserServerNoticeMask : public ModeHandler
public: public:
ModeUserServerNoticeMask(InspIRCd* Instance); ModeUserServerNoticeMask(InspIRCd* Instance);
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode); ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode);
void OnParameterMissing(User* user, User* dest, Channel* channel);
}; };

View File

@ -142,6 +142,10 @@ void ModeHandler::DisplayEmptyList(User*, Channel*)
{ {
} }
void ModeHandler::OnParameterMissing(User* user, User* dest, Channel* channel)
{
}
bool ModeHandler::CheckTimeStamp(time_t theirs, time_t ours, const std::string&, const std::string&, Channel*) bool ModeHandler::CheckTimeStamp(time_t theirs, time_t ours, const std::string&, const std::string&, Channel*)
{ {
return (ours < theirs); return (ours < theirs);
@ -571,6 +575,7 @@ void ModeParser::Process(const std::vector<std::string>& parameters, User *user,
else else
{ {
/* No parameter, continue to the next mode */ /* No parameter, continue to the next mode */
modehandlers[handler_id]->OnParameterMissing(user, targetuser, targetchannel);
continue; continue;
} }

View File

@ -51,3 +51,9 @@ ModeAction ModeUserServerNoticeMask::OnModeChange(User* source, User* dest, Chan
return MODEACTION_DENY; return MODEACTION_DENY;
} }
void ModeUserServerNoticeMask::OnParameterMissing(User* user, User* dest, Channel* channel)
{
user->WriteServ("NOTICE %s :*** The user mode +s requires a parameter (server notice mask). Please provide a parameter, e.g. '+s +*'.",
user->nick.c_str());
}