mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Strip leading @ and trailing , from /user and /usercard commands (#3143)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
6151cd5b05
commit
7309fd8668
|
@ -3,6 +3,7 @@
|
||||||
## Unversioned
|
## Unversioned
|
||||||
|
|
||||||
- Minor: Remove TwitchEmotes.com attribution and the open/copy options when right-clicking a Twitch Emote. (#2214, #3136)
|
- Minor: Remove TwitchEmotes.com attribution and the open/copy options when right-clicking a Twitch Emote. (#2214, #3136)
|
||||||
|
- Minor: Strip leading @ and trailing , from username in /user and /usercard commands. (#3143)
|
||||||
- Minor: Display a system message when reloading subscription emotes to match BTTV/FFZ behavior (#3135)
|
- Minor: Display a system message when reloading subscription emotes to match BTTV/FFZ behavior (#3135)
|
||||||
- Bugfix: Moderation mode and active filters are now preserved when opening a split as a popup. (#3113, #3130)
|
- Bugfix: Moderation mode and active filters are now preserved when opening a split as a popup. (#3113, #3130)
|
||||||
- Bugfix: Fixed a bug that caused all badge highlights to use the same color. (#3132, #3134)
|
- Bugfix: Fixed a bug that caused all badge highlights to use the same color. (#3132, #3134)
|
||||||
|
|
|
@ -70,6 +70,32 @@ static const QStringList twitchDefaultCommands{
|
||||||
|
|
||||||
static const QStringList whisperCommands{"/w", ".w"};
|
static const QStringList whisperCommands{"/w", ".w"};
|
||||||
|
|
||||||
|
// stripUserName removes any @ prefix or , suffix to make it more suitable for command use
|
||||||
|
void stripUserName(QString &userName)
|
||||||
|
{
|
||||||
|
if (userName.startsWith('@'))
|
||||||
|
{
|
||||||
|
userName.remove(0, 1);
|
||||||
|
}
|
||||||
|
if (userName.endsWith(','))
|
||||||
|
{
|
||||||
|
userName.chop(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// stripChannelName removes any @ prefix or , suffix to make it more suitable for command use
|
||||||
|
void stripChannelName(QString &channelName)
|
||||||
|
{
|
||||||
|
if (channelName.startsWith('@') || channelName.startsWith('#'))
|
||||||
|
{
|
||||||
|
channelName.remove(0, 1);
|
||||||
|
}
|
||||||
|
if (channelName.endsWith(','))
|
||||||
|
{
|
||||||
|
channelName.chop(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void sendWhisperMessage(const QString &text)
|
void sendWhisperMessage(const QString &text)
|
||||||
{
|
{
|
||||||
// (hemirt) pajlada: "we should not be sending whispers through jtv, but
|
// (hemirt) pajlada: "we should not be sending whispers through jtv, but
|
||||||
|
@ -430,16 +456,17 @@ void CommandController::initialize(Settings &, Paths &paths)
|
||||||
makeSystemMessage("Usage /user [user] (channel)"));
|
makeSystemMessage("Usage /user [user] (channel)"));
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
QString userName = words[1];
|
||||||
|
stripUserName(userName);
|
||||||
|
|
||||||
QString channelName = channel->getName();
|
QString channelName = channel->getName();
|
||||||
|
|
||||||
if (words.size() > 2)
|
if (words.size() > 2)
|
||||||
{
|
{
|
||||||
channelName = words[2];
|
channelName = words[2];
|
||||||
if (channelName[0] == '#')
|
stripChannelName(channelName);
|
||||||
{
|
|
||||||
channelName.remove(0, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
openTwitchUsercard(channelName, words[1]);
|
openTwitchUsercard(channelName, userName);
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
});
|
});
|
||||||
|
@ -451,10 +478,12 @@ void CommandController::initialize(Settings &, Paths &paths)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString userName = words[1];
|
||||||
|
stripUserName(userName);
|
||||||
auto *userPopup = new UserInfoPopup(
|
auto *userPopup = new UserInfoPopup(
|
||||||
getSettings()->autoCloseUserPopup,
|
getSettings()->autoCloseUserPopup,
|
||||||
static_cast<QWidget *>(&(getApp()->windows->getMainWindow())));
|
static_cast<QWidget *>(&(getApp()->windows->getMainWindow())));
|
||||||
userPopup->setData(words[1], channel);
|
userPopup->setData(userName, channel);
|
||||||
userPopup->move(QCursor::pos());
|
userPopup->move(QCursor::pos());
|
||||||
userPopup->show();
|
userPopup->show();
|
||||||
return "";
|
return "";
|
||||||
|
|
Loading…
Reference in a new issue