]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_ojoin.cpp
Merge branch 'master+chanwritenotice'
[user/henk/code/inspircd.git] / src / modules / m_ojoin.cpp
index 3710757aafa76d78cd8331937806ef01e78deca4..56cef10b4ed3f8ae533df791a238055a97ee2ec3 100644 (file)
@@ -58,25 +58,24 @@ class CommandOjoin : public SplitCommand
 
                        if (notice)
                        {
-                               channel->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s joined on official network business.",
-                                       parameters[0].c_str(), user->nick.c_str());
-                               ServerInstance->PI->SendChannelNotice(channel, 0, user->nick + " joined on official network business.");
+                               const std::string msg = user->nick + " joined on official network business.";
+                               channel->WriteNotice(msg);
+                               ServerInstance->PI->SendChannelNotice(channel, 0, msg);
                        }
                }
                else
                {
+                       channel = ServerInstance->FindChan(parameters[0]);
+                       if (!channel)
+                               return CMD_FAILURE;
+
                        ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used OJOIN in "+parameters[0]);
                        // they're already in the channel
-                       std::vector<std::string> modes;
-                       modes.push_back(parameters[0]);
-                       modes.push_back(std::string("+") + npmh->GetModeChar());
+                       Modes::ChangeList changelist;
+                       changelist.push_add(npmh, user->nick);
                        if (op)
-                       {
-                               modes[1].push_back('o');
-                               modes.push_back(user->nick);
-                       }
-                       modes.push_back(user->nick);
-                       ServerInstance->Modes->Process(modes, ServerInstance->FakeClient);
+                               changelist.push_add(ServerInstance->Modes->FindMode('o', MODETYPE_CHANNEL), user->nick);
+                       ServerInstance->Modes->Process(ServerInstance->FakeClient, channel, NULL, changelist);
                }
                return CMD_SUCCESS;
        }
@@ -147,7 +146,7 @@ class ModuleOjoin : public Module
                if (source == memb->user)
                        return MOD_RES_PASSTHRU;
 
-               source->WriteNumeric(ERR_RESTRICTED, memb->chan->name+" :Can't kick "+memb->user->nick+" as they're on official network business.");
+               source->WriteNumeric(ERR_RESTRICTED, memb->chan->name, "Can't kick "+memb->user->nick+" as they're on official network business.");
                return MOD_RES_DENY;
        }