@ -22,6 +22,8 @@
# include "CoreCommands.h"
# include "CoreCommands.h"
# include "IRC_Bot.h"
# include "IRC_Bot.h"
using namespace Jupiter : : literals ;
// Help Console Command
// Help Console Command
HelpConsoleCommand : : HelpConsoleCommand ( )
HelpConsoleCommand : : HelpConsoleCommand ( )
@ -61,33 +63,7 @@ const Jupiter::ReadableString &HelpConsoleCommand::getHelp(const Jupiter::Readab
CONSOLE_COMMAND_INIT ( HelpConsoleCommand )
CONSOLE_COMMAND_INIT ( HelpConsoleCommand )
// Version Console Command
// Help IRC Command.
VersionConsoleCommand : : VersionConsoleCommand ( )
{
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " version " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " versioninfo " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " copyright " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " copyrightinfo " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " client " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " clientinfo " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " info " ) ) ;
}
void VersionConsoleCommand : : trigger ( const Jupiter : : ReadableString & parameters )
{
printf ( " Version: %s " ENDL " %s " ENDL , Jupiter : : version , Jupiter : : copyright ) ;
}
const Jupiter : : ReadableString & VersionConsoleCommand : : getHelp ( const Jupiter : : ReadableString & )
{
static STRING_LITERAL_AS_NAMED_REFERENCE ( defaultHelp , " Displays version and copyright information " ) ;
return defaultHelp ;
}
CONSOLE_COMMAND_INIT ( VersionConsoleCommand )
// Help Command.
void HelpIRCCommand : : create ( )
void HelpIRCCommand : : create ( )
{
{
@ -137,87 +113,97 @@ const Jupiter::ReadableString &HelpIRCCommand::getHelp(const Jupiter::ReadableSt
IRC_COMMAND_INIT ( HelpIRCCommand )
IRC_COMMAND_INIT ( HelpIRCCommand )
// Version IRC Command
// Version Command
void VersionIRCCommand : : create ( )
VersionGenericCommand : : VersionGenericCommand ( )
{
{
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " version " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " version " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " versioninfo " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " versioninfo " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " copyright " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " copyright " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " copyrightinfo " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " copyrightinfo " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " client " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " clientinfo " ) ) ;
}
}
void VersionIRCCommand : : trigger ( IRC_Bot * source , const Jupiter : : ReadableString & channel , const Jupiter : : ReadableString & nick , const Jupiter : : ReadableString & parameters )
GenericCommand : : ResponseLine * VersionGenericCommand : : trigger ( const Jupiter : : ReadableString & parameters )
{
{
source - > sendMessage ( channel , Jupiter : : StringS : : Format ( " Version: %s " , Jupiter : : version ) ) ;
GenericCommand : : ResponseLine * ret = new GenericCommand : : ResponseLine ( " Version: " _jrs + Jupiter : : ReferenceString ( Jupiter : : version ) , GenericCommand : : DisplayType : : PublicSuccess ) ;
source - > sendMessage ( channel , Jupiter : : ReferenceString ( Jupiter : : copyright ) ) ;
ret - > next = new GenericCommand : : ResponseLine ( Jupiter : : ReferenceString ( Jupiter : : copyright ) , GenericCommand : : DisplayType : : PublicSuccess ) ;
return ret ;
}
}
const Jupiter : : ReadableString & VersionIRC Command : : getHelp ( const Jupiter : : ReadableString & )
const Jupiter : : ReadableString & VersionGeneric Command : : getHelp ( const Jupiter : : ReadableString & )
{
{
static STRING_LITERAL_AS_NAMED_REFERENCE ( defaultHelp , " Displays version and copyright information. Syntax: version " ) ;
static STRING_LITERAL_AS_NAMED_REFERENCE ( defaultHelp , " Displays version and copyright information " ) ;
return defaultHelp ;
return defaultHelp ;
}
}
IRC_COMMAND_INIT ( VersionIRCCommand )
GENERIC_COMMAND_INIT ( VersionGenericCommand )
GENERIC_COMMAND_AS_CONSOLE_COMMAND ( VersionGenericCommand )
GENERIC_COMMAND_AS_IRC_COMMAND ( VersionGenericCommand )
// Sync Command
// Sync Command
void SyncIRCCommand : : create ( )
SyncGenericCommand : : SyncGenericCommand ( )
{
{
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " sync " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " sync " ) ) ;
this - > setAccessLevel ( 4 ) ;
}
}
void SyncIRCCommand : : trigger ( IRC_Bot * source , const Jupiter : : ReadableString & channel , const Jupiter : : ReadableString & nick , const Jupiter : : ReadableString & parameters )
GenericCommand : : ResponseLine * SyncGenericCommand : : trigger ( const Jupiter : : ReadableString & parameters )
{
{
if ( source - > Config = = nullptr ) source - > sendMessage ( channel , STRING_LITERAL_AS_REFERENCE ( " Unable to find Config data. " ) ) ;
if ( Jupiter : : IRC : : Client : : Config = = nullptr )
return new GenericCommand : : ResponseLine ( STRING_LITERAL_AS_REFERENCE ( " Unable to find Config data. " ) , GenericCommand : : DisplayType : : PublicError ) ;
else
else
{
{
bool r ;
bool r ;
if ( parameters . isNotEmpty ( ) )
if ( parameters . isNotEmpty ( ) )
r = source - > Config - > sync ( parameters ) ;
r = Jupiter : : IRC : : Client : : Config - > sync ( parameters ) ;
else r = source - > Config - > sync ( ) ;
else r = Jupiter : : IRC : : Client : : Config - > sync ( ) ;
if ( r ) source - > sendMessage ( channel , STRING_LITERAL_AS_REFERENCE ( " Config data synced to file successfully. " ) ) ;
if ( r )
else source - > sendMessage ( channel , STRING_LITERAL_AS_REFERENCE ( " Unable to sync Config data. " ) ) ;
return new GenericCommand : : ResponseLine ( STRING_LITERAL_AS_REFERENCE ( " Config data synced to file successfully. " ) , GenericCommand : : DisplayType : : PublicSuccess ) ;
return new GenericCommand : : ResponseLine ( STRING_LITERAL_AS_REFERENCE ( " Unable to sync Config data. " ) , GenericCommand : : DisplayType : : PublicError ) ;
}
}
}
}
const Jupiter : : ReadableString & SyncIRC Command : : getHelp ( const Jupiter : : ReadableString & )
const Jupiter : : ReadableString & SyncGeneric Command : : getHelp ( const Jupiter : : ReadableString & )
{
{
static STRING_LITERAL_AS_NAMED_REFERENCE ( defaultHelp , " Syncs the configuration data to a file. Syntax: sync [file] " ) ;
static STRING_LITERAL_AS_NAMED_REFERENCE ( defaultHelp , " Syncs the configuration data to a file. Syntax: sync [file] " ) ;
return defaultHelp ;
return defaultHelp ;
}
}
IRC_COMMAND_INIT ( SyncIRCCommand )
GENERIC_COMMAND_INIT ( SyncGenericCommand )
GENERIC_COMMAND_AS_CONSOLE_COMMAND ( SyncGenericCommand )
GENERIC_COMMAND_AS_IRC_COMMAND_2 ( SyncGenericCommand , 4 )
// Rehash Command
// Rehash Command
void RehashIRCCommand : : create ( )
RehashGenericCommand : : RehashGenericCommand ( )
{
{
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " rehash " ) ) ;
this - > addTrigger ( STRING_LITERAL_AS_REFERENCE ( " rehash " ) ) ;
this - > setAccessLevel ( 4 ) ;
}
}
void RehashIRCCommand : : trigger ( IRC_Bot * source , const Jupiter : : ReadableString & channel , const Jupiter : : ReadableString & nick , const Jupiter : : ReadableString & parameters )
GenericCommand : : ResponseLine * RehashGenericCommand : : trigger ( const Jupiter : : ReadableString & parameters )
{
{
if ( source - > Config = = nullptr ) source - > sendMessage ( channel , STRING_LITERAL_AS_REFERENCE ( " Unable to find Config data. " ) ) ;
if ( Jupiter : : IRC : : Client : : Config = = nullptr )
return new GenericCommand : : ResponseLine ( STRING_LITERAL_AS_REFERENCE ( " Unable to find Config data. " ) , GenericCommand : : DisplayType : : PublicError ) ;
else
else
{
{
unsigned int r = Jupiter : : rehash ( ) ;
unsigned int r = Jupiter : : rehash ( ) ;
if ( r = = 0 )
if ( r = = 0 )
source - > sendMessage ( channel , Jupiter : : StringS : : Format ( " All %u objects were successfully rehashed. " , Jupiter : : getRehashableCount ( ) ) ) ;
return new GenericCommand : : ResponseLine ( Jupiter : : StringS : : Format ( " All %u objects were successfully rehashed. " , Jupiter : : getRehashableCount ( ) ) , GenericCommand : : DisplayType : : PublicSuccess ) ;
else source - > sendMessage ( channel , Jupiter : : StringS : : Format ( " %u of %u objects failed to successfully rehash. " , r , Jupiter : : getRehashableCount ( ) ) ) ;
return new GenericCommand : : ResponseLine ( Jupiter : : StringS : : Format ( " %u of %u objects failed to successfully rehash. " , r , Jupiter : : getRehashableCount ( ) ) , GenericCommand : : DisplayType : : PublicError ) ;
}
}
}
}
const Jupiter : : ReadableString & RehashIRC Command : : getHelp ( const Jupiter : : ReadableString & )
const Jupiter : : ReadableString & RehashGeneric Command : : getHelp ( const Jupiter : : ReadableString & )
{
{
static STRING_LITERAL_AS_NAMED_REFERENCE ( defaultHelp , " Rehashes configuration data from a file. Syntax: rehash [file] " ) ;
static STRING_LITERAL_AS_NAMED_REFERENCE ( defaultHelp , " Rehashes configuration data from a file. Syntax: rehash [file] " ) ;
return defaultHelp ;
return defaultHelp ;
}
}
IRC_COMMAND_INIT ( RehashIRCCommand )
GENERIC_COMMAND_INIT ( RehashGenericCommand )
GENERIC_COMMAND_AS_CONSOLE_COMMAND ( RehashGenericCommand )
GENERIC_COMMAND_AS_IRC_COMMAND_2 ( RehashGenericCommand , 4 )
// Plugin instantiation and entry point.
// Plugin instantiation and entry point.
CoreCommandsPlugin pluginInstance ;
CoreCommandsPlugin pluginInstance ;