summaryrefslogtreecommitdiff
path: root/src/irc/irc_client.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-05-27 02:17:25 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-05-27 02:17:58 +0200
commit796af0531e0f5eb5fa2b800370338ede120a867d (patch)
tree8abff42f0761fa97a94390d68b6e08aa66e3c6d4 /src/irc/irc_client.cpp
parent23e8e32f84c8d7f8bb947a1ab484a81890b40371 (diff)
downloadbiboumi-796af0531e0f5eb5fa2b800370338ede120a867d.tar.gz
biboumi-796af0531e0f5eb5fa2b800370338ede120a867d.tar.bz2
biboumi-796af0531e0f5eb5fa2b800370338ede120a867d.tar.xz
biboumi-796af0531e0f5eb5fa2b800370338ede120a867d.zip
Add support for CHANTYPES isupport element, to know the prefixes of channels
Diffstat (limited to 'src/irc/irc_client.cpp')
-rw-r--r--src/irc/irc_client.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index cea08f2..03402e7 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -20,7 +20,8 @@ IrcClient::IrcClient(std::shared_ptr<Poller> poller, const std::string& hostname
current_nick(username),
bridge(bridge),
welcomed(false),
- chanmodes({"", "", "", ""})
+ chanmodes({"", "", "", ""}),
+ chantypes({'#', '&'})
{
this->dummy_channel.topic = "This is a virtual channel provided for "
"convenience by biboumi, it is not connected "
@@ -279,6 +280,15 @@ void IrcClient::on_isupport_message(const IrcMessage& message)
this->prefix_to_mode[token[j++]] = token[i++];
}
}
+ else if (token.substr(0, 10) == "CHANTYPES=")
+ {
+ // Remove the default types, they apply only if no other value is
+ // specified.
+ this->chantypes.clear();
+ size_t i = 11;
+ while (i < token.size())
+ this->chantypes.insert(token[i++]);
+ }
}
}
@@ -564,8 +574,7 @@ void IrcClient::on_kick(const IrcMessage& message)
void IrcClient::on_mode(const IrcMessage& message)
{
const std::string target = message.arguments[0];
- if (target[0] == '&' || target[0] == '#' ||
- target[0] == '!' || target[0] == '+')
+ if (this->chantypes.find(target[0]) != this->chantypes.end())
this->on_channel_mode(message);
else
this->on_user_mode(message);