Browse Source

Updated Jupiter; updated plugins as necessary

pull/3/head
Jessica James 9 years ago
parent
commit
d8eedce01a
  1. 2
      Bot/Bot.vcxproj
  2. 6
      Bot/Bot.vcxproj.filters
  3. 9
      Bot/Console_Command.h
  4. 63
      Bot/Generic_Command.cpp
  5. 128
      Bot/Generic_Command.h
  6. 86
      Bot/IRC_Bot.cpp
  7. 15
      Bot/IRC_Command.h
  8. 12
      CoreCommands/CoreCommands.cpp
  9. 82
      ExtraCommands/ExtraCommands.cpp
  10. 14
      FunCommands/FunCommands.cpp
  11. 2
      Jupiter
  12. 8
      PluginManager/PluginManager.cpp
  13. 2
      PluginManager/PluginManager.h
  14. BIN
      Release/Bot.lib
  15. BIN
      Release/Plugins/RenX.Core.lib
  16. 24
      RenX.Ladder/RenX_Ladder.cpp

2
Bot/Bot.vcxproj

@ -88,7 +88,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Console_Command.cpp" />
<ClCompile Include="Generic_Command.cpp" />
<ClCompile Include="IRC_Command.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="IRC_Bot.cpp" />
@ -96,7 +95,6 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="Console_Command.h" />
<ClInclude Include="Generic_Command.h" />
<ClInclude Include="IRC_Bot.h" />
<ClInclude Include="IRC_Command.h" />
<ClInclude Include="Jupiter_Bot.h" />

6
Bot/Bot.vcxproj.filters

@ -30,9 +30,6 @@
<ClCompile Include="Console_Command.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Generic_Command.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="IRC_Bot.h">
@ -50,9 +47,6 @@
<ClInclude Include="Console_Command.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Generic_Command.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Library Include="..\Jupiter\Release\Jupiter.lib">

9
Bot/Console_Command.h

