23 #include "ircisupportparser.h" 25 #include "irc/entities/ircuserprefix.h" 27 #include <QStringList> 29 DClass<IRCISupportParser>
43 QStringList iSupportParams;
53 IRCISupportParser::~IRCISupportParser()
57 void IRCISupportParser::appendLine(
const QString &line)
59 for (
const QString &element : line.split(
" "))
61 if (element ==
":are")
67 d->iSupportParams << element;
71 QString IRCISupportParser::findValue(
const QString &key)
73 for (
const QString &element : d->iSupportParams)
75 if (element.startsWith(key))
76 return element.mid(key.length());
81 void IRCISupportParser::parse()
87 void IRCISupportParser::parsePrefix()
89 QString value = findValue(
"PREFIX=");
92 QRegExp regex(R
"(\((\S+)\)(\S+)$)"); 93 regex.setMinimal(true);
94 if (regex.indexIn(value) < 0)
96 QByteArray modes = regex.cap(1).toUtf8();
97 QByteArray prefixes = regex.cap(2).toUtf8();
98 if (modes.size() != prefixes.size())
101 for (
int i = 0; i < modes.size(); ++i)
102 userPrefixes.assignPrefix(modes[i], prefixes[i]);
103 d->state.userPrefixes = userPrefixes;
108 return d->state.userPrefixes;
static IRCUserPrefix mkDefault()
User modes: op, half-op and voice.
One-to-one association of visible prefixes to user mode.