JustinAJ
10 years ago
5 changed files with 303 additions and 0 deletions
@ -0,0 +1,85 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup Label="ProjectConfigurations"> |
|||
<ProjectConfiguration Include="Debug|Win32"> |
|||
<Configuration>Debug</Configuration> |
|||
<Platform>Win32</Platform> |
|||
</ProjectConfiguration> |
|||
<ProjectConfiguration Include="Release|Win32"> |
|||
<Configuration>Release</Configuration> |
|||
<Platform>Win32</Platform> |
|||
</ProjectConfiguration> |
|||
</ItemGroup> |
|||
<PropertyGroup Label="Globals"> |
|||
<ProjectGuid>{672B3FC9-0B31-45B4-AAB6-669073F2D291}</ProjectGuid> |
|||
<RootNamespace>PluginExample</RootNamespace> |
|||
</PropertyGroup> |
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> |
|||
<ConfigurationType>Application</ConfigurationType> |
|||
<UseDebugLibraries>true</UseDebugLibraries> |
|||
<PlatformToolset>v120</PlatformToolset> |
|||
<CharacterSet>MultiByte</CharacterSet> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> |
|||
<ConfigurationType>DynamicLibrary</ConfigurationType> |
|||
<UseDebugLibraries>false</UseDebugLibraries> |
|||
<PlatformToolset>v120</PlatformToolset> |
|||
<WholeProgramOptimization>true</WholeProgramOptimization> |
|||
<CharacterSet>Unicode</CharacterSet> |
|||
</PropertyGroup> |
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
|||
<ImportGroup Label="ExtensionSettings"> |
|||
</ImportGroup> |
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
|||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
|||
</ImportGroup> |
|||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
|||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
|||
</ImportGroup> |
|||
<PropertyGroup Label="UserMacros" /> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
|||
<OutDir>$(SolutionDir)$(Configuration)\Plugins\</OutDir> |
|||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> |
|||
</PropertyGroup> |
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
|||
<ClCompile> |
|||
<WarningLevel>Level3</WarningLevel> |
|||
<Optimization>Disabled</Optimization> |
|||
<SDLCheck>true</SDLCheck> |
|||
</ClCompile> |
|||
<Link> |
|||
<GenerateDebugInformation>true</GenerateDebugInformation> |
|||
</Link> |
|||
</ItemDefinitionGroup> |
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
|||
<ClCompile> |
|||
<WarningLevel>Level3</WarningLevel> |
|||
<Optimization>MaxSpeed</Optimization> |
|||
<FunctionLevelLinking>true</FunctionLevelLinking> |
|||
<IntrinsicFunctions>true</IntrinsicFunctions> |
|||
<SDLCheck>true</SDLCheck> |
|||
<AdditionalIncludeDirectories>../Bot;../Jupiter;../RenX.Core</AdditionalIncludeDirectories> |
|||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
|||
</ClCompile> |
|||
<Link> |
|||
<GenerateDebugInformation>true</GenerateDebugInformation> |
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
|||
<OptimizeReferences>true</OptimizeReferences> |
|||
</Link> |
|||
</ItemDefinitionGroup> |
|||
<ItemGroup> |
|||
<ClInclude Include="RenX_IRCJoin.h" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ClCompile Include="RenX_IRCJoin.cpp" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Library Include="..\Jupiter\Release\Jupiter.lib" /> |
|||
<Library Include="..\Release\Bot.lib" /> |
|||
<Library Include="..\Release\Plugins\RenX.Core.lib" /> |
|||
</ItemGroup> |
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
|||
<ImportGroup Label="ExtensionTargets"> |
|||
</ImportGroup> |
|||
</Project> |
@ -0,0 +1,38 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<Filter Include="Source Files"> |
|||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> |
|||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> |
|||
</Filter> |
|||
<Filter Include="Header Files"> |
|||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> |
|||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> |
|||
</Filter> |
|||
<Filter Include="Resource Files"> |
|||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> |
|||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> |
|||
</Filter> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Library Include="..\Release\Plugins\RenX.Core.lib"> |
|||
<Filter>Resource Files</Filter> |
|||
</Library> |
|||
<Library Include="..\Release\Bot.lib"> |
|||
<Filter>Resource Files</Filter> |
|||
</Library> |
|||
<Library Include="..\Jupiter\Release\Jupiter.lib"> |
|||
<Filter>Resource Files</Filter> |
|||
</Library> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ClInclude Include="RenX_IRCJoin.h"> |
|||
<Filter>Header Files</Filter> |
|||
</ClInclude> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ClCompile Include="RenX_IRCJoin.cpp"> |
|||
<Filter>Source Files</Filter> |
|||
</ClCompile> |
|||
</ItemGroup> |
|||
</Project> |
@ -0,0 +1,122 @@ |
|||
/**
|
|||
* Copyright (C) 2014 Justin James. |
|||
* |
|||
* This license must be preserved. |
|||
* Any applications, libraries, or code which make any use of any |
|||
* component of this program must not be commercial, unless explicit |
|||
* permission is granted from the original author. The use of this |
|||
* program for non-profit purposes is permitted. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|||
* |
|||
* In the event that this license restricts you from making desired use of this program, contact the original author. |
|||
* Written by Justin James <justin.aj@hotmail.com> |
|||
*/ |
|||
|
|||
#include "Jupiter/IRC_Client.h" |
|||
#include "Jupiter/INIFile.h" |
|||
#include "Jupiter/String.h" |
|||
#include "RenX_Core.h" |
|||
#include "RenX_Server.h" |
|||
#include "RenX_IRCJoin.h" |
|||
|
|||
void RenX_IRCJoinPlugin::init() |
|||
{ |
|||
RenX_IRCJoinPlugin::publicOnly = Jupiter::IRC::Client::Config->getBool(this->getName(), STRING_LITERAL_AS_REFERENCE("PublicOnly"), true); |
|||
RenX_IRCJoinPlugin::joinMsgAlways = Jupiter::IRC::Client::Config->getBool(this->getName(), STRING_LITERAL_AS_REFERENCE("Join.MsgAlways"), false); |
|||
RenX_IRCJoinPlugin::partMsgAlways = Jupiter::IRC::Client::Config->getBool(this->getName(), STRING_LITERAL_AS_REFERENCE("Part.MsgAlways"), false); |
|||
RenX_IRCJoinPlugin::minAccessJoinMessage = Jupiter::IRC::Client::Config->getInt(this->getName(), STRING_LITERAL_AS_REFERENCE("Join.MinAccess"), 0); |
|||
RenX_IRCJoinPlugin::maxAccessJoinMessage = Jupiter::IRC::Client::Config->getInt(this->getName(), STRING_LITERAL_AS_REFERENCE("Join.MaxAccess"), -1); |
|||
RenX_IRCJoinPlugin::minAccessPartMessage = Jupiter::IRC::Client::Config->getInt(this->getName(), STRING_LITERAL_AS_REFERENCE("Part.MinAccess"), 0); |
|||
RenX_IRCJoinPlugin::maxAccessPartMessage = Jupiter::IRC::Client::Config->getInt(this->getName(), STRING_LITERAL_AS_REFERENCE("Part.MaxAccess"), -1); |
|||
RenX_IRCJoinPlugin::nameTag = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("NameTag"), STRING_LITERAL_AS_REFERENCE("{NAME}")); |
|||
RenX_IRCJoinPlugin::chanTag = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("ChannelTag"), STRING_LITERAL_AS_REFERENCE("{CHAN}")); |
|||
RenX_IRCJoinPlugin::partReasonTag = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("PartReasonTag"), STRING_LITERAL_AS_REFERENCE("{REASON}")); |
|||
RenX_IRCJoinPlugin::joinFmt = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("Join.Format"), STRING_LITERAL_AS_REFERENCE("{NAME} has joined {CHAN}!")); |
|||
RenX_IRCJoinPlugin::partFmt = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("Part.Format"), STRING_LITERAL_AS_REFERENCE("{NAME} has left {CHAN} ({REASON})!")); |
|||
RenX_IRCJoinPlugin::partFmtNoReason = Jupiter::IRC::Client::Config->get(this->getName(), STRING_LITERAL_AS_REFERENCE("Part.FormatNoReason"), STRING_LITERAL_AS_REFERENCE("{NAME} has left {CHAN}!")); |
|||
} |
|||
|
|||
void RenX_IRCJoinPlugin::OnJoin(Jupiter::IRC::Client *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick) |
|||
{ |
|||
int access = source->getAccessLevel(channel, nick); |
|||
|
|||
if (access >= RenX_IRCJoinPlugin::minAccessJoinMessage && (RenX_IRCJoinPlugin::maxAccessJoinMessage == -1 || access <= RenX_IRCJoinPlugin::maxAccessJoinMessage)) |
|||
{ |
|||
RenX::Server *server; |
|||
int type = source->getChannel(channel)->getType(); |
|||
|
|||
Jupiter::String msg = RenX_IRCJoinPlugin::joinFmt; |
|||
msg.replace(RenX_IRCJoinPlugin::nameTag, nick); |
|||
msg.replace(RenX_IRCJoinPlugin::chanTag, channel); |
|||
|
|||
auto checkType = [&] |
|||
{ |
|||
if (this->publicOnly) |
|||
return server->isPublicLogChanType(type); |
|||
else |
|||
return server->isLogChanType(type); |
|||
}; |
|||
for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++) |
|||
{ |
|||
server = RenX::getCore()->getServer(i); |
|||
if (checkType() && (RenX_IRCJoinPlugin::joinMsgAlways || server->players.size() != 0)) |
|||
server->sendMessage(msg); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void RenX_IRCJoinPlugin::OnPart(Jupiter::IRC::Client *source, const Jupiter::ReadableString &channel, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &reason) |
|||
{ |
|||
int access = source->getAccessLevel(channel, nick); |
|||
|
|||
if (access >= RenX_IRCJoinPlugin::minAccessPartMessage && (RenX_IRCJoinPlugin::maxAccessPartMessage == -1 || access <= RenX_IRCJoinPlugin::maxAccessPartMessage)) |
|||
{ |
|||
RenX::Server *server; |
|||
int type = source->getChannel(channel)->getType(); |
|||
|
|||
Jupiter::String msg; |
|||
if (reason.isEmpty()) |
|||
msg = RenX_IRCJoinPlugin::partFmtNoReason; |
|||
else |
|||
msg = RenX_IRCJoinPlugin::partFmt; |
|||
msg.replace(RenX_IRCJoinPlugin::nameTag, nick); |
|||
msg.replace(RenX_IRCJoinPlugin::chanTag, channel); |
|||
msg.replace(RenX_IRCJoinPlugin::partReasonTag, reason); |
|||
|
|||
auto checkType = [&]() |
|||
{ |
|||
if (this->publicOnly) |
|||
return server->isPublicLogChanType(type); |
|||
else |
|||
return server->isLogChanType(type); |
|||
}; |
|||
for (unsigned int i = 0; i != RenX::getCore()->getServerCount(); i++) |
|||
{ |
|||
server = RenX::getCore()->getServer(i); |
|||
if (checkType() && (RenX_IRCJoinPlugin::partMsgAlways || server->players.size() != 0)) |
|||
server->sendMessage(msg); |
|||
} |
|||
} |
|||
} |
|||
|
|||
int RenX_IRCJoinPlugin::OnRehash() |
|||
{ |
|||
RenX_IRCJoinPlugin::init(); |
|||
return 0; |
|||
} |
|||
|
|||
RenX_IRCJoinPlugin::RenX_IRCJoinPlugin() |
|||
{ |
|||
RenX_IRCJoinPlugin::init(); |
|||
} |
|||
|
|||
// Plugin instantiation and entry point.
|
|||
RenX_IRCJoinPlugin pluginInstance; |
|||
|
|||
extern "C" __declspec(dllexport) Jupiter::Plugin *getPlugin() |
|||
{ |
|||
return &pluginInstance; |
|||
} |
@ -0,0 +1,52 @@ |
|||
/**
|
|||
* Copyright (C) 2014 Justin James. |
|||
* |
|||
* This license must be preserved. |
|||
* Any applications, libraries, or code which make any use of any |
|||
* component of this program must not be commercial, unless explicit |
|||
* permission is granted from the original author. The use of this |
|||
* program for non-profit purposes is permitted. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|||
* |
|||
* In the event that this license restricts you from making desired use of this program, contact the original author. |
|||
* Written by Justin James <justin.aj@hotmail.com> |
|||
*/ |
|||
|
|||
#if !defined _EXAMPLE_H_HEADER |
|||
#define _EXAMPLE_H_HEADER |
|||
|
|||
#include "Jupiter/Plugin.h" |
|||
#include "Jupiter/Reference_String.h" |
|||
#include "RenX_Plugin.h" |
|||
|
|||
class RenX_IRCJoinPlugin : public RenX::Plugin |
|||
{ |
|||
public: // Jupiter::Plugin
|
|||
void OnJoin(Jupiter::IRC::Client *source, const Jupiter::ReadableString &chan, const Jupiter::ReadableString &nick) override; |
|||
void OnPart(Jupiter::IRC::Client *source, const Jupiter::ReadableString &chan, const Jupiter::ReadableString &nick, const Jupiter::ReadableString &reason) override; |
|||
int OnRehash(); |
|||
RenX_IRCJoinPlugin(); |
|||
const Jupiter::ReadableString &getName() override { return name; } |
|||
|
|||
private: |
|||
void init(); |
|||
bool publicOnly; |
|||
bool joinMsgAlways; |
|||
bool partMsgAlways; |
|||
int minAccessJoinMessage; |
|||
int maxAccessJoinMessage; |
|||
int minAccessPartMessage; |
|||
int maxAccessPartMessage; |
|||
Jupiter::StringS nameTag; |
|||
Jupiter::StringS chanTag; |
|||
Jupiter::StringS partReasonTag; |
|||
Jupiter::StringS joinFmt; |
|||
Jupiter::StringS partFmt; |
|||
Jupiter::StringS partFmtNoReason; |
|||
STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.IRCJoin"); |
|||
}; |
|||
|
|||
#endif // _EXAMPLE_H_HEADER
|
Loading…
Reference in new issue