@ -24,10 +24,9 @@
* @brief Provides an extendable command system specialized for console-based commands.
*/
#include "Jupiter/Command.h"
#include "Jupiter/GenericCommand.h"
#include "Jupiter/ArrayList.h"
#include "Jupiter_Bot.h"
#include "Generic_Command.h"
class ConsoleCommand;
@ -114,11 +113,11 @@ template <typename T> Generic_Command_As_Console_Command<T>::Generic_Command_As_
template<typename T> void Generic_Command_As_Console_Command<T>::trigger(const Jupiter::ReadableString &parameters)
{
GenericCommand::ResponseLine *del;
GenericCommand::ResponseLine *ret = T::instance.trigger(parameters);
Jupiter::GenericCommand::ResponseLine *del;
Jupiter::GenericCommand::ResponseLine *ret = T::instance.trigger(parameters);
while (ret != nullptr)
{
ret->response.println(ret->type == GenericCommand::DisplayType::PublicError || ret->type == GenericCommand::DisplayType::PrivateError ? stderr : stdout);
ret->response.println(ret->type == Jupiter::GenericCommand::DisplayType::PublicError || ret->type == Jupiter::GenericCommand::DisplayType::PrivateError ? stderr : stdout);
del = ret;
ret = ret->next;
delete del;

63
Bot/Generic_Command.cpp

@ -1,63 +0,0 @@
/**
* Copyright (C) 2015 Jessica James.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#include "Generic_Command.h"
Jupiter::ArrayList<GenericCommand> _genericCommands;
Jupiter::ArrayList<GenericCommand> *genericCommands = &_genericCommands;
GenericCommand::GenericCommand()
{
_genericCommands.add(this);
}
GenericCommand::~GenericCommand()
{
size_t count = _genericCommands.size();
while (count != 0)
if (_genericCommands.get(--count) == this)
{
_genericCommands.remove(count);
break;
}
}
GenericCommand *getGenericCommand(const Jupiter::ReadableString &trigger)
{
size_t count = _genericCommands.size();
while (count != 0)
{
GenericCommand *cmd = _genericCommands.get(--count);
if (cmd->matches(trigger))
return cmd;
}
return nullptr;
}
GenericCommand::ResponseLine::ResponseLine(const Jupiter::ReadableString &response_, GenericCommand::DisplayType type_)
{
GenericCommand::ResponseLine::response = response_;
GenericCommand::ResponseLine::type = type_;
}
GenericCommand::ResponseLine *GenericCommand::ResponseLine::set(const Jupiter::ReadableString &response_, GenericCommand::DisplayType type_)
{
GenericCommand::ResponseLine::response = response_;
GenericCommand::ResponseLine::type = type_;
return this;
}

128
Bot/Generic_Command.h

@ -1,128 +0,0 @@
/**
* Copyright (C) 2015 Jessica James.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Written by Jessica James <jessica.aj@outlook.com>
*/
#if !defined _GENERIC_COMMAND_H_HEADER
#define _GENERIC_COMMAND_H_HEADER
/**
* @file Generic_Command.h
* @brief Provides an extendable command system.
*/
#include "Jupiter/Command.h"
#include "Jupiter/String.h"
#include "Jupiter_Bot.h"
class GenericCommand;
/** DLL Linkage Nagging */
#if defined _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
/** Generic command list */
JUPITER_BOT_API extern Jupiter::ArrayList<GenericCommand> *genericCommands;
/**
* @brief Provides the base for generic commands.
*/
class JUPITER_BOT_API GenericCommand : public Jupiter::Command
{
public:
/** Enumerated class to guide output in generic command interpreters */
enum class DisplayType
{
PublicSuccess,
PrivateSuccess,
PublicError,
PrivateError,
};
/** Data entry returned by trigger() */
struct JUPITER_BOT_API ResponseLine
{
Jupiter::StringS response;
GenericCommand::DisplayType type;
ResponseLine *next = nullptr;
/**
* @brief Sets the response and type of the ResponseLine.
*
* @param in_response Value to set response to.
* @param in_type Value to set type to.
* @return This.
*/
ResponseLine *set(const Jupiter::ReadableString &response, GenericCommand::DisplayType type);
ResponseLine() = default;
ResponseLine(const Jupiter::ReadableString &response, GenericCommand::DisplayType type);
};
/**
* @brief Called when the command is to be executed.
*
* @param input Parameters passed to the command by the user.
*/
virtual ResponseLine *trigger(const Jupiter::ReadableString &input) = 0;
/**
* @brief Default constructor for the generic command class.
*/
GenericCommand();
/**
* @brief Destructor for the generic command class.
*/
~GenericCommand();
};
/**
* @brief Fetches a generic command based on its trigger.
*
* @param trigger Trigger of the command to fetch.
* @return A generic command if it exists, nullptr otherwise.
*/
JUPITER_BOT_API extern GenericCommand *getGenericCommand(const Jupiter::ReadableString &trigger);
/** Generic Command Macros */
/** Defines the core of a generic command's declaration. This should be included in every generic command. */
#define BASE_GENERIC_COMMAND(CLASS) \
public: \
CLASS(); \
GenericCommand::ResponseLine *trigger(const Jupiter::ReadableString &parameters); \
const Jupiter::ReadableString &getHelp(const Jupiter::ReadableString &parameters); \
static CLASS instance;
/** Expands to become the entire declaration for a generic command. In most cases, this will be sufficient. */
#define GENERIC_GENERIC_COMMAND(CLASS) \
class CLASS : public GenericCommand { \
BASE_GENERIC_COMMAND(CLASS) \
};
/** Instantiates a generic command. */
#define GENERIC_COMMAND_INIT(CLASS) \
CLASS CLASS :: instance = CLASS (); \
CLASS & CLASS ## _instance = CLASS :: instance;
/** Re-enable warnings */
#if defined _MSC_VER
#pragma warning(pop)
#endif
#endif // _GENERIC_COMMAND_H_HEADER

86
Bot/IRC_Bot.cpp

@ -103,49 +103,67 @@ Jupiter::StringL IRC_Bot::getTriggers(Jupiter::ArrayList<IRCCommand> &cmds)
void IRC_Bot::setCommandAccessLevels()
{
// Rewrite this later
// Note: Prepare for abstraction of configuration file type.
Jupiter::StringS commandSection = "DefaultCommands";
checkForCommands:
int sIndex = Config->getSectionIndex(commandSection);
if (sIndex >= 0)
auto set_command_access_levels = [this](const Jupiter::ReadableString &section_name)
{
int sLen = Config->getSectionLength(sIndex);
for (int i = 0; i < sLen; i++)
Jupiter::INIFile::Section *section = this->Config->getSection(section_name);
if (section != nullptr)
{
const Jupiter::ReadableString &key = Config->getKey(commandSection, i);
int pos = key.find('.');
if (pos != Jupiter::INVALID_INDEX)
size_t section_length = section->size();
Jupiter::INIFile::Section::KeyValuePair *pair;
size_t tmp_index;
Jupiter::ReferenceString tmp_key, tmp_sub_key;
IRCCommand *command;
for (size_t pair_index = 0; pair_index != section_length; ++pair_index)
{
Jupiter::ReferenceString command = Jupiter::ReferenceString(key.ptr(), pos);
if (command != nullptr)
pair = section->getPair(pair_index);
tmp_index = pair->getKey().find('.');
if (tmp_index != Jupiter::INVALID_INDEX)
{
IRCCommand *cmd = IRC_Bot::getCommand(command);
if (cmd != nullptr)
// non-default access assignment
tmp_key.set(pair->getKey().ptr(), tmp_index);
tmp_sub_key = pair->getKey();
tmp_sub_key.shiftRight(tmp_index + 1);
if (tmp_sub_key.findi("Type."_jrs) == 0)
{
tmp_sub_key.shiftRight(5); // shift beyond "Type."
command = this->getCommand(tmp_key);
if (command != nullptr)
command->setAccessLevel(tmp_sub_key.asInt(), pair->getValue().asInt());
}
else if (tmp_sub_key.findi("Channel."_jrs) == 0)
{
Jupiter::ReferenceString channelType(key.ptr() + pos + 1, key.size() - pos - 1);
if (isdigit(key[pos + 1]))
cmd->setAccessLevel(channelType.asInt(10), Config->getInt(commandSection, key));
else cmd->setAccessLevel(channelType.asInt(10), Config->getInt(commandSection, key));
tmp_sub_key.shiftRight(8); // shift beyond "Channel."
// Assign access level to command (if command exists)
command = this->getCommand(tmp_key);
if (command != nullptr)
command->setAccessLevel(tmp_sub_key, pair->getValue().asInt());
else if (this->getPrintOutput() != nullptr)
fprintf(this->getPrintOutput(), "Unable to find command \"%.*s\"" ENDL, tmp_key.size(), tmp_key.ptr());
}
else if (this->getPrintOutput()) printf("Unable to find command \"%.*s\"" ENDL, key.size(), key.ptr());
}
}
else
{
IRCCommand *cmd = IRC_Bot::getCommand(key);
if (cmd != nullptr) cmd->setAccessLevel(Config->getInt(commandSection, key));
else if (this->getPrintOutput()) printf("Unable to find command \"%.*s\"" ENDL, key.size(), key.ptr());
else
{
// Assign access level to command (if command exists)
command = this->getCommand(pair->getKey());
if (command != nullptr)
command->setAccessLevel(pair->getValue().asInt());
else if (this->getPrintOutput() != nullptr)
fprintf(this->getPrintOutput(), "Unable to find command \"%.*s\"" ENDL, pair->getKey().size(), pair->getKey().ptr());
}
}
}
}
if (commandSection.equals("DefaultCommands"))
{
commandSection = this->getConfigSection();
commandSection += "Commands";
if (commandSection.equals("DefaultCommands") == false) goto checkForCommands;
}
};
set_command_access_levels("DefaultCommands"_jrs);
set_command_access_levels(this->getConfigSection() + "Commands"_jrs);
}
int IRC_Bot::OnRehash()

15
Bot/IRC_Command.h

@ -24,14 +24,13 @@
* @brief Provides an extendable command system specialized for IRC chat-based commands.
*/
#include "Jupiter/Command.h"
#include "Jupiter/GenericCommand.h"
#include "Jupiter/IRC_Client.h"
#include "Jupiter/ArrayList.h"
#include "Jupiter/String.h"
#include "Jupiter_Bot.h"
#include "ServerManager.h"
#include "IRC_Bot.h"
#include "Generic_Command.h"
class IRCCommand;
@ -218,18 +217,18 @@ template<typename T> Generic_Command_As_IRC_Command<T>::Generic_Command_As_IRC_C
template<typename T> void Generic_Command_As_IRC_Command<T>::trigger(IRC_Bot *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &parameters)
{
GenericCommand::ResponseLine *del;
GenericCommand::ResponseLine *ret = T::instance.trigger(parameters);
Jupiter::GenericCommand::ResponseLine *del;
Jupiter::GenericCommand::ResponseLine *ret = T::instance.trigger(parameters);
while (ret != nullptr)
{
switch (ret->type)
{
case GenericCommand::DisplayType::PublicSuccess:
case GenericCommand::DisplayType::PublicError:
case Jupiter::GenericCommand::DisplayType::PublicSuccess:
case Jupiter::GenericCommand::DisplayType::PublicError:
source->sendMessage(channel, ret->response);
break;
case GenericCommand::DisplayType::PrivateSuccess:
case GenericCommand::DisplayType::PrivateError:
case Jupiter::GenericCommand::DisplayType::PrivateSuccess:
case Jupiter::GenericCommand::DisplayType::PrivateError:
source->sendNotice(nick, ret->response);
break;
default:

12
CoreCommands/CoreCommands.cpp

@ -131,10 +131,10 @@ VersionGenericCommand::VersionGenericCommand()
this->addTrigger(STRING_LITERAL_AS_REFERENCE("clientinfo"));
}
GenericCommand::ResponseLine *VersionGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *VersionGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
GenericCommand::ResponseLine *ret = new GenericCommand::ResponseLine("Version: "_jrs + Jupiter::ReferenceString(Jupiter::version), GenericCommand::DisplayType::PublicSuccess);
ret->next = new GenericCommand::ResponseLine(Jupiter::ReferenceString(Jupiter::copyright), GenericCommand::DisplayType::PublicSuccess);
Jupiter::GenericCommand::ResponseLine *ret = new Jupiter::GenericCommand::ResponseLine("Version: "_jrs + Jupiter::ReferenceString(Jupiter::version), GenericCommand::DisplayType::PublicSuccess);
ret->next = new Jupiter::GenericCommand::ResponseLine(Jupiter::ReferenceString(Jupiter::copyright), GenericCommand::DisplayType::PublicSuccess);
return ret;
}
@ -155,14 +155,14 @@ RehashGenericCommand::RehashGenericCommand()
this->addTrigger(STRING_LITERAL_AS_REFERENCE("rehash"));
}
GenericCommand::ResponseLine *RehashGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *RehashGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
unsigned int r = Jupiter::rehash();
if (r == 0)
return new GenericCommand::ResponseLine(Jupiter::StringS::Format("All %u objects were successfully rehashed.", Jupiter::getRehashableCount()), GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine(Jupiter::StringS::Format("All %u objects were successfully rehashed.", Jupiter::getRehashableCount()), GenericCommand::DisplayType::PublicSuccess);
return new GenericCommand::ResponseLine(Jupiter::StringS::Format("%u of %u objects failed to successfully rehash.", r, Jupiter::getRehashableCount()), GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine(Jupiter::StringS::Format("%u of %u objects failed to successfully rehash.", r, Jupiter::getRehashableCount()), GenericCommand::DisplayType::PublicError);
}
const Jupiter::ReadableString &RehashGenericCommand::getHelp(const Jupiter::ReadableString &)

82
ExtraCommands/ExtraCommands.cpp

@ -31,24 +31,24 @@ SelectGenericCommand::SelectGenericCommand()
this->addTrigger("ircselect"_jrs);
}
GenericCommand::ResponseLine *SelectGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *SelectGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
if (parameters.isEmpty())
{
if (IRCCommand::selected_server == nullptr)
return new GenericCommand::ResponseLine("No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new GenericCommand::ResponseLine(IRCCommand::selected_server->getConfigSection() + " is currently selected."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine("No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine(IRCCommand::selected_server->getConfigSection() + " is currently selected."_jrs, GenericCommand::DisplayType::PublicSuccess);
}
if (IRCCommand::active_server == IRCCommand::selected_server)
IRCCommand::active_server = nullptr;
IRCCommand::selected_server = serverManager->getServer(parameters);
if (IRCCommand::selected_server == nullptr)
return new GenericCommand::ResponseLine("Error: IRC server \""_jrs + parameters + "\" not found. No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine("Error: IRC server \""_jrs + parameters + "\" not found. No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
if (IRCCommand::active_server == nullptr)
IRCCommand::active_server = IRCCommand::selected_server;
return new GenericCommand::ResponseLine(IRCCommand::selected_server->getConfigSection() + " is now selected."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine(IRCCommand::selected_server->getConfigSection() + " is now selected."_jrs, GenericCommand::DisplayType::PublicSuccess);
}
const Jupiter::ReadableString &SelectGenericCommand::getHelp(const Jupiter::ReadableString &)
@ -73,12 +73,12 @@ DeselectGenericCommand::DeselectGenericCommand()
this->addTrigger("ircunselect"_jrs);
}
GenericCommand::ResponseLine *DeselectGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *DeselectGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
if (IRCCommand::selected_server == nullptr)
return new GenericCommand::ResponseLine("No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine("No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicSuccess);
GenericCommand::ResponseLine *ret = new GenericCommand::ResponseLine(IRCCommand::selected_server->getConfigSection() + " has been deselected."_jrs, GenericCommand::DisplayType::PublicSuccess);
Jupiter::GenericCommand::ResponseLine *ret = new Jupiter::GenericCommand::ResponseLine(IRCCommand::selected_server->getConfigSection() + " has been deselected."_jrs, GenericCommand::DisplayType::PublicSuccess);
IRCCommand::selected_server = nullptr;
IRCCommand::active_server = IRCCommand::selected_server;
return ret;
@ -102,7 +102,7 @@ RawGenericCommand::RawGenericCommand()
this->addTrigger("sendraw"_jrs);
}
GenericCommand::ResponseLine *RawGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *RawGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
IRC_Bot *server;
if (IRCCommand::selected_server != nullptr)
@ -110,13 +110,13 @@ GenericCommand::ResponseLine *RawGenericCommand::trigger(const Jupiter::Readable
else if (IRCCommand::active_server != nullptr)
server = IRCCommand::active_server;
else
return new GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
if (parameters.isEmpty())
return new GenericCommand::ResponseLine("Error: Too few parameters. Syntax: raw <message>"_jrs, GenericCommand::DisplayType::PrivateError);
return new Jupiter::GenericCommand::ResponseLine("Error: Too few parameters. Syntax: raw <message>"_jrs, GenericCommand::DisplayType::PrivateError);
server->send(parameters);
return new GenericCommand::ResponseLine("Data has been successfully sent to server."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine("Data has been successfully sent to server."_jrs, GenericCommand::DisplayType::PublicSuccess);
}
const Jupiter::ReadableString &RawGenericCommand::getHelp(const Jupiter::ReadableString &)
@ -138,7 +138,7 @@ IRCMessageGenericCommand::IRCMessageGenericCommand()
this->addTrigger("privmsg"_jrs);
}
GenericCommand::ResponseLine *IRCMessageGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *IRCMessageGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
IRC_Bot *server;
if (IRCCommand::selected_server != nullptr)
@ -146,13 +146,13 @@ GenericCommand::ResponseLine *IRCMessageGenericCommand::trigger(const Jupiter::R
else if (IRCCommand::active_server != nullptr)
server = IRCCommand::active_server;
else
return new GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
if (parameters.wordCount(WHITESPACE) < 3)
return new GenericCommand::ResponseLine("Error: Too few parameters. Syntax: ircmsg <destination> <message>"_jrs, GenericCommand::DisplayType::PrivateError);
return new Jupiter::GenericCommand::ResponseLine("Error: Too few parameters. Syntax: ircmsg <destination> <message>"_jrs, GenericCommand::DisplayType::PrivateError);
server->sendMessage(Jupiter::ReferenceString::getWord(parameters, 0, WHITESPACE), Jupiter::ReferenceString::gotoWord(parameters, 1, WHITESPACE));
return new GenericCommand::ResponseLine("Message successfully sent."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine("Message successfully sent."_jrs, GenericCommand::DisplayType::PublicSuccess);
}
const Jupiter::ReadableString &IRCMessageGenericCommand::getHelp(const Jupiter::ReadableString &)
@ -172,7 +172,7 @@ JoinGenericCommand::JoinGenericCommand()
this->addTrigger("Join"_jrs);
}
GenericCommand::ResponseLine *JoinGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *JoinGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
IRC_Bot *server;
if (IRCCommand::selected_server != nullptr)
@ -180,17 +180,17 @@ GenericCommand::ResponseLine *JoinGenericCommand::trigger(const Jupiter::Readabl
else if (IRCCommand::active_server != nullptr)
server = IRCCommand::active_server;
else
return new GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
if (parameters.isEmpty())
return new GenericCommand::ResponseLine("Error: Too Few Parameters. Syntax: join <channel> [password]"_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine("Error: Too Few Parameters. Syntax: join <channel> [password]"_jrs, GenericCommand::DisplayType::PublicError);
if (parameters.wordCount(WHITESPACE) == 1)
server->joinChannel(parameters);
else
server->joinChannel(Jupiter::ReferenceString::getWord(parameters, 0, WHITESPACE), Jupiter::ReferenceString::gotoWord(parameters, 1, WHITESPACE));
return new GenericCommand::ResponseLine("Request to join channel has been sent."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine("Request to join channel has been sent."_jrs, GenericCommand::DisplayType::PublicSuccess);
}
const Jupiter::ReadableString &JoinGenericCommand::getHelp(const Jupiter::ReadableString &)
@ -210,7 +210,7 @@ PartGenericCommand::PartGenericCommand()
this->addTrigger("Part"_jrs);
}
GenericCommand::ResponseLine *PartGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *PartGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
IRC_Bot *server;
if (IRCCommand::selected_server != nullptr)
@ -218,17 +218,17 @@ GenericCommand::ResponseLine *PartGenericCommand::trigger(const Jupiter::Readabl
else if (IRCCommand::active_server != nullptr)
server = IRCCommand::active_server;
else
return new GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
if (parameters.isEmpty())
return new GenericCommand::ResponseLine("Error: Too few parameters. Syntax: part <channel> [message]"_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine("Error: Too few parameters. Syntax: part <channel> [message]"_jrs, GenericCommand::DisplayType::PublicError);
if (parameters.wordCount(WHITESPACE) == 1)
server->partChannel(parameters);
else
server->partChannel(Jupiter::ReferenceString::getWord(parameters, 0, WHITESPACE), Jupiter::ReferenceString::gotoWord(parameters, 1, WHITESPACE));
return new GenericCommand::ResponseLine("Part command successfuly sent."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine("Part command successfuly sent."_jrs, GenericCommand::DisplayType::PublicSuccess);
}
const Jupiter::ReadableString &PartGenericCommand::getHelp(const Jupiter::ReadableString &)
@ -248,7 +248,7 @@ DebugInfoGenericCommand::DebugInfoGenericCommand()
this->addTrigger("debuginfo"_jrs);
}
GenericCommand::ResponseLine *DebugInfoGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *DebugInfoGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
IRC_Bot *server;
if (IRCCommand::selected_server != nullptr)
@ -256,26 +256,26 @@ GenericCommand::ResponseLine *DebugInfoGenericCommand::trigger(const Jupiter::Re
else if (IRCCommand::active_server != nullptr)
server = IRCCommand::active_server;
else
return new GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
Jupiter::IRC::Client::Channel *chan;
Jupiter::IRC::Client::User *user;
GenericCommand::ResponseLine *ret = new GenericCommand::ResponseLine("Prefixes: "_jrs + server->getPrefixes(), GenericCommand::DisplayType::PublicSuccess);
GenericCommand::ResponseLine *line = new GenericCommand::ResponseLine("Prefix Modes: "_jrs + server->getPrefixModes(), GenericCommand::DisplayType::PublicSuccess);
Jupiter::GenericCommand::ResponseLine *ret = new Jupiter::GenericCommand::ResponseLine("Prefixes: "_jrs + server->getPrefixes(), GenericCommand::DisplayType::PublicSuccess);
Jupiter::GenericCommand::ResponseLine *line = new Jupiter::GenericCommand::ResponseLine("Prefix Modes: "_jrs + server->getPrefixModes(), GenericCommand::DisplayType::PublicSuccess);
ret->next = line;
line->next = new GenericCommand::ResponseLine(Jupiter::StringS::Format("Outputting data for %u channels...", server->getChannelCount()), GenericCommand::DisplayType::PublicSuccess);
line->next = new Jupiter::GenericCommand::ResponseLine(Jupiter::StringS::Format("Outputting data for %u channels...", server->getChannelCount()), GenericCommand::DisplayType::PublicSuccess);
line = line->next;
for (unsigned int index = 0; index < server->getChannelCount(); ++index)
{
chan = server->getChannel(index);
if (chan != nullptr)
{
line->next = new GenericCommand::ResponseLine(Jupiter::StringS::Format("Channel %.*s - Type: %d", chan->getName().size(), chan->getName().ptr(), chan->getType()), GenericCommand::DisplayType::PublicSuccess);
line->next = new Jupiter::GenericCommand::ResponseLine(Jupiter::StringS::Format("Channel %.*s - Type: %d", chan->getName().size(), chan->getName().ptr(), chan->getType()), GenericCommand::DisplayType::PublicSuccess);
line = line->next;
for (unsigned int j = 0; j != chan->getUserCount(); ++j)
{
user = chan->getUser(j)->getUser();
line->next = new GenericCommand::ResponseLine(Jupiter::StringS::Format("User %.*s!%.*s@%.*s (prefix: %c) of channel %.*s (of %u shared)", user->getNickname().size(), user->getNickname().ptr(), user->getUsername().size(), user->getUsername().ptr(), user->getHostname().size(), user->getHostname().ptr(), chan->getUserPrefix(j) ? chan->getUserPrefix(j) : ' ', chan->getName().size(), chan->getName().ptr(), user->getChannelCount()), GenericCommand::DisplayType::PublicSuccess);
line->next = new Jupiter::GenericCommand::ResponseLine(Jupiter::StringS::Format("User %.*s!%.*s@%.*s (prefix: %c) of channel %.*s (of %u shared)", user->getNickname().size(), user->getNickname().ptr(), user->getUsername().size(), user->getUsername().ptr(), user->getHostname().size(), user->getHostname().ptr(), chan->getUserPrefix(j) ? chan->getUserPrefix(j) : ' ', chan->getName().size(), chan->getName().ptr(), user->getChannelCount()), GenericCommand::DisplayType::PublicSuccess);
line = line->next;
}
}
@ -300,7 +300,7 @@ ExitGenericCommand::ExitGenericCommand()
this->addTrigger("exit"_jrs);
}
GenericCommand::ResponseLine *ExitGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *ExitGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
exit(0);
}
@ -323,7 +323,7 @@ IRCConnectGenericCommand::IRCConnectGenericCommand()
this->addTrigger("IRCReconnect"_jrs);
}
GenericCommand::ResponseLine *IRCConnectGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *IRCConnectGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
if (parameters.isEmpty())
{
@ -333,20 +333,20 @@ GenericCommand::ResponseLine *IRCConnectGenericCommand::trigger(const Jupiter::R
else if (IRCCommand::active_server != nullptr)
server = IRCCommand::active_server;
else
return new GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
server->disconnect("Connect command used; reconnecting..."_jrs, false);
return new GenericCommand::ResponseLine("Disconnected from IRC server."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine("Disconnected from IRC server."_jrs, GenericCommand::DisplayType::PublicSuccess);
}
IRC_Bot *server = serverManager->getServer(parameters);
if (server != nullptr)
{
server->disconnect("Connect command used; reconnecting..."_jrs, false);
return new GenericCommand::ResponseLine("Disconnected from IRC server."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine("Disconnected from IRC server."_jrs, GenericCommand::DisplayType::PublicSuccess);
}
if (serverManager->addServer(parameters))
return new GenericCommand::ResponseLine("Connection successfully established; server added to server list."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new GenericCommand::ResponseLine("Error: Unable to find configuration settings for server, or connection refused."_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine("Connection successfully established; server added to server list."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine("Error: Unable to find configuration settings for server, or connection refused."_jrs, GenericCommand::DisplayType::PublicError);
}
const Jupiter::ReadableString &IRCConnectGenericCommand::getHelp(const Jupiter::ReadableString &)
@ -366,7 +366,7 @@ IRCDisconnectGenericCommand::IRCDisconnectGenericCommand()
this->addTrigger("IRCDisconnect"_jrs);
}
GenericCommand::ResponseLine *IRCDisconnectGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *IRCDisconnectGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
IRC_Bot *server;
if (IRCCommand::selected_server != nullptr)
@ -374,10 +374,10 @@ GenericCommand::ResponseLine *IRCDisconnectGenericCommand::trigger(const Jupiter
else if (IRCCommand::active_server != nullptr)
server = IRCCommand::active_server;
else
return new GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine("Error: No IRC server is currently selected."_jrs, GenericCommand::DisplayType::PublicError);
server->disconnect("Disconnect command used."_jrs, true);
return new GenericCommand::ResponseLine("Disconnected from server."_jrs, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine("Disconnected from server."_jrs, GenericCommand::DisplayType::PublicSuccess);
}
const Jupiter::ReadableString &IRCDisconnectGenericCommand::getHelp(const Jupiter::ReadableString &)

14
FunCommands/FunCommands.cpp

@ -157,29 +157,29 @@ ResolveGenericCommand::ResolveGenericCommand()
this->addTrigger("resolve"_jrs);
}
GenericCommand::ResponseLine *ResolveGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *ResolveGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
unsigned int count = parameters.wordCount(WHITESPACE);
if (count <= 1)
return new GenericCommand::ResponseLine("Error: Too few parameters. Syntax: resolve <hostname|ip> <address>"_jrs, GenericCommand::DisplayType::PrivateError);
return new Jupiter::GenericCommand::ResponseLine("Error: Too few parameters. Syntax: resolve <hostname|ip> <address>"_jrs, GenericCommand::DisplayType::PrivateError);
Jupiter::ReferenceString command = Jupiter::ReferenceString::getWord(parameters, 0, WHITESPACE);
if (command.equalsi("hostname"_jrs) || command.equalsi("host"_jrs))
{
Jupiter::ReferenceString resolved = Jupiter::Socket::resolveHostname(Jupiter::CStringS::gotoWord(parameters, 1, WHITESPACE).c_str(), 0);
if (resolved.isEmpty())
return new GenericCommand::ResponseLine("Error: Unable to resolve."_jrs, GenericCommand::DisplayType::PublicError);
return new GenericCommand::ResponseLine(resolved, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine("Error: Unable to resolve."_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine(resolved, GenericCommand::DisplayType::PublicSuccess);
}
else if (command.equalsi("ip"_jrs))
{
Jupiter::ReferenceString resolved = Jupiter::Socket::resolveAddress(Jupiter::CStringS::gotoWord(parameters, 1, WHITESPACE).c_str(), 0);
if (resolved.isEmpty())
return new GenericCommand::ResponseLine("Error: Unable to resolve."_jrs, GenericCommand::DisplayType::PublicError);
return new GenericCommand::ResponseLine(resolved, GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine("Error: Unable to resolve."_jrs, GenericCommand::DisplayType::PublicError);
return new Jupiter::GenericCommand::ResponseLine(resolved, GenericCommand::DisplayType::PublicSuccess);
}
return new GenericCommand::ResponseLine("Error: Invalid type. You can only resolve hostnames and IP addresses."_jrs, GenericCommand::DisplayType::PrivateError);
return new Jupiter::GenericCommand::ResponseLine("Error: Invalid type. You can only resolve hostnames and IP addresses."_jrs, GenericCommand::DisplayType::PrivateError);
}
const Jupiter::ReadableString &ResolveGenericCommand::getHelp(const Jupiter::ReadableString &parameters)

2
Jupiter

@ -1 +1 @@
Subproject commit 1b697ec73adfc406e4ad5244aae8d24978fa36d8
Subproject commit 427ddecf8d89d64fbe90cbcd8eba3aaa7931939a

8
PluginManager/PluginManager.cpp

@ -31,15 +31,15 @@ PluginGenericCommand::PluginGenericCommand()
this->addTrigger(STRING_LITERAL_AS_REFERENCE("modules"));
}
GenericCommand::ResponseLine *PluginGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *PluginGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
GenericCommand::ResponseLine *ret = new GenericCommand::ResponseLine();
Jupiter::GenericCommand::ResponseLine *ret = new Jupiter::GenericCommand::ResponseLine();
if (parameters.isEmpty() || parameters.matchi("list*"))
{
GenericCommand::ResponseLine *line = ret->set(Jupiter::String::Format("There are %u plugins loaded:", Jupiter::plugins->size()), GenericCommand::DisplayType::PublicSuccess);
Jupiter::GenericCommand::ResponseLine *line = ret->set(Jupiter::String::Format("There are %u plugins loaded:", Jupiter::plugins->size()), GenericCommand::DisplayType::PublicSuccess);
for (size_t i = 0; i != Jupiter::plugins->size(); i++)
{
line->next = new GenericCommand::ResponseLine(Jupiter::plugins->get(i)->getName(), GenericCommand::DisplayType::PublicSuccess);
line->next = new Jupiter::GenericCommand::ResponseLine(Jupiter::plugins->get(i)->getName(), GenericCommand::DisplayType::PublicSuccess);
line = line->next;
}
return ret;

2
PluginManager/PluginManager.h

@ -20,7 +20,7 @@
#define _PLUGINMANAGER_H_HEADER
#include "Jupiter/Plugin.h"
#include "Generic_Command.h"
#include "Jupiter/GenericCommand.h"
#include "Console_Command.h"
#include "IRC_Command.h"

BIN
Release/Bot.lib

Binary file not shown.

BIN
Release/Plugins/RenX.Core.lib

Binary file not shown.

24
RenX.Ladder/RenX_Ladder.cpp

@ -88,13 +88,13 @@ LadderGenericCommand::LadderGenericCommand()
this->addTrigger("rank"_jrs);
}
GenericCommand::ResponseLine *LadderGenericCommand::trigger(const Jupiter::ReadableString &parameters)
Jupiter::GenericCommand::ResponseLine *LadderGenericCommand::trigger(const Jupiter::ReadableString &parameters)
{
if (parameters.isEmpty())
return new GenericCommand::ResponseLine("Error: Too few parameters. Syntax: ladder <name | rank>"_jrs, GenericCommand::DisplayType::PrivateError);
return new Jupiter::GenericCommand::ResponseLine("Error: Too few parameters. Syntax: ladder <name | rank>"_jrs, GenericCommand::DisplayType::PrivateError);
if (RenX::default_ladder_database == nullptr)
return new GenericCommand::ResponseLine("Error: No default ladder database specified."_jrs, GenericCommand::DisplayType::PrivateError);
return new Jupiter::GenericCommand::ResponseLine("Error: No default ladder database specified."_jrs, GenericCommand::DisplayType::PrivateError);
RenX::LadderDatabase::Entry *entry;
size_t rank;
@ -102,27 +102,27 @@ GenericCommand::ResponseLine *LadderGenericCommand::trigger(const Jupiter::Reada
{
rank = parameters.asUnsignedInt(10);
if (rank == 0)
return new GenericCommand::ResponseLine("Error: Invalid parameters"_jrs, GenericCommand::DisplayType::PrivateError);
return new Jupiter::GenericCommand::ResponseLine("Error: Invalid parameters"_jrs, GenericCommand::DisplayType::PrivateError);
entry = RenX::default_ladder_database->getPlayerEntryByIndex(rank - 1);
if (entry == nullptr)
return new GenericCommand::ResponseLine("Error: Player not found"_jrs, GenericCommand::DisplayType::PrivateError);
return new Jupiter::GenericCommand::ResponseLine("Error: Player not found"_jrs, GenericCommand::DisplayType::PrivateError);
return new GenericCommand::ResponseLine(FormatLadderResponse(entry, rank), GenericCommand::DisplayType::PublicSuccess);
return new Jupiter::GenericCommand::ResponseLine(FormatLadderResponse(entry, rank), GenericCommand::DisplayType::PublicSuccess);
}
Jupiter::SLList<std::pair<RenX::LadderDatabase::Entry, size_t>> list = RenX::default_ladder_database->getPlayerEntriesAndIndexByPartName(parameters, pluginInstance.getMaxLadderCommandPartNameOutput());
if (list.size() == 0)
return new GenericCommand::ResponseLine("Error: Player not found"_jrs, GenericCommand::DisplayType::PrivateError);
return new Jupiter::GenericCommand::ResponseLine("Error: Player not found"_jrs, GenericCommand::DisplayType::PrivateError);
std::pair<RenX::LadderDatabase::Entry, size_t> *pair = list.remove(0);
GenericCommand::ResponseLine *response_head = new GenericCommand::ResponseLine(FormatLadderResponse(std::addressof(pair->first), pair->second + 1), GenericCommand::DisplayType::PrivateSuccess);
GenericCommand::ResponseLine *response_end = response_head;
Jupiter::GenericCommand::ResponseLine *response_head = new Jupiter::GenericCommand::ResponseLine(FormatLadderResponse(std::addressof(pair->first), pair->second + 1), GenericCommand::DisplayType::PrivateSuccess);
Jupiter::GenericCommand::ResponseLine *response_end = response_head;
delete pair;
while (list.size() != 0)
{
pair = list.remove(0);
response_end->next = new GenericCommand::ResponseLine(FormatLadderResponse(std::addressof(pair->first), pair->second + 1), GenericCommand::DisplayType::PrivateSuccess);
response_end->next = new Jupiter::GenericCommand::ResponseLine(FormatLadderResponse(std::addressof(pair->first), pair->second + 1), GenericCommand::DisplayType::PrivateSuccess);
response_end = response_end->next;
delete pair;
}
@ -169,8 +169,8 @@ void LadderGameCommand::trigger(RenX::Server *source, RenX::PlayerInfo *player,
}
else
{
GenericCommand::ResponseLine *response = LadderGenericCommand_instance.trigger(parameters);
GenericCommand::ResponseLine *ptr;
Jupiter::GenericCommand::ResponseLine *response = LadderGenericCommand_instance.trigger(parameters);
Jupiter::GenericCommand::ResponseLine *ptr;
while (response != nullptr)
{
source->sendMessage(player, response->response);

Loading…
Cancel
Save