From 5bbea4813d98b981d9277f80cbad5f2349da36a9 Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 8 Jul 2006 18:22:34 +0000 Subject: Added DisplayCurrentModes which will display the modes of a channel or nick git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4181 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/mode.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mode.cpp b/src/mode.cpp index 8415a3bf4..808b01388 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -229,6 +229,24 @@ const char* ModeParser::Revoke(userrec *d,chanrec *chan,int MASK) return ""; } +void ModeParser::DisplayCurrentModes(userrec *user, userrec* targetuser, chanrec* targetchannel, const char* text) +{ + if (targetchannel) + { + /* Display channel's current mode string */ + WriteServ(user->fd,"324 %s %s +%s",user->nick, targetchannel->name, chanmodes(targetchannel, targetchannel->HasUser(user))); + WriteServ(user->fd,"329 %s %s %d", user->nick, targetchannel->name, targetchannel->created); + } + else if (targetuser) + { + /* Display user's current mode string */ + WriteServ(user->fd,"221 %s :+%s",targetuser->nick,targetuser->FormatModes()); + } + /* No such nick/channel */ + WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, text); + return; +} + void ModeParser::Process(char **parameters, int pcnt, userrec *user, bool servermode) { std::string target = parameters[0]; @@ -239,11 +257,14 @@ void ModeParser::Process(char **parameters, int pcnt, userrec *user, bool server log(DEBUG,"ModeParser::Process start"); - if (pcnt > 1) + if (pcnt == 1) + { + this->DisplayCurrentModes(user, targetuser, targetchannel, parameters[0]); + } + else if (pcnt > 1) { if (targetchannel) { - log(DEBUG,"Target type is CHANNEL"); type = MODETYPE_CHANNEL; mask = MASK_CHANNEL; @@ -270,14 +291,13 @@ void ModeParser::Process(char **parameters, int pcnt, userrec *user, bool server } else if (targetuser) { - log(DEBUG,"Target type is USER"); type = MODETYPE_USER; mask = MASK_USER; } else { /* No such nick/channel */ - log(DEBUG,"Target type is UNKNOWN, bailing"); + WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]); return; } std::string mode_sequence = parameters[1]; -- cgit v1.2.3