summaryrefslogtreecommitdiff
path: root/src/irc/irc_client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/irc/irc_client.cpp')
-rw-r--r--src/irc/irc_client.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index d179aaa..f9ebfa0 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -20,7 +20,7 @@ using namespace std::string_literals;
using namespace std::chrono_literals;
IrcClient::IrcClient(std::shared_ptr<Poller> poller, const std::string& hostname, const std::string& username, Bridge* bridge):
- SocketHandler(poller),
+ TCPSocketHandler(poller),
hostname(hostname),
username(username),
current_nick(username),
@@ -77,8 +77,9 @@ void IrcClient::on_connection_failed(const std::string& reason)
for (const std::string& channel: this->channels_to_join)
{
Iid iid(channel + "%" + this->hostname);
- this->bridge->send_join_failed(iid, this->current_nick,
- "cancel", "item-not-found", reason);
+ this->bridge->send_presence_error(iid, this->current_nick,
+ "cancel", "item-not-found",
+ "", reason);
}
}
else // try the next port
@@ -93,9 +94,11 @@ void IrcClient::on_connected()
this->send_pending_data();
}
-void IrcClient::on_connection_close()
+void IrcClient::on_connection_close(const std::string& error_msg)
{
- static const std::string message = "Connection closed by remote server.";
+ std::string message = "Connection closed by remote server.";
+ if (!error_msg.empty())
+ message += ": " + error_msg;
const IrcMessage error{"ERROR", {message}};
this->on_error(error);
log_warning(message);
@@ -475,6 +478,25 @@ void IrcClient::on_nickname_conflict(const IrcMessage& message)
}
}
+void IrcClient::on_nickname_change_too_fast(const IrcMessage& message)
+{
+ const std::string nickname = message.arguments[1];
+ std::string txt;
+ if (message.arguments.size() >= 3)
+ txt = message.arguments[2];
+ this->on_generic_error(message);
+ for (auto it = this->channels.begin(); it != this->channels.end(); ++it)
+ {
+ Iid iid;
+ iid.set_local(it->first);
+ iid.set_server(this->hostname);
+ iid.is_channel = true;
+ this->bridge->send_presence_error(iid, nickname,
+ "cancel", "not-acceptable",
+ "", txt);
+ }
+}
+
void IrcClient::on_generic_error(const IrcMessage& message)
{
const std::string error_msg = message.arguments.size() >= 3 ?