#include "Server.hpp"
#include "errcodes.hpp"

int
Server::_cmdMOTD(const Message& msg)
{
    static const char *const motd[] = {
        "- We're no strangers to love",
        "- You know the rules and so do I",
        "- A full commitment's what I'm thinking of",
        "- You wouldn't get this from any other guy",
        "- ",
        "- I just wanna tell you how I'm feeling",
        "- Gotta make you understand",
        "- ",
        "- Never gonna give you up",
        "- Never gonna let you down",
        "- Never gonna run around and desert you",
        "- Never gonna make you cry",
        "- Never gonna say goodbye",
        "- Never gonna tell a lie and hurt you",
        "- ",
        "- We've known each other for so long",
        "- Your heart's been aching, but",
        "- You're too shy to say it",
        "- Inside, we both know what's been going on",
        "- We know the game and we're gonna play it",
        "- ",
        "- And if you ask me how I'm feeling",
        "- Don't tell me you're too blind to see",
        "- ",
        "- Never gonna give you up",
        "- Never gonna let you down",
        "- Never gonna run around and desert you",
        "- Never gonna make you cry",
        "- Never gonna say goodbye",
        "- Never gonna tell a lie and hurt you",
        "- ",
        "- Never gonna give you up",
        "- Never gonna let you down",
        "- Never gonna run around and desert you",
        "- Never gonna make you cry",
        "- Never gonna say goodbye",
        "- Never gonna tell a lie and hurt you",
        "- ",
        "- (Ooh, give you up)",
        "- (Ooh, give you up)",
        "- Never gonna give, never gonna give",
        "- (Give you up)",
        "- Never gonna give, never gonna give",
        "- (Give you up)",
        "- ",
        "- We've known each other for so long",
        "- Your heart's been aching, but",
        "- You're too shy to say it",
        "- Inside, we both know what's been going on",
        "- We know the game and we're gonna play it",
        "- ",
        "- I just wanna tell you how I'm feeling",
        "- Gotta make you understand",
        "- ",
        "- Never gonna give you up",
        "- Never gonna let you down",
        "- Never gonna run around and desert you",
        "- Never gonna make you cry",
        "- Never gonna say goodbye",
        "- Never gonna tell a lie and hurt you",
        "- ",
        "- Never gonna give you up",
        "- Never gonna let you down",
        "- Never gonna run around and desert you",
        "- Never gonna make you cry",
        "- Never gonna say goodbye",
        "- Never gonna tell a lie and hurt you",
        "- ",
        "- Never gonna give you up",
        "- Never gonna let you down",
        "- Never gonna run around and desert you",
        "- Never gonna make you cry",
        "- Never gonna say goodbye",
        "- Never gonna tell a lie and hurt you"
    };

    if (msg.getClient().sendCode(RPL_MOTDSTART, "- Message of the day -")) {
        return -1;
    }
    for (std::size_t i = 0; i < sizeof(motd) / sizeof(*motd); i++) {
        if (msg.getClient().sendCode(RPL_MOTD, motd[i])) {
            return -1;
        }
    }
    if (msg.getClient().sendCode(RPL_ENDOFMOTD, "End of MOTD command")) {
        return -1;
    }
    return 0;
}
