~singpolyma/biboumi

532228a3cefd92fe43ad0f52149b7f0f5ab5cb79 — Florent Le Coz 7 years ago 1691cf8
Send a PASS IRC command if the “pass” config is sot by a user, on an IRC server

fix #3068
2 files changed, 13 insertions(+), 0 deletions(-)

M src/irc/irc_client.cpp
M src/irc/irc_client.hpp
M src/irc/irc_client.cpp => src/irc/irc_client.cpp +12 -0
@@ 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}));

M src/irc/irc_client.hpp => src/irc/irc_client.hpp +1 -0
@@ 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.
   */