summaryrefslogtreecommitdiff
path: root/src/irc/irc_user.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-12-29 19:57:43 +0100
committerFlorent Le Coz <louiz@louiz.org>2014-01-04 01:59:36 +0100
commitacf769d83a40e971ccc1346225688841465b36ee (patch)
tree8388af28b20e258d412cc34f79cb3c3cfcedbcb6 /src/irc/irc_user.cpp
parenta075517824da7e82e1be7b67d615834851482861 (diff)
downloadbiboumi-acf769d83a40e971ccc1346225688841465b36ee.tar.gz
biboumi-acf769d83a40e971ccc1346225688841465b36ee.tar.bz2
biboumi-acf769d83a40e971ccc1346225688841465b36ee.tar.xz
biboumi-acf769d83a40e971ccc1346225688841465b36ee.zip
Use isupport informations to know the user modes when joining
Also remove the duplicate send_self_join methods, user only send_user_join
Diffstat (limited to 'src/irc/irc_user.cpp')
-rw-r--r--src/irc/irc_user.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/irc/irc_user.cpp b/src/irc/irc_user.cpp
index f9866ef..934988a 100644
--- a/src/irc/irc_user.cpp
+++ b/src/irc/irc_user.cpp
@@ -2,26 +2,26 @@
#include <iostream>
-IrcUser::IrcUser(const std::string& name)
+IrcUser::IrcUser(const std::string& name,
+ const std::map<char, char>& prefix_to_mode)
{
+ if (name.empty())
+ return ;
const std::string::size_type sep = name.find("!");
+ const std::map<char, char>::const_iterator prefix = prefix_to_mode.find(name[0]);
+ const size_t name_begin = prefix == prefix_to_mode.end()? 0: 1;
if (sep == std::string::npos)
- {
- if (name[0] == '~' || name[0] == '&'
- || name[0] == '@' || name[0] == '%'
- || name[0] == '+')
- this->nick = name.substr(1);
- else
- this->nick = name;
- }
+ this->nick = name.substr(name_begin);
else
{
- if (name[0] == '~' || name[0] == '&'
- || name[0] == '@' || name[0] == '%'
- || name[0] == '+')
- this->nick = name.substr(1, sep);
- else
- this->nick = name.substr(0, sep);
+ this->nick = name.substr(name_begin, sep);
this->host = name.substr(sep+1);
}
+ if (prefix != prefix_to_mode.end())
+ this->modes.insert(prefix->second);
+}
+
+IrcUser::IrcUser(const std::string& name):
+ IrcUser(name, {})
+{
}