mirror of
https://github.com/Syping/dtranslatebot.git
synced 2024-11-21 13:20:23 +01:00
improve code organisation, add .rc file
This commit is contained in:
parent
5191dcbefc
commit
87961fe611
26 changed files with 92 additions and 83 deletions
16
.gitattributes
vendored
Normal file
16
.gitattributes
vendored
Normal file
|
@ -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
|
|
@ -17,34 +17,34 @@
|
||||||
****************************************************************************]]
|
****************************************************************************]]
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(dtranslatebot VERSION 0.2 LANGUAGES CXX)
|
project(dtranslatebot VERSION 0.2.0 LANGUAGES CXX)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# dtranslatebot Source files
|
# dtranslatebot Source files
|
||||||
set(DTRANSLATEBOT_HEADERS
|
set(DTRANSLATEBOT_HEADERS
|
||||||
src/database_core.h
|
src/core/database.h
|
||||||
src/database_file.h
|
src/core/message_queue.h
|
||||||
src/message_queue.h
|
src/core/regex.h
|
||||||
src/regex.h
|
src/core/settings.h
|
||||||
src/settings.h
|
src/core/settings_types.h
|
||||||
src/settings_types.h
|
src/core/slashcommands.h
|
||||||
src/slashcommands.h
|
src/core/submit_queue.h
|
||||||
src/submit_queue.h
|
src/core/translator.h
|
||||||
src/translator_core.h
|
src/core/webhook_push.h
|
||||||
src/translator_libretranslate.h
|
src/database/file/file.h
|
||||||
src/webhook_push.h
|
src/translator/libretranslate/libretranslate.h
|
||||||
)
|
)
|
||||||
set(DTRANSLATEBOT_SOURCES
|
set(DTRANSLATEBOT_SOURCES
|
||||||
src/database_core.cpp
|
src/core/database.cpp
|
||||||
src/database_file.cpp
|
src/core/main.cpp
|
||||||
src/main.cpp
|
src/core/message_queue.cpp
|
||||||
src/message_queue.cpp
|
src/core/settings.cpp
|
||||||
src/settings.cpp
|
src/core/slashcommands.cpp
|
||||||
src/slashcommands.cpp
|
src/core/submit_queue.cpp
|
||||||
src/submit_queue.cpp
|
src/core/translator.cpp
|
||||||
src/translator_core.cpp
|
src/core/webhook_push.cpp
|
||||||
src/translator_libretranslate.cpp
|
src/database/file/file.cpp
|
||||||
src/webhook_push.cpp
|
src/translator/libretranslate/libretranslate.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# dtranslatebot Module Path
|
# dtranslatebot Module Path
|
||||||
|
@ -69,8 +69,16 @@ find_package(DPP REQUIRED)
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
find_package(Threads REQUIRED)
|
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
|
# dtranslatebot Target + Installs
|
||||||
add_executable(dtranslatebot ${DTRANSLATEBOT_HEADERS} ${DTRANSLATEBOT_SOURCES})
|
add_executable(dtranslatebot ${DTRANSLATEBOT_HEADERS} ${DTRANSLATEBOT_SOURCES} ${DTRANSLATEBOT_RESOURCES})
|
||||||
target_compile_definitions(dtranslatebot PRIVATE
|
target_compile_definitions(dtranslatebot PRIVATE
|
||||||
$<$<BOOL:${DTRANSLATEBOT_USE_BOOST_REGEX}>:DTRANSLATEBOT_USE_BOOST_REGEX>
|
$<$<BOOL:${DTRANSLATEBOT_USE_BOOST_REGEX}>:DTRANSLATEBOT_USE_BOOST_REGEX>
|
||||||
)
|
)
|
||||||
|
|
|
@ -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": ""
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
{
|
|
||||||
"token": "",
|
|
||||||
"translator": {
|
|
||||||
"url": "http://127.0.0.1:5000/",
|
|
||||||
"apiKey": ""
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,7 +19,7 @@
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
#include "database_core.h"
|
#include "database.h"
|
||||||
using namespace bot::database;
|
using namespace bot::database;
|
||||||
|
|
||||||
database::database()
|
database::database()
|
|
@ -16,8 +16,8 @@
|
||||||
* responsible for anything with use of the software, you are self responsible.
|
* responsible for anything with use of the software, you are self responsible.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef DATABASE_CORE_H
|
#ifndef DATABASE_H
|
||||||
#define DATABASE_CORE_H
|
#define DATABASE_H
|
||||||
|
|
||||||
#include "settings_types.h"
|
#include "settings_types.h"
|
||||||
|
|
||||||
|
@ -52,4 +52,4 @@ namespace bot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DATABASE_CORE_H
|
#endif // DATABASE_H
|
|
@ -19,9 +19,9 @@
|
||||||
#include <dpp/json.h>
|
#include <dpp/json.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "database_file.h"
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "translator_libretranslate.h"
|
#include "../database/file/file.h"
|
||||||
|
#include "../translator/libretranslate/libretranslate.h"
|
||||||
using namespace bot::settings;
|
using namespace bot::settings;
|
||||||
|
|
||||||
void process_database_channels(std::shared_ptr<bot::database::database> database, bot::settings::guild *guild, std::vector<dpp::snowflake> *webhookIds)
|
void process_database_channels(std::shared_ptr<bot::database::database> database, bot::settings::guild *guild, std::vector<dpp::snowflake> *webhookIds)
|
|
@ -19,9 +19,9 @@
|
||||||
#ifndef SETTINGS_H
|
#ifndef SETTINGS_H
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "database_core.h"
|
#include "database.h"
|
||||||
#include "settings_types.h"
|
#include "settings_types.h"
|
||||||
#include "translator_core.h"
|
#include "translator.h"
|
||||||
|
|
||||||
namespace bot {
|
namespace bot {
|
||||||
namespace settings {
|
namespace settings {
|
|
@ -19,7 +19,7 @@
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
#include "translator_core.h"
|
#include "translator.h"
|
||||||
using namespace bot::translator;
|
using namespace bot::translator;
|
||||||
|
|
||||||
translator::translator()
|
translator::translator()
|
|
@ -16,8 +16,8 @@
|
||||||
* responsible for anything with use of the software, you are self responsible.
|
* responsible for anything with use of the software, you are self responsible.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#ifndef TRANSLATOR_CORE_H
|
#ifndef TRANSLATOR_H
|
||||||
#define TRANSLATOR_CORE_H
|
#define TRANSLATOR_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -39,4 +39,4 @@ namespace bot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TRANSLATOR_CORE_H
|
#endif // TRANSLATOR_H
|
|
@ -27,7 +27,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "database_file.h"
|
#include "file.h"
|
||||||
using namespace bot::database;
|
using namespace bot::database;
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
#include "database_core.h"
|
#include "../../core/database.h"
|
||||||
|
|
||||||
namespace bot {
|
namespace bot {
|
||||||
namespace database {
|
namespace database {
|
29
src/resources/win32/dtranslatebot.rc.in
Normal file
29
src/resources/win32/dtranslatebot.rc.in
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#include <windows.h>
|
||||||
|
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
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include <dpp/json.h>
|
#include <dpp/json.h>
|
||||||
#include <dpp/httpsclient.h>
|
#include <dpp/httpsclient.h>
|
||||||
#include "translator_libretranslate.h"
|
#include "libretranslate.h"
|
||||||
using namespace bot::translator;
|
using namespace bot::translator;
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "translator_core.h"
|
#include "../../core/translator.h"
|
||||||
|
|
||||||
namespace bot {
|
namespace bot {
|
||||||
namespace translator {
|
namespace translator {
|
Loading…
Reference in a new issue