From 8fbdfcdd7377d8089378d1e206b90a1c4a2152e1 Mon Sep 17 00:00:00 2001 From: JustinAJ Date: Fri, 17 Oct 2014 02:18:34 -0400 Subject: [PATCH] Added RenX.Greetings plugin --- Jupiter Bot.sln | 13 +++ Release/Bot.lib | Bin 19582 -> 19582 bytes Release/Plugins/RenX.Core.lib | Bin 56672 -> 56672 bytes RenX.Greetings/RenX.Greetings.vcxproj | 86 ++++++++++++++++ RenX.Greetings/RenX.Greetings.vcxproj.filters | 38 +++++++ RenX.Greetings/RenX_Greetings.cpp | 95 ++++++++++++++++++ RenX.Greetings/RenX_Greetings.h | 50 +++++++++ 7 files changed, 282 insertions(+) create mode 100644 RenX.Greetings/RenX.Greetings.vcxproj create mode 100644 RenX.Greetings/RenX.Greetings.vcxproj.filters create mode 100644 RenX.Greetings/RenX_Greetings.cpp create mode 100644 RenX.Greetings/RenX_Greetings.h diff --git a/Jupiter Bot.sln b/Jupiter Bot.sln index f5f799b..f1ee49e 100644 --- a/Jupiter Bot.sln +++ b/Jupiter Bot.sln @@ -82,6 +82,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenX.Announcements", "RenX. EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{844CF9EF-70F3-449D-ACF3-A70D3501A775}" + ProjectSection(SolutionItems) = preProject + RenX.Greetings\RenX.Greetings.vcxproj = RenX.Greetings\RenX.Greetings.vcxproj + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenX.Medals", "RenX.Medals\RenX.Medals.vcxproj", "{C295FFC2-8CE5-4387-B237-E4E1B1AB9987}" ProjectSection(ProjectDependencies) = postProject @@ -106,6 +109,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenX.DNS", "RenX.DNS\RenX.D {9103DF3D-8B4A-48E5-A6B3-CBE2554630E2} = {9103DF3D-8B4A-48E5-A6B3-CBE2554630E2} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RenX.Greetings", "RenX.Greetings\RenX.Greetings.vcxproj", "{8709993F-B08A-4156-BD93-581F297FE0A4}" + ProjectSection(ProjectDependencies) = postProject + {C188871B-5F32-4946-B301-24CA2EBB275D} = {C188871B-5F32-4946-B301-24CA2EBB275D} + {9103DF3D-8B4A-48E5-A6B3-CBE2554630E2} = {9103DF3D-8B4A-48E5-A6B3-CBE2554630E2} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -188,6 +197,10 @@ Global {812E9781-A9CB-43C6-8C40-87908D50B363}.Debug|Win32.Build.0 = Debug|Win32 {812E9781-A9CB-43C6-8C40-87908D50B363}.Release|Win32.ActiveCfg = Release|Win32 {812E9781-A9CB-43C6-8C40-87908D50B363}.Release|Win32.Build.0 = Release|Win32 + {8709993F-B08A-4156-BD93-581F297FE0A4}.Debug|Win32.ActiveCfg = Debug|Win32 + {8709993F-B08A-4156-BD93-581F297FE0A4}.Debug|Win32.Build.0 = Debug|Win32 + {8709993F-B08A-4156-BD93-581F297FE0A4}.Release|Win32.ActiveCfg = Release|Win32 + {8709993F-B08A-4156-BD93-581F297FE0A4}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Release/Bot.lib b/Release/Bot.lib index afa2c7622bfa301c3a06837727b8b7220ad1b8f8..ad75b33d5adef493d34a95c74e9bb5dbae8c0571 100644 GIT binary patch delta 1485 zcmZuxOH30{6rEB&B`A=TwxY;4fB`9VN~cUqnJI<-r~zY%F);x`j4_0uQ5T{MG#V2L zvGHy&#Dy!Dgn$bp8<)t2xYfky4wbmT4GYls=Jq~b6L;--=bU@)z35qT4>Cb|GS=ZJ)+<2$PM1kYWw_#xgPEOX*-sGt^PeeVP?TvB9_Q(=hI9pu?PtX?mO%p@k8O!0@@@ zsLT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E zU7(6HFK`?mdhd&Tzy4RS4f ziL4eQ?VjnMX=_0o-WLt>%r)$hK*GlRrS>ZC7tvu}dTSb46EQt}J9;!J(}QGFnuzS4 zrga)w{R;U)NV8!}Bub;3SMFS6Gk3sINS%zi#y3q*s~q?lSVkh2k>nnN1FvYSTLMV} zK6>kHZLS>HV7_Jk`Ej8nB?{_zK!vCN#Ph}T=6_wCH&yxO>#RHbMfpIR>^O=ndq@adYHg=XR3z5 zJImP7w|3h8AsDp{8#8gx`_R@Qw+(I%$~ghwZ5N17-wA|yoxF;4><@LS^X>=Z@5(Q~ zIT)3Oh=JCKzL%JghEMC`yUJ;mB@z`;VmbzT2ake7_qak4#HZ%}HMAkmkC`|3=P z?gSKvK)VpgKWbKA27J?#lNFtIlT#pUXqc({y6&fXhEU-7jv$Q_9}vkKSp;ZM6akJZcG2t`k52^@Q} fn`cS8WR`a8wpw#HRr;ViLh + + + + Debug + Win32 + + + Release + Win32 + + + + {8709993F-B08A-4156-BD93-581F297FE0A4} + PluginExample + RenX.Greetings + + + + Application + true + v120 + MultiByte + + + DynamicLibrary + false + v120 + true + Unicode + + + + + + + + + + + + + $(SolutionDir)$(Configuration)\Plugins\ + AllRules.ruleset + + + + Level3 + Disabled + true + + + true + + + + + Level3 + MaxSpeed + true + true + true + ../Bot;../Jupiter;../RenX.Core + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + true + true + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/RenX.Greetings/RenX.Greetings.vcxproj.filters b/RenX.Greetings/RenX.Greetings.vcxproj.filters new file mode 100644 index 0000000..2a35b21 --- /dev/null +++ b/RenX.Greetings/RenX.Greetings.vcxproj.filters @@ -0,0 +1,38 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Resource Files + + + Resource Files + + + Resource Files + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/RenX.Greetings/RenX_Greetings.cpp b/RenX.Greetings/RenX_Greetings.cpp new file mode 100644 index 0000000..baf9697 --- /dev/null +++ b/RenX.Greetings/RenX_Greetings.cpp @@ -0,0 +1,95 @@ +/** + * 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 + */ + +#include "RenX_Greetings.h" +#include "RenX_PlayerInfo.h" +#include "RenX_Server.h" +#include "Jupiter/IRC_Client.h" +#include "Jupiter/INIFile.h" + +void RenX_GreetingsPlugin::RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player) +{ + auto sendMessage = [&](const Jupiter::ReadableString &m) + { + Jupiter::String msg = m; + msg.replace(this->steamTag, server->formatSteamID(player)); + msg.replace(this->ipTag, player->ip); + msg.replace(this->uuidTag, player->uuid); + msg.replace(this->nameTag, player->name); + + if (this->sendPrivate) + server->sendMessage(player, msg); + else + server->sendMessage(msg); + }; + if (player->isBot == false) + { + switch (RenX_GreetingsPlugin::sendMode) + { + case 0: + RenX_GreetingsPlugin::lastLine = rand() % RenX_GreetingsPlugin::greetingsFile.getLineCount(); + sendMessage(RenX_GreetingsPlugin::greetingsFile.getLine(RenX_GreetingsPlugin::lastLine)); + break; + case 1: + if (++RenX_GreetingsPlugin::lastLine == RenX_GreetingsPlugin::greetingsFile.getLineCount()) + RenX_GreetingsPlugin::lastLine = 0; + sendMessage(RenX_GreetingsPlugin::greetingsFile.getLine(RenX_GreetingsPlugin::lastLine)); + break; + case 2: + for (RenX_GreetingsPlugin::lastLine = 0; RenX_GreetingsPlugin::lastLine != RenX_GreetingsPlugin::greetingsFile.getLineCount(); RenX_GreetingsPlugin::lastLine++) + sendMessage(RenX_GreetingsPlugin::greetingsFile.getLine(RenX_GreetingsPlugin::lastLine)); + break; + default: + return; + } + } +} + +int RenX_GreetingsPlugin::OnRehash() +{ + RenX_GreetingsPlugin::greetingsFile.unload(); + RenX_GreetingsPlugin::init(); + return 0; +} + +RenX_GreetingsPlugin::RenX_GreetingsPlugin() +{ + RenX_GreetingsPlugin::init(); +} + +void RenX_GreetingsPlugin::init() +{ + RenX_GreetingsPlugin::sendPrivate = Jupiter::IRC::Client::Config->getBool(RenX_GreetingsPlugin::name, STRING_LITERAL_AS_REFERENCE("SendPrivate"), true); + RenX_GreetingsPlugin::sendMode = Jupiter::IRC::Client::Config->getInt(RenX_GreetingsPlugin::name, STRING_LITERAL_AS_REFERENCE("SendMode"), 0); + RenX_GreetingsPlugin::greetingsFile.load(Jupiter::IRC::Client::Config->get(RenX_GreetingsPlugin::name, STRING_LITERAL_AS_REFERENCE("GreetingsFile"), STRING_LITERAL_AS_REFERENCE("RenX.Greetings.txt"))); + if (RenX_GreetingsPlugin::greetingsFile.getLineCount() == 0) + RenX_GreetingsPlugin::greetingsFile.addData(STRING_LITERAL_AS_REFERENCE("Please notify the server administrator to properly configure or disable server greetings.\r\n")); + RenX_GreetingsPlugin::lastLine = RenX_GreetingsPlugin::greetingsFile.getLineCount() - 1; + + RenX_GreetingsPlugin::nameTag = Jupiter::IRC::Client::Config->get(RenX_GreetingsPlugin::name, STRING_LITERAL_AS_REFERENCE("NameTag"), STRING_LITERAL_AS_REFERENCE("{NAME}")); + RenX_GreetingsPlugin::ipTag = Jupiter::IRC::Client::Config->get(RenX_GreetingsPlugin::name, STRING_LITERAL_AS_REFERENCE("IPTag"), STRING_LITERAL_AS_REFERENCE("{IP}")); + RenX_GreetingsPlugin::steamTag = Jupiter::IRC::Client::Config->get(RenX_GreetingsPlugin::name, STRING_LITERAL_AS_REFERENCE("SteamTag"), STRING_LITERAL_AS_REFERENCE("{STEAM}")); + RenX_GreetingsPlugin::uuidTag = Jupiter::IRC::Client::Config->get(RenX_GreetingsPlugin::name, STRING_LITERAL_AS_REFERENCE("UUIDTag"), STRING_LITERAL_AS_REFERENCE("{UUID}")); +} + +// Plugin instantiation and entry point. +RenX_GreetingsPlugin pluginInstance; + +extern "C" __declspec(dllexport) Jupiter::Plugin *getPlugin() +{ + return &pluginInstance; +} diff --git a/RenX.Greetings/RenX_Greetings.h b/RenX.Greetings/RenX_Greetings.h new file mode 100644 index 0000000..3012b96 --- /dev/null +++ b/RenX.Greetings/RenX_Greetings.h @@ -0,0 +1,50 @@ +/** + * 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 + */ + +#if !defined _RENX_GREETING_H_HEADER +#define _RENX_GREETING_H_HEADER + +#include "Jupiter/Plugin.h" +#include "Jupiter/Reference_String.h" +#include "Jupiter/File.h" +#include "Jupiter/String.h" +#include "RenX_Plugin.h" + +class RenX_GreetingsPlugin : public RenX::Plugin +{ +public: // RenX::Plugin + void RenX_OnJoin(RenX::Server *server, const RenX::PlayerInfo *player) override; + +public: // Jupiter::Plugin + int OnRehash() override; + const Jupiter::ReadableString &getName() override { return name; } + + RenX_GreetingsPlugin(); +private: + void init(); + bool sendPrivate; + unsigned int lastLine; + unsigned int sendMode = 0; /** 0 = Send greetings randomly, 1 = Send greetings sequentially, 2 = Send all greetings */ + Jupiter::File greetingsFile; + Jupiter::StringS nameTag; + Jupiter::StringS ipTag; + Jupiter::StringS steamTag; + Jupiter::StringS uuidTag; + STRING_LITERAL_AS_NAMED_REFERENCE(name, "RenX.Greetings"); +}; + +#endif // _RENX_GREETING_H_HEADER \ No newline at end of file