mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Migrate /uniquechat and /uniquechatoff to Helix API (#4057)
* Migrate /uniquechat and /uniquechatoff to Helix * Update CHANGELOG.md * Move & squash changelog entries Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
3e020b4891
commit
c71d3437f4
|
@ -62,6 +62,8 @@
|
|||
- Minor: Migrated /timeout to Helix API. (#4049)
|
||||
- Minor: Migrated /w to Helix API. Chat command will continue to be used until February 11th 2023. (#4052)
|
||||
- Minor: Migrated /vips to Helix API. Chat command will continue to be used until February 11th 2023. (#4053)
|
||||
- Minor: Migrated /uniquechat and /r9kbeta to Helix API. (#4057)
|
||||
- Minor: Migrated /uniquechatoff and /r9kbetaoff to Helix API. (#4057)
|
||||
- Minor: Make menus and placeholders display appropriate custom key combos. (#4045)
|
||||
- Bugfix: Connection to Twitch PubSub now recovers more reliably. (#3643, #3716)
|
||||
- Bugfix: Fixed `Smooth scrolling on new messages` setting sometimes hiding messages. (#4028)
|
||||
|
|
|
@ -3068,6 +3068,67 @@ void CommandController::initialize(Settings &, Paths &paths)
|
|||
|
||||
return "";
|
||||
});
|
||||
|
||||
auto uniqueChatLambda = [formatChatSettingsError](auto words, auto channel,
|
||||
bool target) {
|
||||
auto currentUser = getApp()->accounts->twitch.getCurrent();
|
||||
if (currentUser->isAnon())
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"You must be logged in to update chat settings!"));
|
||||
return "";
|
||||
}
|
||||
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
if (twitchChannel == nullptr)
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
QString("The /%1 command only works in Twitch channels")
|
||||
.arg(target ? "uniquechat" : "uniquechatoff")));
|
||||
return "";
|
||||
}
|
||||
|
||||
if (twitchChannel->accessRoomModes()->r9k == target)
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
target ? "This room is already in unique-chat mode."
|
||||
: "This room is not in unique-chat mode."));
|
||||
return "";
|
||||
}
|
||||
|
||||
getHelix()->updateUniqueChatMode(
|
||||
twitchChannel->roomId(), currentUser->getUserId(), target,
|
||||
[](auto) {
|
||||
// we'll get a message from irc
|
||||
},
|
||||
[channel, formatChatSettingsError](auto error, auto message) {
|
||||
channel->addMessage(
|
||||
makeSystemMessage(formatChatSettingsError(error, message)));
|
||||
});
|
||||
return "";
|
||||
};
|
||||
|
||||
this->registerCommand(
|
||||
"/uniquechatoff",
|
||||
[uniqueChatLambda](const QStringList &words, auto channel) {
|
||||
return uniqueChatLambda(words, channel, false);
|
||||
});
|
||||
|
||||
this->registerCommand(
|
||||
"/r9kbetaoff",
|
||||
[uniqueChatLambda](const QStringList &words, auto channel) {
|
||||
return uniqueChatLambda(words, channel, false);
|
||||
});
|
||||
|
||||
this->registerCommand(
|
||||
"/uniquechat",
|
||||
[uniqueChatLambda](const QStringList &words, auto channel) {
|
||||
return uniqueChatLambda(words, channel, true);
|
||||
});
|
||||
|
||||
this->registerCommand(
|
||||
"/r9kbeta", [uniqueChatLambda](const QStringList &words, auto channel) {
|
||||
return uniqueChatLambda(words, channel, true);
|
||||
});
|
||||
}
|
||||
|
||||
void CommandController::save()
|
||||
|
|
Loading…
Reference in a new issue