mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
07dd8c560b
Co-authored-by: Sidd <iProdigy@users.noreply.github.com> Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
60 lines
1.1 KiB
C++
60 lines
1.1 KiB
C++
#include "util/Twitch.hpp"
|
|
|
|
#include <QDesktopServices>
|
|
#include <QUrl>
|
|
|
|
namespace chatterino {
|
|
|
|
namespace {
|
|
|
|
const auto TWITCH_USER_LOGIN_PATTERN = R"(^[a-z0-9]\w{0,24}$)";
|
|
|
|
} // namespace
|
|
|
|
void openTwitchUsercard(QString channel, QString username)
|
|
{
|
|
QDesktopServices::openUrl("https://www.twitch.tv/popout/" + channel +
|
|
"/viewercard/" + username);
|
|
}
|
|
|
|
void stripUserName(QString &userName)
|
|
{
|
|
if (userName.startsWith('@'))
|
|
{
|
|
userName.remove(0, 1);
|
|
}
|
|
if (userName.endsWith(','))
|
|
{
|
|
userName.chop(1);
|
|
}
|
|
}
|
|
|
|
void stripChannelName(QString &channelName)
|
|
{
|
|
if (channelName.startsWith('@') || channelName.startsWith('#'))
|
|
{
|
|
channelName.remove(0, 1);
|
|
}
|
|
if (channelName.endsWith(','))
|
|
{
|
|
channelName.chop(1);
|
|
}
|
|
}
|
|
|
|
QRegularExpression twitchUserNameRegexp()
|
|
{
|
|
static QRegularExpression re(
|
|
TWITCH_USER_LOGIN_PATTERN,
|
|
QRegularExpression::PatternOption::CaseInsensitiveOption);
|
|
|
|
return re;
|
|
}
|
|
|
|
QRegularExpression twitchUserLoginRegexp()
|
|
{
|
|
static QRegularExpression re(TWITCH_USER_LOGIN_PATTERN);
|
|
|
|
return re;
|
|
}
|
|
|
|
} // namespace chatterino
|