23 #include "ircisupportparser.h"
25 #include "irc/entities/ircuserprefix.h"
27 #include <QRegularExpression>
28 #include <QStringList>
30 DClass<IRCISupportParser>
44 QStringList iSupportParams;
54 IRCISupportParser::~IRCISupportParser()
58 void IRCISupportParser::appendLine(
const QString &line)
60 for (
const QString &element : line.split(
" "))
62 if (element ==
":are")
68 d->iSupportParams << element;
72 QString IRCISupportParser::findValue(
const QString &key)
74 for (
const QString &element : d->iSupportParams)
76 if (element.startsWith(key))
77 return element.mid(key.length());
82 void IRCISupportParser::parse()
88 void IRCISupportParser::parsePrefix()
90 QString value = findValue(
"PREFIX=");
93 QRegularExpression regex(R
"(\((\S+)\)(\S+)$)", QRegularExpression::InvertedGreedinessOption);
94 auto match = regex.match(value);
95 if (!match.hasMatch())
97 QByteArray modes = match.captured(1).toUtf8();
98 QByteArray prefixes = match.captured(2).toUtf8();
99 if (modes.size() != prefixes.size())
102 for (
int i = 0; i < modes.size(); ++i)
103 userPrefixes.assignPrefix(modes[i], prefixes[i]);
104 d->state.userPrefixes = userPrefixes;
109 return d->state.userPrefixes;