diff --git a/.gitignore b/.gitignore
index e5eccb0..cd53d71 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,6 @@
build/*
Temp/
-config.json
Music
-*.info.json
+*.json
yt-dlp
ffmpeg
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..7bc07ec
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,10 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Environment-dependent path to Maven home directory
+/mavenHomeManager.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/BumbleCee.iml b/.idea/BumbleCee.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/BumbleCee.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..31e1ebc
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..75bf592
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index 5963335..b4a26e9 100644
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -3,7 +3,8 @@
{
"name": "Linux",
"includePath": [
- "${workspaceFolder}/**"
+ "${workspaceFolder}/**",
+ "${workspaceFolder}/include"
],
"defines": [
"DDPP_CORO=on"
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 1558cba..4f1df64 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -97,6 +97,11 @@
"__tuple": "cpp",
"ios": "cpp",
"locale": "cpp",
- "queue": "cpp"
+ "queue": "cpp",
+ "hash_map": "cpp",
+ "hash_set": "cpp",
+ "regex": "cpp",
+ "stack": "cpp",
+ "__memory": "cpp"
}
}
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6fa2f31..26932af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,32 +5,21 @@ set(BOT_NAME "BumbleCee")
project(${BOT_NAME})
aux_source_directory("src" coresrc)
+aux_source_directory("src/Audio" commands)
aux_source_directory("src/Commands" commands)
+aux_source_directory("src/Queue" settings)
aux_source_directory("src/Settings" settings)
+aux_source_directory("src/Utils" settings)
add_executable(${BOT_NAME} ${coresrc} ${commands} ${settings})
-string(ASCII 27 Esc)
-
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-
-set_target_properties(${BOT_NAME} PROPERTIES
- CXX_STANDARD 20
- CXX_STANDARD_REQUIRED ON
-)
+set(CMAKE_BUILD_TYPE Debug)
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
-find_package(DPP)
-if(APPLE)
- if(CMAKE_APPLE_SILICON_PROCESSOR)
- set(OPENSSL_ROOT_DIR "/opt/homebrew/opt/openssl")
- else()
- set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
- endif()
- find_package(OpenSSL REQUIRED)
-else()
- find_package(OpenSSL REQUIRED)
-endif()
+find_package(OpenSSL REQUIRED)
target_include_directories(${BOT_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
@@ -39,45 +28,13 @@ target_include_directories(${BOT_NAME} PUBLIC
)
target_link_libraries(${BOT_NAME}
- dl
dpp
opus
- opusfile
ogg
oggz
- mariadbcpp
- curl
${CMAKE_THREAD_LIBS_INIT}
${OPENSSL_CRYPTO_LIBRARY}
${OPENSSL_SSL_LIBRARY}
)
-if (DPP_FOUND)
- target_link_libraries(${BOT_NAME} ${DPP_LIBRARIES})
- target_include_directories(${BOT_NAME} PUBLIC ${DPP_INCLUDE_DIR})
-else()
- message(WARNING "Could not find DPP install. Building from source instead.")
- option(DPP_BUILD_TEST "" OFF)
- include(FetchContent)
-
- FetchContent_Declare(
- libdpp
- GIT_REPOSITORY https://github.com/brainboxdotcc/DPP.git
- GIT_TAG master)
-
- FetchContent_GetProperties(libdpp)
- if(NOT libdpp_POPULATED)
- FetchContent_Populate(libdpp)
- target_include_directories(${BOT_NAME} PUBLIC
- ${libdpp_SOURCE_DIR}/include
- )
- add_subdirectory(
- ${libdpp_SOURCE_DIR}
- ${libdpp_BINARY_DIR}
- EXCLUDE_FROM_ALL)
- endif()
-
- target_link_libraries(${BOT_NAME} dpp)
-endif()
-
-set(CMAKE_CXX_FLAGS "-g")
\ No newline at end of file
+link_directories(/usr/lib)
\ No newline at end of file
diff --git a/include/Audio/MusicPlayManager.hpp b/include/Audio/MusicPlayManager.hpp
new file mode 100644
index 0000000..da8896d
--- /dev/null
+++ b/include/Audio/MusicPlayManager.hpp
@@ -0,0 +1,50 @@
+#pragma once
+#ifndef _MUSICPLAYMANAGER_HPP_
+#define _MUSICPLAYMANAGER_HPP_
+#include
+#include
+#include
+
+namespace bumbleBee {
+class MusicPlayManager {
+public:
+ MusicPlayManager(std::shared_ptr cluster) {
+ this->cluster = cluster;
+ this->queue = std::make_unique();
+
+ cluster->on_voice_ready([this](const dpp::voice_ready_t &event){on_voice_ready(event);});
+ cluster->on_voice_track_marker([this](const dpp::voice_track_marker_t &event){on_voice_track_marker(event);});
+ cluster->on_voice_client_disconnect([this](const dpp::voice_client_disconnect_t& event){on_voice_client_disconnect(event);});
+ }
+
+ /**
+ * @brief voice_ready 이벤트 인지시 콜백되는 함수
+ * @param event const dpp::voice_ready_t&
+ **/
+ void on_voice_ready(const dpp::voice_ready_t& event);
+ /**
+ * @brief voice_track_marker 이벤트 인지시 콜백되는 함수
+ * @param event const dpp::voice_track_marker_t&
+ **/
+ void on_voice_track_marker(const dpp::voice_track_marker_t& event);
+ /**
+ * @brief voice_client_disconnect 이벤트 인지시 콜백되는 함수
+ * @param event const dpp::voice_client_disconnect_t&
+ **/
+ void on_voice_client_disconnect(const dpp::voice_client_disconnect_t& event);
+
+ void queue_music(const std::shared_ptr music);
+
+ std::condition_variable queuedCondition;
+private:
+ std::shared_ptr cluster;
+ /// @brief 음악 큐
+ std::unique_ptr queue;
+
+ std::mutex queueEmptyMutex;
+
+ void send_audio_to_voice(const MusicQueueElement& music, const dpp::voice_ready_t &event);
+ void send_audio_to_voice(const MusicQueueElement& music, const dpp::voice_track_marker_t& event);
+};
+}
+#endif
\ No newline at end of file
diff --git a/include/BumbleBee.hpp b/include/BumbleBee.hpp
index 3a93623..8267f92 100644
--- a/include/BumbleBee.hpp
+++ b/include/BumbleBee.hpp
@@ -4,9 +4,7 @@
#include
#include
#include
-#include
-#include
-#include
+#include
namespace bumbleBee {
/**
@@ -16,49 +14,38 @@ namespace bumbleBee {
class BumbleBee {
public:
/**
- * @fn BumbleBee(nlohmann::json settings)
* @brief 생성자
**/
BumbleBee();
/**
- * @fn ~BumbleBee()
* @brief 파괴자
* @details BumbleBee의 모든 Property를 책임지고 파괴합니다
**/
~BumbleBee() {}
/**
- * @fn void start()
* @brief 봇 시작
**/
void start();
/**
- * @fn void on_slashcommand(const dpp::slashcommand_t& event)
* @brief slashcommand 이벤트 인지시 콜백되는 함수
- * @param event
+ * @param event const dpp::slashcommand_t&
**/
void on_slashcommand(const dpp::slashcommand_t& event);
/**
- * @fn void on_ready(const dpp::ready_t &event)
* @brief ready 이벤트 인지시 콜백되는 함수
- * @param event
+ * @param event const dpp::ready_t&
**/
- void on_ready(const dpp::ready_t &event);
+ void on_ready(const dpp::ready_t& event);
/// @brief DPP 기본 클러스터 객체
std::shared_ptr cluster;
- /// @brief 음악 큐
- std::shared_ptr queue;
private:
- /// @brief db 드라이버
- sql::Driver* dbDriver;
- /// @brief db 접속 URL
- std::shared_ptr dbURL;
- /// @brief db 접속 속성
- std::shared_ptr dbProperties;
/// @brief Command 목록
- std::vector> commands;
+ std::unordered_map> commands;
+ /// @brief voiceclient 관련 event 처리기
+ std::shared_ptr musicManager;
};
}
#endif
\ No newline at end of file
diff --git a/include/BumbleBeeCommand.hpp b/include/BumbleBeeCommand.hpp
deleted file mode 100644
index d470ae1..0000000
--- a/include/BumbleBeeCommand.hpp
+++ /dev/null
@@ -1,102 +0,0 @@
-#pragma once
-#ifndef _BUMBLEBEECOMMAND_HPP_
-#define _BUMBLEBEECOMMAND_HPP_
-#include
-#include
-
-namespace bumbleBee::commands {
-class ICommand {
-public:
- /**
- * @brief 기본 생성자
- * @param botID 명령어 등록을 위한 봇 아이디
- * @param queue 음악이 저장되어 있는 큐
- **/
- ICommand(dpp::snowflake botID, std::weak_ptr queue) {
- this->botID = botID;
- this->queue = queue;
- }
- /**
- * @brief 명령어 호출 시에 콜백될 메소드
- * @param event dpp::slashcommand_t
- **/
- virtual void operator()(const dpp::slashcommand_t &event){};
-
- /// @brief 봇 명령어들의 이름과 별명들을 저장하는 벡터
- std::vector nameAndAliases;
-
-private:
- /// @brief 봇 ID
- dpp::snowflake botID;
- /// @brief 음악 큐에 대한 약한 포인터
- std::weak_ptr queue;
-
- /**
- * @brief 명령어 별명 추가
- * @param name 명령어 이름
- * @param description 명령어 설명
- **/
- void addCommandAliase(std::string name, std::string description) {
- nameAndAliases.push_back(dpp::slashcommand(name, description, botID));
- }
-};
-}
-
-/**
- * @brief 명령어 인자가 없는 명령어의 boilerplate 대체 매크로
- * @param name 명령어 이름 및 클래스명
- * @param alias 명령어 별명
- * @param description 명령어 설명
-**/
-#define _DECLARE_BUMBLEBEE_COMMAND_one_ALIAS(name, alias, description) \
-namespace bumbleBee::commands { \
-class name : public ICommand { \
-public: \
- name (dpp::snowflake botID, std::weak_ptr q) \
- : ICommand(botID, q) { \
- dpp::slashcommand command = dpp::slashcommand(#name, description, botID); \
- dpp::slashcommand aliasCommand = dpp::slashcommand(alias, description, botID); \
- nameAndAliases.push_back(command); \
- nameAndAliases.push_back(aliasCommand); \
- } \
- virtual void operator()(const dpp::slashcommand_t &event) override; \
-}; \
-}
-
-/**
- * @brief 명령어 인자를 하나 갖는 명령어의 boilerplate 대체 매크로
- * @param name 명령어 이름 및 클래스명
- * @param alias 명령어 별명
- * @param description 명령어 설명
- * @param option_name 명령어 인자 이름
- * @param option_desc 명령어 인자 설명
-**/
-#define _DECLARE_BUMBLEBEE_COMMAND_one_PARAM_one_ALIAS(name, alias, description, option_name, option_desc) \
-namespace bumbleBee::commands { \
-class name : public ICommand { \
-public: \
- name (dpp::snowflake botID, std::weak_ptr q) \
- : ICommand(botID, q) { \
- dpp::slashcommand command = dpp::slashcommand(#name, description, botID); \
- dpp::slashcommand aliasCommand = dpp::slashcommand(alias, description, botID); \
- command.add_option( \
- dpp::command_option(dpp::co_string, option_name, option_desc, botID) \
- ); \
- aliasCommand.add_option( \
- dpp::command_option(dpp::co_string, option_name, option_desc, botID) \
- ); \
- nameAndAliases.push_back(command); \
- nameAndAliases.push_back(aliasCommand); \
- } \
- virtual void operator()(const dpp::slashcommand_t &event) override; \
-}; \
-}
-
-_DECLARE_BUMBLEBEE_COMMAND_one_PARAM_one_ALIAS(Delete, "d", "큐의 해당하는 번호의 노래를 지웁니다", "pos", "큐 번호")
-_DECLARE_BUMBLEBEE_COMMAND_one_ALIAS(Leave, "l", "음성 채팅방을 떠납니다")
-_DECLARE_BUMBLEBEE_COMMAND_one_PARAM_one_ALIAS(Play, "p", "노래 재생", "query", "링크 또는 검색어")
-_DECLARE_BUMBLEBEE_COMMAND_one_ALIAS(Queue, "q", "노래 예약 큐를 출력합니다")
-_DECLARE_BUMBLEBEE_COMMAND_one_ALIAS(Repeat, "r", "반복을 켜거나 끕니다")
-_DECLARE_BUMBLEBEE_COMMAND_one_ALIAS(Skip, "s", "현재 재생중인 곡을 스킵합니다")
-
-#endif
\ No newline at end of file
diff --git a/include/Commands/BumbleBeeCommand.hpp b/include/Commands/BumbleBeeCommand.hpp
new file mode 100644
index 0000000..bf16d36
--- /dev/null
+++ b/include/Commands/BumbleBeeCommand.hpp
@@ -0,0 +1,70 @@
+#pragma once
+#ifndef _BUMBLEBEECOMMAND_HPP_
+#define _BUMBLEBEECOMMAND_HPP_
+#include
+#include