diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9a45441 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,16 @@ +* text=auto eol=lf + +# Configuration files +*.json text eol=crlf + +# Development files +CMakeLists.txt text eol=lf +*.cmake text eol=lf +*.cpp text eol=lf +*.h text eol=lf + +# BSD and Linux development files +*.pc.in text eol=lf + +# Windows development files +*.rc.in text encoding=cp1252 eol=crlf diff --git a/CMakeLists.txt b/CMakeLists.txt index b26ac46..3e17be0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,34 +17,34 @@ ****************************************************************************]] cmake_minimum_required(VERSION 3.16) -project(dtranslatebot VERSION 0.2 LANGUAGES CXX) +project(dtranslatebot VERSION 0.2.0 LANGUAGES CXX) include(GNUInstallDirs) # dtranslatebot Source files set(DTRANSLATEBOT_HEADERS - src/database_core.h - src/database_file.h - src/message_queue.h - src/regex.h - src/settings.h - src/settings_types.h - src/slashcommands.h - src/submit_queue.h - src/translator_core.h - src/translator_libretranslate.h - src/webhook_push.h + src/core/database.h + src/core/message_queue.h + src/core/regex.h + src/core/settings.h + src/core/settings_types.h + src/core/slashcommands.h + src/core/submit_queue.h + src/core/translator.h + src/core/webhook_push.h + src/database/file/file.h + src/translator/libretranslate/libretranslate.h ) set(DTRANSLATEBOT_SOURCES - src/database_core.cpp - src/database_file.cpp - src/main.cpp - src/message_queue.cpp - src/settings.cpp - src/slashcommands.cpp - src/submit_queue.cpp - src/translator_core.cpp - src/translator_libretranslate.cpp - src/webhook_push.cpp + src/core/database.cpp + src/core/main.cpp + src/core/message_queue.cpp + src/core/settings.cpp + src/core/slashcommands.cpp + src/core/submit_queue.cpp + src/core/translator.cpp + src/core/webhook_push.cpp + src/database/file/file.cpp + src/translator/libretranslate/libretranslate.cpp ) # dtranslatebot Module Path @@ -69,8 +69,16 @@ find_package(DPP REQUIRED) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) +# dtranslatebot Win32 Shared Resources +if (WIN32) + configure_file(src/resources/win32/dtranslatebot.rc.in "${dtranslatebot_BINARY_DIR}/resources/win32/dtranslatebot.rc" @ONLY) + list(APPEND DTRANSLATEBOT_RESOURCES + "${dtranslatebot_BINARY_DIR}/resources/win32/dtranslatebot.rc" + ) +endif() + # dtranslatebot Target + Installs -add_executable(dtranslatebot ${DTRANSLATEBOT_HEADERS} ${DTRANSLATEBOT_SOURCES}) +add_executable(dtranslatebot ${DTRANSLATEBOT_HEADERS} ${DTRANSLATEBOT_SOURCES} ${DTRANSLATEBOT_RESOURCES}) target_compile_definitions(dtranslatebot PRIVATE $<$:DTRANSLATEBOT_USE_BOOST_REGEX> ) diff --git a/etc/dtranslatebot.example.json b/etc/dtranslatebot.example.json deleted file mode 100644 index 202a0ee..0000000 --- a/etc/dtranslatebot.example.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "guilds": { - "$guild1_id": { - "$channel1_id": { - "source": "en", - "target": "de", - "webhook": "https://discord.com/api/webhooks/$guild1_de_webhook_id/$guild1_de_webhook_token" - }, - "$channel2_id": { - "source": "de", - "target": "en", - "webhook": "https://discord.com/api/webhooks/$guild1_en_webhook_id/$guild1_en_webhook_token" - } - }, - "My Discord Guild": { - "id": $guild2_id, - "General English": { - "id": $channel3_id, - "source": "en", - "target": { - "de": "https://discord.com/api/webhooks/$guild2_de_webhook_id/$guild2_de_webhook_token", - "fr": "https://discord.com/api/webhooks/$guild2_fr_webhook_id/$guild2_fr_webhook_token" - } - } - } - }, - "preferred_lang": ["en", "de", "fr", ...], - "storage": "$working_directory", - "user": { - "avatar_size": 256 - }, - "token": "$bot_token", - "translator": { - "url": "http://127.0.0.1:5000/", - "apiKey": "" - } -} diff --git a/etc/dtranslatebot.json b/etc/dtranslatebot.json deleted file mode 100644 index 28381db..0000000 --- a/etc/dtranslatebot.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "token": "", - "translator": { - "url": "http://127.0.0.1:5000/", - "apiKey": "" - } -} diff --git a/src/database_core.cpp b/src/core/database.cpp similarity index 99% rename from src/database_core.cpp rename to src/core/database.cpp index b540f36..f7fb12d 100644 --- a/src/database_core.cpp +++ b/src/core/database.cpp @@ -19,7 +19,7 @@ #ifndef NDEBUG #include #endif -#include "database_core.h" +#include "database.h" using namespace bot::database; database::database() diff --git a/src/database_core.h b/src/core/database.h similarity index 97% rename from src/database_core.h rename to src/core/database.h index 6526eda..04e8cf3 100644 --- a/src/database_core.h +++ b/src/core/database.h @@ -16,8 +16,8 @@ * responsible for anything with use of the software, you are self responsible. *****************************************************************************/ -#ifndef DATABASE_CORE_H -#define DATABASE_CORE_H +#ifndef DATABASE_H +#define DATABASE_H #include "settings_types.h" @@ -52,4 +52,4 @@ namespace bot { } } -#endif // DATABASE_CORE_H +#endif // DATABASE_H diff --git a/src/main.cpp b/src/core/main.cpp similarity index 100% rename from src/main.cpp rename to src/core/main.cpp diff --git a/src/message_queue.cpp b/src/core/message_queue.cpp similarity index 100% rename from src/message_queue.cpp rename to src/core/message_queue.cpp diff --git a/src/message_queue.h b/src/core/message_queue.h similarity index 100% rename from src/message_queue.h rename to src/core/message_queue.h diff --git a/src/regex.h b/src/core/regex.h similarity index 100% rename from src/regex.h rename to src/core/regex.h diff --git a/src/settings.cpp b/src/core/settings.cpp similarity index 99% rename from src/settings.cpp rename to src/core/settings.cpp index d8fb47d..d761ea4 100644 --- a/src/settings.cpp +++ b/src/core/settings.cpp @@ -19,9 +19,9 @@ #include #include #include -#include "database_file.h" #include "settings.h" -#include "translator_libretranslate.h" +#include "../database/file/file.h" +#include "../translator/libretranslate/libretranslate.h" using namespace bot::settings; void process_database_channels(std::shared_ptr database, bot::settings::guild *guild, std::vector *webhookIds) diff --git a/src/settings.h b/src/core/settings.h similarity index 98% rename from src/settings.h rename to src/core/settings.h index 31b71c3..d02db2a 100644 --- a/src/settings.h +++ b/src/core/settings.h @@ -19,9 +19,9 @@ #ifndef SETTINGS_H #define SETTINGS_H #include -#include "database_core.h" +#include "database.h" #include "settings_types.h" -#include "translator_core.h" +#include "translator.h" namespace bot { namespace settings { diff --git a/src/settings_types.h b/src/core/settings_types.h similarity index 100% rename from src/settings_types.h rename to src/core/settings_types.h diff --git a/src/slashcommands.cpp b/src/core/slashcommands.cpp similarity index 100% rename from src/slashcommands.cpp rename to src/core/slashcommands.cpp diff --git a/src/slashcommands.h b/src/core/slashcommands.h similarity index 100% rename from src/slashcommands.h rename to src/core/slashcommands.h diff --git a/src/submit_queue.cpp b/src/core/submit_queue.cpp similarity index 100% rename from src/submit_queue.cpp rename to src/core/submit_queue.cpp diff --git a/src/submit_queue.h b/src/core/submit_queue.h similarity index 100% rename from src/submit_queue.h rename to src/core/submit_queue.h diff --git a/src/translator_core.cpp b/src/core/translator.cpp similarity index 98% rename from src/translator_core.cpp rename to src/core/translator.cpp index d32d544..4d82d16 100644 --- a/src/translator_core.cpp +++ b/src/core/translator.cpp @@ -19,7 +19,7 @@ #ifndef NDEBUG #include #endif -#include "translator_core.h" +#include "translator.h" using namespace bot::translator; translator::translator() diff --git a/src/translator_core.h b/src/core/translator.h similarity index 94% rename from src/translator_core.h rename to src/core/translator.h index 33fbf0e..d42e21b 100644 --- a/src/translator_core.h +++ b/src/core/translator.h @@ -16,8 +16,8 @@ * responsible for anything with use of the software, you are self responsible. *****************************************************************************/ -#ifndef TRANSLATOR_CORE_H -#define TRANSLATOR_CORE_H +#ifndef TRANSLATOR_H +#define TRANSLATOR_H #include #include @@ -39,4 +39,4 @@ namespace bot { } } -#endif // TRANSLATOR_CORE_H +#endif // TRANSLATOR_H diff --git a/src/webhook_push.cpp b/src/core/webhook_push.cpp similarity index 100% rename from src/webhook_push.cpp rename to src/core/webhook_push.cpp diff --git a/src/webhook_push.h b/src/core/webhook_push.h similarity index 100% rename from src/webhook_push.h rename to src/core/webhook_push.h diff --git a/src/database_file.cpp b/src/database/file/file.cpp similarity index 99% rename from src/database_file.cpp rename to src/database/file/file.cpp index db5774b..31c4cfb 100644 --- a/src/database_file.cpp +++ b/src/database/file/file.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "database_file.h" +#include "file.h" using namespace bot::database; using namespace std::string_literals; diff --git a/src/database_file.h b/src/database/file/file.h similarity index 99% rename from src/database_file.h rename to src/database/file/file.h index 5947b3f..c743011 100644 --- a/src/database_file.h +++ b/src/database/file/file.h @@ -26,7 +26,7 @@ #define WIN32_LEAN_AND_MEAN #include #endif -#include "database_core.h" +#include "../../core/database.h" namespace bot { namespace database { diff --git a/src/resources/win32/dtranslatebot.rc.in b/src/resources/win32/dtranslatebot.rc.in new file mode 100644 index 0000000..a3e475d --- /dev/null +++ b/src/resources/win32/dtranslatebot.rc.in @@ -0,0 +1,29 @@ +#include +VS_VERSION_INFO VERSIONINFO +FILEVERSION @dtranslatebot_VERSION_MAJOR@, @dtranslatebot_VERSION_MINOR@, @dtranslatebot_VERSION_PATCH@, 0 +PRODUCTVERSION @dtranslatebot_VERSION_MAJOR@, @dtranslatebot_VERSION_MINOR@, @dtranslatebot_VERSION_PATCH@, 0 +FILEFLAGSMASK 0x3fL +FILEFLAGS 0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Syping" + VALUE "FileDescription", "Open Source Discord Translation Bot" + VALUE "FileVersion", "@dtranslatebot_VERSION@" + VALUE "InternalName", "dtranslatebot" + VALUE "LegalCopyright", "Copyright © 2023-2024 Syping" + VALUE "OriginalFilename", "dtranslatebot.exe" + VALUE "ProductName", "dtranslatebot" + VALUE "ProductVersion", "@dtranslatebot_VERSION@" + END + END +END diff --git a/src/translator_libretranslate.cpp b/src/translator/libretranslate/libretranslate.cpp similarity index 98% rename from src/translator_libretranslate.cpp rename to src/translator/libretranslate/libretranslate.cpp index 78a0026..7e5e9e7 100644 --- a/src/translator_libretranslate.cpp +++ b/src/translator/libretranslate/libretranslate.cpp @@ -18,7 +18,7 @@ #include #include -#include "translator_libretranslate.h" +#include "libretranslate.h" using namespace bot::translator; using namespace std::string_literals; diff --git a/src/translator_libretranslate.h b/src/translator/libretranslate/libretranslate.h similarity index 98% rename from src/translator_libretranslate.h rename to src/translator/libretranslate/libretranslate.h index eaa287d..0bb8afa 100644 --- a/src/translator_libretranslate.h +++ b/src/translator/libretranslate/libretranslate.h @@ -21,7 +21,7 @@ #include #include -#include "translator_core.h" +#include "../../core/translator.h" namespace bot { namespace translator {