feat: Allow id: prefix in /ban and /timeout (#4945)
ban example: `/ban id:70948394`, equivalent to `/banid 70948394` timeout example: `/timeout id:70948394 10 xd`
This commit is contained in:
@@ -62,6 +62,33 @@ void stripChannelName(QString &channelName)
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<ParsedUserName, ParsedUserID> parseUserNameOrID(const QString &input)
|
||||
{
|
||||
if (input.startsWith("id:"))
|
||||
{
|
||||
return {
|
||||
{},
|
||||
input.mid(3),
|
||||
};
|
||||
}
|
||||
|
||||
QString userName = input;
|
||||
|
||||
if (userName.startsWith('@') || userName.startsWith('#'))
|
||||
{
|
||||
userName.remove(0, 1);
|
||||
}
|
||||
if (userName.endsWith(','))
|
||||
{
|
||||
userName.chop(1);
|
||||
}
|
||||
|
||||
return {
|
||||
userName,
|
||||
{},
|
||||
};
|
||||
}
|
||||
|
||||
QRegularExpression twitchUserNameRegexp()
|
||||
{
|
||||
static QRegularExpression re(
|
||||
|
||||
@@ -16,6 +16,16 @@ void stripUserName(QString &userName);
|
||||
// stripChannelName removes any @ prefix or , suffix to make it more suitable for command use
|
||||
void stripChannelName(QString &channelName);
|
||||
|
||||
using ParsedUserName = QString;
|
||||
using ParsedUserID = QString;
|
||||
|
||||
/**
|
||||
* Parse the given input into either a user name or a user ID
|
||||
*
|
||||
* User IDs take priority and are parsed if the input starts with `id:`
|
||||
*/
|
||||
std::pair<ParsedUserName, ParsedUserID> parseUserNameOrID(const QString &input);
|
||||
|
||||
// Matches a strict Twitch user login.
|
||||
// May contain lowercase a-z, 0-9, and underscores
|
||||
// Must contain between 1 and 25 characters
|
||||
|
||||
Reference in New Issue
Block a user