~singpolyma/biboumi

ref: acf769d83a40e971ccc1346225688841465b36ee biboumi/src/irc/irc_user.cpp -rw-r--r-- 720 bytes
acf769d8 — Florent Le Coz Use isupport informations to know the user modes when joining 9 years ago
                                                                                
bf7b05ef Florent Le Coz
acf769d8 Florent Le Coz
bf7b05ef Florent Le Coz
acf769d8 Florent Le Coz
bf7b05ef Florent Le Coz
acf769d8 Florent Le Coz
bf7b05ef Florent Le Coz
acf769d8 Florent Le Coz
bf7b05ef Florent Le Coz
acf769d8 Florent Le Coz
bf7b05ef Florent Le Coz
acf769d8 Florent Le Coz
bf7b05ef Florent Le Coz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <irc/irc_user.hpp>

#include <iostream>

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)
    this->nick = name.substr(name_begin);
  else
    {
      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, {})
{
}