1
0
Fork 0
mirror of https://gitlab.com/niansa/SomeBot.git synced 2025-03-06 20:48:26 +01:00

Updated stuff to latest version

This commit is contained in:
niansa 2023-10-06 22:43:44 +02:00
parent 60d9f0ff93
commit b7ebfdb554
6 changed files with 3 additions and 54 deletions

3
.gitmodules vendored
View file

@ -1,9 +1,6 @@
[submodule "DPP"]
path = DPP
url = https://github.com/brainboxdotcc/DPP.git
[submodule "libjustgpt"]
path = libjustgpt
url = https://gitlab.com/niansa/libjustgpt.git
[submodule "luau"]
path = luau
url = https://github.com/Roblox/luau.git

View file

@ -6,7 +6,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(DPP)
add_subdirectory(libjustgpt)
set(LUAU_BUILD_TESTS No)
add_subdirectory(luau)
set(LUABRIDGE_TESTING No)
@ -20,7 +19,7 @@ add_compile_definitions(COMPILER_PLATFORM="${CMAKE_CXX_PLATFORM_ID}")
file(GLOB MODULES modules/*.cpp modules/*.hpp)
add_executable(KeineAhnung main.cpp util.cpp ${MODULES})
target_link_libraries(KeineAhnung PRIVATE dpp justgpt sqlite3 pthread Luau.VM Luau.Compiler LuaBridge)
target_link_libraries(KeineAhnung PRIVATE dpp sqlite3 pthread Luau.VM Luau.Compiler LuaBridge)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set_property(TARGET KeineAhnung PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "Interprocedural optimization is enabled")

2
DPP

@ -1 +1 @@
Subproject commit 22ca0359bce9034b55a754d848212e290d762a57
Subproject commit ac9081f77b5f9cd954f2936bcc5b5495dfb311cd

@ -1 +0,0 @@
Subproject commit fba3475a92b7aec01ec372ac08002d386e7acc0e

2
luau

@ -1 +1 @@
Subproject commit 48172dd5b139e410e6d1b0b1821340bc491cde9a
Subproject commit 36e0e6471567eb0d41d80e54b73db791efbb808a

View file

@ -2,62 +2,16 @@
#include <thread>
#include <ai.hpp>
class Fun {
Bot *bot;
const std::string_view ai_init_prompt =
R"(<question> Hello
<answer> Hi!
<question> How are you?
<answer> Great!
<question> What is your favorite color?
<answer> Green!
<question> What is your name?
<answer> I don't have a name.
<question> How are you?
<answer> Good.
<question> )";
Ai ai;
std::string chat_reply(const std::string& message) {
auto prompt = std::string(ai_init_prompt)+message+"\n<answer>";
return ai.complete(prompt, '\n');
}
public:
Fun(Bot *_bot) : bot(_bot) {
bot->cluster.on_message_create([&](const dpp::message_create_t& message) {
// Chat with bot
if (message.msg.content[0] == '-') {
auto content = message.msg.content;
content.erase(0, 1);
for (auto& c : content) {
if (c == '\n')
c = ' ';
}
auto reply = chat_reply(content);
message.reply(reply);
return;
}
});
bot->add_chatcommand(Bot::ChatCommand({"ping"}, "Ping pong!"), [&](const dpp::slashcommand_t& event) {
event.reply(dpp::message("Pong!").set_flags(dpp::message_flags::m_ephemeral));
});
bot->add_chatcommand(Bot::ChatCommand({"chat"}, "Chat with me (english)", dpp::slashcommand().add_option(dpp::command_option(dpp::command_option_type::co_string, "message", "Your message", true))), [&](const dpp::slashcommand_t& event) {
auto& content = std::get<std::string>(event.get_parameter("message"));
event.thinking(false);
std::thread([=]() {
auto reply = chat_reply(content);
event.delete_original_response();
bot->cluster.message_create(dpp::message(event.command.channel_id, event.command.member.get_mention()+" asked:\n> "+content+"\nI reply:\n> "+reply));
}).detach();
});
bot->add_chatcommand(Bot::ChatCommand({"cat", "katze"}, "Generiere eine Katze"), [&](const dpp::slashcommand_t& event) {
event.reply("https://thiscatdoesnotexist.com/?"+std::to_string(event.command.id));
});