summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/irc/irc_client.cpp12
-rw-r--r--src/irc/irc_client.hpp1
2 files changed, 13 insertions, 0 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index 29f0b54..bac3e34 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -1,4 +1,5 @@
#include <utils/timed_events.hpp>
+#include <database/database.hpp>
#include <irc/irc_message.hpp>
#include <irc/irc_client.hpp>
#include <bridge/bridge.hpp>
@@ -94,6 +95,12 @@ void IrcClient::on_connection_failed(const std::string& reason)
void IrcClient::on_connected()
{
+#ifdef USE_DATABASE
+ auto options = Database::get_irc_server_options(this->bridge->get_bare_jid(),
+ this->get_hostname());
+ if (!options.pass.value().empty())
+ this->send_pass_command(options.pass.value());
+#endif
this->send_nick_command(this->username);
this->send_user_command(this->username, this->username);
this->send_gateway_message("Connected to IRC server"s + (this->use_tls ? " (encrypted)": "") + ".");
@@ -218,6 +225,11 @@ void IrcClient::send_nick_command(const std::string& nick)
this->send_message(IrcMessage("NICK", {nick}));
}
+void IrcClient::send_pass_command(const std::string& password)
+{
+ this->send_message(IrcMessage("PASS", {password}));
+}
+
void IrcClient::send_kick_command(const std::string& chan_name, const std::string& target, const std::string& reason)
{
this->send_message(IrcMessage("KICK", {chan_name, target, reason}));
diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp
index a3f69a0..4e61d14 100644
--- a/src/irc/irc_client.hpp
+++ b/src/irc/irc_client.hpp
@@ -85,6 +85,7 @@ public:
* Send the NICK irc command
*/
void send_nick_command(const std::string& username);
+ void send_pass_command(const std::string& password);
/**
* Send the JOIN irc command.
*/