summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mode.h5
-rw-r--r--src/mode.cpp28
2 files changed, 25 insertions, 8 deletions
diff --git a/include/mode.h b/include/mode.h
index 59dc9dc3b..23bf03436 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -218,10 +218,7 @@ class ModeParser
*/
std::vector<ModeWatcher*> modewatchers[256];
- /*char* GiveHops(userrec *user,char *dest,chanrec *chan,int status);
- char* GiveVoice(userrec *user,char *dest,chanrec *chan,int status);
- char* TakeHops(userrec *user,char *dest,chanrec *chan,int status);
- char* TakeVoice(userrec *user,char *dest,chanrec *chan,int status);*/
+ void DisplayCurrentModes(userrec *user, userrec* targetuser, chanrec* targetchannel, const char* text);
public:
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];