mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Add reward.cost
reward.id
, reward.title
filter variables (#5275)
This commit is contained in:
parent
09b2c53383
commit
69bdac9936
|
@ -50,6 +50,7 @@
|
||||||
- Minor: Image links now reflect the scale of their image instead of an internal label. (#5201)
|
- Minor: Image links now reflect the scale of their image instead of an internal label. (#5201)
|
||||||
- Minor: IPC files are now stored in the Chatterino directory instead of system directories on Windows. (#5226)
|
- Minor: IPC files are now stored in the Chatterino directory instead of system directories on Windows. (#5226)
|
||||||
- Minor: 7TV emotes now have a 4x image rather than a 3x image. (#5209)
|
- Minor: 7TV emotes now have a 4x image rather than a 3x image. (#5209)
|
||||||
|
- Minor: Add `reward.cost` `reward.id`, `reward.title` filter variables. (#5275)
|
||||||
- Bugfix: Fixed an issue where certain emojis did not send to Twitch chat correctly. (#4840)
|
- Bugfix: Fixed an issue where certain emojis did not send to Twitch chat correctly. (#4840)
|
||||||
- Bugfix: Fixed the `/shoutout` command not working with usernames starting with @'s (e.g. `/shoutout @forsen`). (#4800)
|
- Bugfix: Fixed the `/shoutout` command not working with usernames starting with @'s (e.g. `/shoutout @forsen`). (#4800)
|
||||||
- Bugfix: Fixed capitalized channel names in log inclusion list not being logged. (#4848)
|
- Bugfix: Fixed capitalized channel names in log inclusion list not being logged. (#4848)
|
||||||
|
|
|
@ -120,6 +120,18 @@ ContextMap buildContextMap(const MessagePtr &m, chatterino::Channel *channel)
|
||||||
vars["channel.live"] = false;
|
vars["channel.live"] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (m->reward != nullptr)
|
||||||
|
{
|
||||||
|
vars["reward.title"] = m->reward->title;
|
||||||
|
vars["reward.cost"] = m->reward->cost;
|
||||||
|
vars["reward.id"] = m->reward->id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vars["reward.title"] = "";
|
||||||
|
vars["reward.cost"] = -1;
|
||||||
|
vars["reward.id"] = "";
|
||||||
|
}
|
||||||
return vars;
|
return vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,9 @@ static const QMap<QString, Type> MESSAGE_TYPING_CONTEXT = {
|
||||||
{"flags.monitored", Type::Bool},
|
{"flags.monitored", Type::Bool},
|
||||||
{"message.content", Type::String},
|
{"message.content", Type::String},
|
||||||
{"message.length", Type::Int},
|
{"message.length", Type::Int},
|
||||||
|
{"reward.title", Type::String},
|
||||||
|
{"reward.cost", Type::Int},
|
||||||
|
{"reward.id", Type::String},
|
||||||
};
|
};
|
||||||
|
|
||||||
ContextMap buildContextMap(const MessagePtr &m, chatterino::Channel *channel);
|
ContextMap buildContextMap(const MessagePtr &m, chatterino::Channel *channel);
|
||||||
|
|
|
@ -35,7 +35,11 @@ static const QMap<QString, QString> validIdentifiersMap = {
|
||||||
{"flags.restricted", "restricted message?"},
|
{"flags.restricted", "restricted message?"},
|
||||||
{"flags.monitored", "monitored message?"},
|
{"flags.monitored", "monitored message?"},
|
||||||
{"message.content", "message text"},
|
{"message.content", "message text"},
|
||||||
{"message.length", "message length"}};
|
{"message.length", "message length"},
|
||||||
|
{"reward.title", "point reward title"},
|
||||||
|
{"reward.cost", "point reward cost"},
|
||||||
|
{"reward.id", "point reward id"},
|
||||||
|
};
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const QRegularExpression tokenRegex(
|
static const QRegularExpression tokenRegex(
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/FlagsEnum.hpp"
|
#include "common/FlagsEnum.hpp"
|
||||||
|
#include "providers/twitch/ChannelPointReward.hpp"
|
||||||
#include "util/QStringHash.hpp"
|
#include "util/QStringHash.hpp"
|
||||||
|
|
||||||
#include <magic_enum/magic_enum.hpp>
|
#include <magic_enum/magic_enum.hpp>
|
||||||
|
@ -107,6 +108,8 @@ struct Message {
|
||||||
std::vector<std::unique_ptr<MessageElement>> elements;
|
std::vector<std::unique_ptr<MessageElement>> elements;
|
||||||
|
|
||||||
ScrollbarHighlight getScrollBarHighlight() const;
|
ScrollbarHighlight getScrollBarHighlight() const;
|
||||||
|
|
||||||
|
std::shared_ptr<ChannelPointReward> reward = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -1625,6 +1625,8 @@ void TwitchMessageBuilder::appendChannelPointRewardMessage(
|
||||||
builder->message().messageText = textList.join(" ");
|
builder->message().messageText = textList.join(" ");
|
||||||
builder->message().searchText = textList.join(" ");
|
builder->message().searchText = textList.join(" ");
|
||||||
builder->message().loginName = reward.user.login;
|
builder->message().loginName = reward.user.login;
|
||||||
|
|
||||||
|
builder->message().reward = std::make_shared<ChannelPointReward>(reward);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchMessageBuilder::liveMessage(const QString &channelName,
|
void TwitchMessageBuilder::liveMessage(const QString &channelName,
|
||||||
|
|
|
@ -268,6 +268,20 @@ void addHiddenContextMenuItems(QMenu *menu,
|
||||||
jsonObject["searchText"] = message->searchText;
|
jsonObject["searchText"] = message->searchText;
|
||||||
jsonObject["messageText"] = message->messageText;
|
jsonObject["messageText"] = message->messageText;
|
||||||
jsonObject["flags"] = qmagicenum::enumFlagsName(message->flags.value());
|
jsonObject["flags"] = qmagicenum::enumFlagsName(message->flags.value());
|
||||||
|
if (message->reward)
|
||||||
|
{
|
||||||
|
QJsonObject reward;
|
||||||
|
reward["id"] = message->reward->id;
|
||||||
|
reward["title"] = message->reward->title;
|
||||||
|
reward["cost"] = message->reward->cost;
|
||||||
|
reward["isUserInputRequired"] =
|
||||||
|
message->reward->isUserInputRequired;
|
||||||
|
jsonObject["reward"] = reward;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
jsonObject["reward"] = QJsonValue();
|
||||||
|
}
|
||||||
|
|
||||||
jsonDocument.setObject(jsonObject);
|
jsonDocument.setObject(jsonObject);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue