Forward mediated invitations (XMPP to IRC only)

This commit is contained in:
louiz’
2016-08-16 15:59:00 +02:00
parent 6bbab9d943
commit 663d4ad54a
6 changed files with 64 additions and 2 deletions
+13 -2
View File
@@ -64,6 +64,8 @@ static const std::unordered_map<std::string,
{"432", {&IrcClient::on_erroneous_nickname, {2, 0}}},
{"433", {&IrcClient::on_nickname_conflict, {2, 0}}},
{"438", {&IrcClient::on_nickname_change_too_fast, {2, 0}}},
{"443", {&IrcClient::on_useronchannel, {3, 0}}},
{"ERR_USERONCHANNEL", {&IrcClient::on_useronchannel, {3, 0}}},
{"001", {&IrcClient::on_welcome_message, {1, 0}}},
{"PART", {&IrcClient::on_part, {1, 0}}},
{"ERROR", {&IrcClient::on_error, {1, 0}}},
@@ -95,7 +97,6 @@ static const std::unordered_map<std::string,
{"436", {&IrcClient::on_generic_error, {2, 0}}},
{"441", {&IrcClient::on_generic_error, {2, 0}}},
{"442", {&IrcClient::on_generic_error, {2, 0}}},
{"443", {&IrcClient::on_generic_error, {2, 0}}},
{"444", {&IrcClient::on_generic_error, {2, 0}}},
{"446", {&IrcClient::on_generic_error, {2, 0}}},
{"451", {&IrcClient::on_generic_error, {2, 0}}},
@@ -429,6 +430,11 @@ void IrcClient::send_list_command()
this->send_message(IrcMessage("LIST", {}));
}
void IrcClient::send_invitation(const std::string& chan_name, const std::string& nick)
{
this->send_message(IrcMessage("INVITE", {nick, chan_name}));
}
void IrcClient::send_topic_command(const std::string& chan_name, const std::string& topic)
{
this->send_message(IrcMessage("TOPIC", {chan_name, topic}));
@@ -803,7 +809,6 @@ void IrcClient::on_nickname_change_too_fast(const IrcMessage& message)
"", txt);
}
}
void IrcClient::on_generic_error(const IrcMessage& message)
{
const std::string error_msg = message.arguments.size() >= 3 ?
@@ -811,6 +816,12 @@ void IrcClient::on_generic_error(const IrcMessage& message)
this->send_gateway_message(message.arguments[1] + ": " + error_msg, message.prefix);
}
void IrcClient::on_useronchannel(const IrcMessage& message)
{
this->send_gateway_message(message.arguments[1] + " " + message.arguments[3] + " "
+ message.arguments[2]);
}
void IrcClient::on_welcome_message(const IrcMessage& message)
{
this->current_nick = message.arguments[0];
+5
View File
@@ -129,6 +129,7 @@ public:
* Send the LIST irc command
*/
void send_list_command();
void send_invitation(const std::string& chan_name, const std::string& nick);
void send_topic_command(const std::string& chan_name, const std::string& topic);
/**
* Send the QUIT irc command
@@ -234,6 +235,10 @@ public:
* Idem, but for when the user changes their nickname too quickly
*/
void on_nickname_change_too_fast(const IrcMessage& message);
/**
* An error when we try to invite a user already in the channel
*/
void on_useronchannel(const IrcMessage& message);
/**
* Handles most errors from the server by just forwarding the message to the user.
*/