]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_showfile.cpp
Sync helpop chmodes s and p with docs
[user/henk/code/inspircd.git] / src / modules / m_showfile.cpp
index 83030b7a14a7254c4e6d61761c899049f3d76180..ba3dc60e1a995d359bebc237f03adea76437a576 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2013 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2018, 2020 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2013-2014, 2016, 2018 Attila Molnar <attilamolnar@hush.com>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -51,25 +52,27 @@ class CommandShowFile : public Command
        {
        }
 
-       CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE
+       CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                if (method == SF_NUMERIC)
                {
-                       if (!introtext.empty())
+                       if (!introtext.empty() && intronumeric)
                                user->WriteRemoteNumeric(intronumeric, introtext);
 
                        for (file_cache::const_iterator i = contents.begin(); i != contents.end(); ++i)
-                               user->WriteRemoteNumeric(textnumeric, InspIRCd::Format("- %s", i->c_str()));
+                               user->WriteRemoteNumeric(textnumeric, InspIRCd::Format(" %s", i->c_str()));
 
-                       user->WriteRemoteNumeric(endnumeric, endtext.c_str());
+                       if (!endtext.empty() && endnumeric)
+                               user->WriteRemoteNumeric(endnumeric, endtext.c_str());
                }
-               else
+               else if (IS_LOCAL(user))
                {
-                       const char* msgcmd = (method == SF_MSG ? "PRIVMSG" : "NOTICE");
+                       LocalUser* const localuser = IS_LOCAL(user);
                        for (file_cache::const_iterator i = contents.begin(); i != contents.end(); ++i)
                        {
                                const std::string& line = *i;
-                               user->WriteCommand(msgcmd, ":" + line);
+                               ClientProtocol::Messages::Privmsg msg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, localuser, line, ((method == SF_MSG) ? MSG_PRIVMSG : MSG_NOTICE));
+                               localuser->Send(ServerInstance->GetRFCEvents().privmsg, msg);
                        }
                }
                return CMD_SUCCESS;
@@ -171,7 +174,7 @@ class ModuleShowFile : public Module
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides support for showing text files to users", VF_VENDOR);
+               return Version("Adds support for showing the contents of files to users when they execute a command.", VF_VENDOR);
        }
 };