mirror of
https://github.com/Syping/dtranslatebot.git
synced 2024-12-21 11:25:31 +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)
|
||||
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
|
||||
$<$<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
|
||||
#include <iostream>
|
||||
#endif
|
||||
#include "database_core.h"
|
||||
#include "database.h"
|
||||
using namespace bot::database;
|
||||
|
||||
database::database()
|
|
@ -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
|
|
@ -19,9 +19,9 @@
|
|||
#include <dpp/json.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#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<bot::database::database> database, bot::settings::guild *guild, std::vector<dpp::snowflake> *webhookIds)
|
|
@ -19,9 +19,9 @@
|
|||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
#include <mutex>
|
||||
#include "database_core.h"
|
||||
#include "database.h"
|
||||
#include "settings_types.h"
|
||||
#include "translator_core.h"
|
||||
#include "translator.h"
|
||||
|
||||
namespace bot {
|
||||
namespace settings {
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef NDEBUG
|
||||
#include <iostream>
|
||||
#endif
|
||||
#include "translator_core.h"
|
||||
#include "translator.h"
|
||||
using namespace bot::translator;
|
||||
|
||||
translator::translator()
|
|
@ -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 <string>
|
||||
#include <vector>
|
||||
|
@ -39,4 +39,4 @@ namespace bot {
|
|||
}
|
||||
}
|
||||
|
||||
#endif // TRANSLATOR_CORE_H
|
||||
#endif // TRANSLATOR_H
|
|
@ -27,7 +27,7 @@
|
|||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include "database_file.h"
|
||||
#include "file.h"
|
||||
using namespace bot::database;
|
||||
using namespace std::string_literals;
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "database_core.h"
|
||||
#include "../../core/database.h"
|
||||
|
||||
namespace bot {
|
||||
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/httpsclient.h>
|
||||
#include "translator_libretranslate.h"
|
||||
#include "libretranslate.h"
|
||||
using namespace bot::translator;
|
||||
using namespace std::string_literals;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include "translator_core.h"
|
||||
#include "../../core/translator.h"
|
||||
|
||||
namespace bot {
|
||||
namespace translator {
|
Loading…
Reference in a new issue