summaryrefslogtreecommitdiff
path: root/src/irc/irc_user.cpp
diff options
context:
space:
mode:
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, {})
+{
}