summaryrefslogtreecommitdiff
path: root/bot/src/modules/join.hpp
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-04-12 17:33:47 +0500
committerilotterytea <iltsu@alright.party>2025-04-12 17:33:47 +0500
commit1b34dc98d33c78cf2d09f0e46b83aceee0c43694 (patch)
tree30a2fe896701fdc5a23249645da3aa624a77080a /bot/src/modules/join.hpp
parent1f5f33fc2f2c8f5d2239d5506ba53438a090d52d (diff)
feat: !mcsrv in lua
Diffstat (limited to 'bot/src/modules/join.hpp')
-rw-r--r--bot/src/modules/join.hpp94
1 files changed, 0 insertions, 94 deletions
diff --git a/bot/src/modules/join.hpp b/bot/src/modules/join.hpp
deleted file mode 100644
index 6818c01..0000000
--- a/bot/src/modules/join.hpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#pragma once
-
-#include <pqxx/pqxx>
-#include <string>
-#include <vector>
-
-#include "../bundle.hpp"
-#include "../commands/command.hpp"
-#include "../schemas/channel.hpp"
-
-namespace bot {
- namespace mod {
- class Join : public command::Command {
- std::string get_name() const override { return "join"; }
-
- command::Response run(const InstanceBundle &bundle,
- const command::Request &request) const override {
- if (!bundle.configuration.commands.join_allowed) {
- std::string owner = "";
-
- if (bundle.configuration.owner.name.has_value()) {
- owner = " " + bundle.localization
- .get_formatted_line(
- request, loc::LineId::MsgOwner,
- {*bundle.configuration.owner.name})
- .value();
- }
-
- return command::Response(
- bundle.localization
- .get_formatted_line(request, loc::LineId::JoinNotAllowed,
- {owner})
- .value());
- }
-
- if (!bundle.configuration.commands.join_allow_from_other_chats &&
- request.channel.get_alias_name() !=
- bundle.irc_client.get_bot_username()) {
- return bundle.localization
- .get_formatted_line(request, loc::LineId::JoinFromOtherChat,
- {bundle.irc_client.get_bot_username()})
- .value();
- }
-
- pqxx::work work(request.conn);
-
- pqxx::result channels =
- work.exec("SELECT * FROM channels WHERE alias_id = " +
- std::to_string(request.user.get_alias_id()));
-
- if (!channels.empty()) {
- schemas::Channel channel(channels[0]);
-
- if (channel.get_opted_out_at().has_value()) {
- work.exec("UPDATE channels SET opted_out_at = null WHERE id = " +
- std::to_string(channel.get_id()));
- work.commit();
-
- bundle.irc_client.join(channel.get_alias_name());
-
- return command::Response(
- bundle.localization
- .get_formatted_line(request, loc::LineId::JoinRejoined,
- {})
- .value());
- }
-
- return command::Response(
- bundle.localization
- .get_formatted_line(request, loc::LineId::JoinAlreadyIn, {})
- .value());
- }
-
- work.exec("INSERT INTO channels(alias_id, alias_name) VALUES (" +
- std::to_string(request.user.get_alias_id()) + ", '" +
- request.user.get_alias_name() + "')");
- work.commit();
-
- bundle.irc_client.join(request.user.get_alias_name());
- bundle.irc_client.say(
- request.user.get_alias_name(),
- bundle.localization
- .get_formatted_line(request, loc::LineId::JoinResponseInChat,
- {})
- .value());
-
- return command::Response(
- bundle.localization
- .get_formatted_line(request, loc::LineId::JoinResponse, {})
- .value());
- }
- };
- }
-}