Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed 3rdPartyBinaries/Sleepy.dll
Binary file not shown.
Binary file removed 3rdPartyBinaries/Sleepy.lib
Binary file not shown.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ This is the source code for all the main Arduino programs.
| [QDarkStyleSheet](https://github.com/ColinDuquesnoy/QDarkStyleSheet) | MIT |
| [Qt Wav Reader](https://code.qt.io/cgit/qt/qtmultimedia.git/tree/examples/multimedia/spectrum/app/wavfile.cpp?h=5.15) | BSD |
| [nlohmann json](https://github.com/nlohmann/json) | MIT |
| [Sleepy Discord](https://github.com/yourWaifu/sleepy-discord) | MIT |
| [D++](https://github.com/brainboxdotcc/DPP) | Apache 2.0 |
| [LUFA](https://github.com/abcminiuser/lufa) | MIT |
| [Tesseract](https://github.com/tesseract-ocr/tesseract) | Apache 2.0 |
Expand Down
4 changes: 0 additions & 4 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,6 @@ file(GLOB MAIN_SOURCES
Source/Integrations/IntegrationsAPI.h
Source/Integrations/ProgramTracker.cpp
Source/Integrations/ProgramTracker.h
Source/Integrations/SleepyDiscordRunner.cpp
Source/Integrations/SleepyDiscordRunner.h
Source/Kernels/AbsFFT/Kernels_AbsFFT.cpp
Source/Kernels/AbsFFT/Kernels_AbsFFT.h
Source/Kernels/AbsFFT/Kernels_AbsFFT_Arch.h
Expand Down Expand Up @@ -2462,15 +2460,13 @@ if (MSVC)
OpenCV_lib
ONNX_lib
ONNX_Providers_lib
Sleepy.lib
dpp_lib
)
target_compile_definitions(
SerialPrograms PRIVATE
_CRT_SECURE_NO_WARNINGS
_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
PA_TESSERACT
PA_SLEEPY
PA_DPP
)

Expand Down
13 changes: 1 addition & 12 deletions SerialPrograms/Source/CommonFramework/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "Logging/Logger.h"
#include "Logging/OutputRedirector.h"
//#include "Tools/StatsDatabase.h"
#include "Integrations/SleepyDiscordRunner.h"
#include "Globals.h"
#include "GlobalSettingsPanel.h"
//#include "Windows/DpiScaler.h"
Expand Down Expand Up @@ -111,15 +110,8 @@ int main(int argc, char *argv[]){

Integration::DiscordIntegrationSettingsOption& discord_settings = GlobalSettings::instance().DISCORD->integration;
if (discord_settings.run_on_start){
#ifdef PA_SLEEPY
if (discord_settings.library0 == Integration::DiscordIntegrationSettingsOption::Library::SleepyDiscord){
Integration::SleepyDiscordRunner::sleepy_connect();
}
#endif
#ifdef PA_DPP
if (discord_settings.library0 == Integration::DiscordIntegrationSettingsOption::Library::DPP){
Integration::DppClient::Client::instance().connect();
}
Integration::DppClient::Client::instance().connect();
#endif
discord_settings.on_config_value_changed(nullptr);
}
Expand All @@ -144,9 +136,6 @@ int main(int argc, char *argv[]){
#ifdef PA_DPP
Integration::DppClient::Client::instance().disconnect();
#endif
#ifdef PA_SLEEPY
Integration::SleepyDiscordRunner::sleepy_terminate();
#endif

return ret;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "CommonFramework/Tools/ProgramEnvironment.h"
#include "CommonFramework/ProgramStats/StatsTracking.h"
#include "Integrations/DiscordWebhook.h"
#include "Integrations/SleepyDiscordRunner.h"
#include "ProgramNotifications.h"

//#include <iostream>
Expand Down Expand Up @@ -120,22 +119,11 @@ void send_raw_notification(
hasFile ? file : nullptr
);

#ifdef PA_SLEEPY
if (GlobalSettings::instance().DISCORD->integration.library0 == Integration::DiscordIntegrationSettingsOption::Library::SleepyDiscord){
Integration::SleepyDiscordRunner::send_embed_sleepy(
should_ping, tags, std::move(embed),
hasFile ? file : nullptr
);
}
#endif

#ifdef PA_DPP
if (GlobalSettings::instance().DISCORD->integration.library0 == Integration::DiscordIntegrationSettingsOption::Library::DPP){
Integration::DppClient::Client::instance().send_embed_dpp(
should_ping, color, tags, std::move(embed),
hasFile ? file : nullptr
);
}
Integration::DppClient::Client::instance().send_embed_dpp(
should_ping, color, tags, std::move(embed),
hasFile ? file : nullptr
);
#endif
}
void send_raw_notification(
Expand Down Expand Up @@ -173,22 +161,11 @@ void send_raw_notification(
hasFile ? file : nullptr
);

#ifdef PA_SLEEPY
if (GlobalSettings::instance().DISCORD->integration.library0 == Integration::DiscordIntegrationSettingsOption::Library::SleepyDiscord){
Integration::SleepyDiscordRunner::send_embed_sleepy(
should_ping, tags, std::move(embed),
hasFile ? file : nullptr
);
}
#endif

#ifdef PA_DPP
if (GlobalSettings::instance().DISCORD->integration.library0 == Integration::DiscordIntegrationSettingsOption::Library::DPP){
Integration::DppClient::Client::instance().send_embed_dpp(
should_ping, color, tags, std::move(embed),
hasFile ? file : nullptr
);
}
Integration::DppClient::Client::instance().send_embed_dpp(
should_ping, color, tags, std::move(embed),
hasFile ? file : nullptr
);
#endif
}

Expand Down
116 changes: 14 additions & 102 deletions SerialPrograms/Source/Integrations/DiscordIntegrationSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//#include "CommonFramework/Globals.h"
//#include "CommonFramework/GlobalSettingsPanel.h"
#include "DppIntegration/DppClient.h"
#include "SleepyDiscordRunner.h"
#include "DiscordIntegrationSettings.h"

//#include <iostream>
Expand All @@ -23,7 +22,6 @@ namespace Integration{


DiscordIntegrationSettingsOption::~DiscordIntegrationSettingsOption(){
library0.remove_listener(*this);
this->remove_listener(*this);
}
DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()
Expand All @@ -38,15 +36,6 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()
LockMode::LOCK_WHILE_RUNNING,
false
)
, library0(
"<b>Discord Integration Library:</b><br>Restart the program for this to take effect.",
{
{Library::SleepyDiscord, "sleepy", "Sleepy Discord (normal commands, deprecated)"},
{Library::DPP, "dpp", "D++ (slash commands and normal commands)"},
},
LockMode::LOCK_WHILE_RUNNING,
Library::DPP
)
, command_type(
"<b>Discord Integration Command Type:</b><br>Restart the program for this to take effect.",
{
Expand All @@ -68,11 +57,6 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()
LockMode::LOCK_WHILE_RUNNING,
"^", "^"
)
, use_suffix(
"<b>Use Suffix (Sleepy):</b><br>Use a suffix instead of a prefix for commands.",
LockMode::LOCK_WHILE_RUNNING,
false
)
, game_status(
false,
"<b>Discord Game Status:</b><br>Enter a status message your bot would display.",
Expand All @@ -85,87 +69,39 @@ DiscordIntegrationSettingsOption::DiscordIntegrationSettingsOption()
LockMode::LOCK_WHILE_RUNNING,
"", "Automation at your service!"
)
, sudo(
false,
"<b>Discord Sudo (Sleepy):</b><br>Enter user ID(s) to grant sudo access to.",
LockMode::LOCK_WHILE_RUNNING,
"", "123456789012345678"
)
, owner(
false,
"<b>Discord Owner (Sleepy):</b><br>Enter the bot owner's ID (your own ID).",
LockMode::LOCK_WHILE_RUNNING,
"", "123456789012345678"
)
, allow_buttons_from_users(
"<b>Allow Buttons from Users:</b><br>Allow other users to issue button presses.",
LockMode::LOCK_WHILE_RUNNING,
false
)
{
PA_ADD_OPTION(run_on_start);
PA_ADD_OPTION(library0);
PA_ADD_OPTION(command_type);
PA_ADD_OPTION(token);
PA_ADD_OPTION(command_prefix);
PA_ADD_OPTION(use_suffix);
PA_ADD_OPTION(game_status);
PA_ADD_OPTION(hello_message);
PA_ADD_OPTION(sudo);
PA_ADD_OPTION(owner);
PA_ADD_OPTION(allow_buttons_from_users);
PA_ADD_OPTION(channels);

DiscordIntegrationSettingsOption::on_config_value_changed(this);

this->add_listener(*this);
library0.add_listener(*this);
}
void DiscordIntegrationSettingsOption::on_config_value_changed([[maybe_unused]] void* object){
// cout << this->enabled() << endl;
#if (defined PA_SLEEPY || defined PA_DPP)
bool options_enabled = this->enabled();
switch (library0){
#ifdef PA_SLEEPY
case Library::SleepyDiscord:{
options_enabled &= !SleepyDiscordRunner::is_running();
ConfigOptionState state = options_enabled ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED;

library0.set_visibility(state);
command_type.set_visibility(ConfigOptionState::HIDDEN);
token.set_visibility(state);
game_status.set_visibility(state);
hello_message.set_visibility(state);

command_prefix.set_visibility(state);
use_suffix.set_visibility(state);
sudo.set_visibility(state);
owner.set_visibility(state);
allow_buttons_from_users.set_visibility(ConfigOptionState::HIDDEN);
break;
}
#endif
#ifdef PA_DPP
case Library::DPP:{
options_enabled &= !DppClient::Client::instance().is_initialized();
ConfigOptionState state = options_enabled ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED;

library0.set_visibility(state);
command_type.set_visibility(state);
token.set_visibility(state);
game_status.set_visibility(state);
hello_message.set_visibility(state);
allow_buttons_from_users.set_visibility(state);

command_prefix.set_visibility(state);
use_suffix.set_visibility(ConfigOptionState::HIDDEN);
sudo.set_visibility(ConfigOptionState::HIDDEN);
owner.set_visibility(ConfigOptionState::HIDDEN);
break;
}
#endif
default:;
}
bool options_enabled = this->enabled();
options_enabled &= !DppClient::Client::instance().is_initialized();
ConfigOptionState state = options_enabled ? ConfigOptionState::ENABLED : ConfigOptionState::DISABLED;

command_type.set_visibility(state);
token.set_visibility(state);
game_status.set_visibility(state);
hello_message.set_visibility(state);
allow_buttons_from_users.set_visibility(state);

command_prefix.set_visibility(state);
#endif
}

Expand All @@ -181,7 +117,7 @@ ConfigWidget* DiscordIntegrationSettingsOption::make_QtWidget(QWidget& parent){
DiscordIntegrationSettingsWidget::DiscordIntegrationSettingsWidget(QWidget& parent, DiscordIntegrationSettingsOption& value)
: GroupWidget(parent, value)
{
#if (defined PA_SLEEPY || defined PA_DPP)
#ifdef PA_DPP

QWidget* control_buttons = new QWidget(this);
m_options_layout->insertWidget(0, control_buttons);
Expand All @@ -207,38 +143,14 @@ DiscordIntegrationSettingsWidget::DiscordIntegrationSettingsWidget(QWidget& pare
connect(
button_start, &QPushButton::clicked,
this, [this, &value](bool){
switch (value.library0){
#ifdef PA_SLEEPY
case DiscordIntegrationSettingsOption::Library::SleepyDiscord:
SleepyDiscordRunner::sleepy_connect();
break;
#endif
#ifdef PA_DPP
case DiscordIntegrationSettingsOption::Library::DPP:
DppClient::Client::instance().connect();
break;
#endif
default:;
}
DppClient::Client::instance().connect();
value.on_config_value_changed(this);
}
);
connect(
button_stop, &QPushButton::clicked,
this, [this, &value](bool){
switch (value.library0){
#ifdef PA_SLEEPY
case DiscordIntegrationSettingsOption::Library::SleepyDiscord:
SleepyDiscordRunner::sleepy_terminate();
break;
#endif
#ifdef PA_DPP
case DiscordIntegrationSettingsOption::Library::DPP:
DppClient::Client::instance().disconnect();
break;
#endif
default:;
}
DppClient::Client::instance().disconnect();
value.on_config_value_changed(this);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ class DiscordIntegrationSettingsOption : public GroupOption, private ConfigOptio

BooleanCheckBoxOption run_on_start;

enum class Library{
SleepyDiscord,
DPP,
};
EnumDropdownOption<Library> library0;

enum class CommandType{
SlashCommands,
MessageCommands,
Expand All @@ -43,11 +37,8 @@ class DiscordIntegrationSettingsOption : public GroupOption, private ConfigOptio

StringOption token;
StringOption command_prefix;
BooleanCheckBoxOption use_suffix;
StringOption game_status;
StringOption hello_message;
StringOption sudo;
StringOption owner;
BooleanCheckBoxOption allow_buttons_from_users;
DiscordIntegrationTable channels;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ DiscordSettingsOption::DiscordSettingsOption()
{
PA_ADD_OPTION(message);
PA_ADD_OPTION(webhooks);
#if defined PA_SLEEPY || defined PA_DPP
#ifdef PA_DPP
PA_ADD_OPTION(integration);
#endif
}
Expand Down
Loading