mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
added settings to show part and join messages
This commit is contained in:
parent
88c609df43
commit
b016f0fb88
7 changed files with 104 additions and 8 deletions
|
@ -246,6 +246,26 @@ void IrcMessageHandler::handleWriteConnectionNoticeMessage(Communi::IrcNoticeMes
|
|||
this->handleNoticeMessage(message);
|
||||
}
|
||||
|
||||
void IrcMessageHandler::handleJoinMessage(Communi::IrcMessage *message)
|
||||
{
|
||||
auto app = getApp();
|
||||
auto channel = app->twitch.server->getChannelOrEmpty(message->parameter(0).remove(0, 1));
|
||||
|
||||
if (TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get())) {
|
||||
twitchChannel->addJoinedUser(message->nick());
|
||||
}
|
||||
}
|
||||
|
||||
void IrcMessageHandler::handlePartMessage(Communi::IrcMessage *message)
|
||||
{
|
||||
auto app = getApp();
|
||||
auto channel = app->twitch.server->getChannelOrEmpty(message->parameter(0).remove(0, 1));
|
||||
|
||||
if (TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get())) {
|
||||
twitchChannel->addPartedUser(message->nick());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace twitch
|
||||
} // namespace providers
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -21,6 +21,9 @@ public:
|
|||
void handleModeMessage(Communi::IrcMessage *message);
|
||||
void handleNoticeMessage(Communi::IrcNoticeMessage *message);
|
||||
void handleWriteConnectionNoticeMessage(Communi::IrcNoticeMessage *message);
|
||||
|
||||
void handleJoinMessage(Communi::IrcMessage *message);
|
||||
void handlePartMessage(Communi::IrcMessage *message);
|
||||
};
|
||||
|
||||
} // namespace twitch
|
||||
|
|
|
@ -213,6 +213,58 @@ void TwitchChannel::addRecentChatter(const std::shared_ptr<messages::Message> &m
|
|||
this->completionModel.addUser(message->displayName);
|
||||
}
|
||||
|
||||
void TwitchChannel::addJoinedUser(const QString &user)
|
||||
{
|
||||
auto *app = getApp();
|
||||
if (user == app->accounts->Twitch.getCurrent()->getUserName() ||
|
||||
!app->settings->showJoins.getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex);
|
||||
|
||||
joinedUsers << user;
|
||||
|
||||
if (!this->joinedUsersMergeQueued) {
|
||||
this->joinedUsersMergeQueued = true;
|
||||
|
||||
QTimer::singleShot(500, &this->object, [this] {
|
||||
std::lock_guard<std::mutex> guard(this->joinedUserMutex);
|
||||
|
||||
this->addMessage(messages::Message::createSystemMessage("Users joined: " +
|
||||
this->joinedUsers.join(", ")));
|
||||
this->joinedUsersMergeQueued = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void TwitchChannel::addPartedUser(const QString &user)
|
||||
{
|
||||
auto *app = getApp();
|
||||
|
||||
if (user == app->accounts->Twitch.getCurrent()->getUserName() ||
|
||||
!app->settings->showJoins.getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(this->partedUserMutex);
|
||||
|
||||
partedUsers << user;
|
||||
|
||||
if (!this->partedUsersMergeQueued) {
|
||||
this->partedUsersMergeQueued = true;
|
||||
|
||||
QTimer::singleShot(500, &this->object, [this] {
|
||||
std::lock_guard<std::mutex> guard(this->partedUserMutex);
|
||||
|
||||
this->addMessage(messages::Message::createSystemMessage("Users parted: " +
|
||||
this->partedUsers.join(", ")));
|
||||
|
||||
this->partedUsersMergeQueued = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
TwitchChannel::RoomModes TwitchChannel::getRoomModes()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->roomModeMutex);
|
||||
|
|
|
@ -63,6 +63,8 @@ public:
|
|||
bool hasModRights();
|
||||
|
||||
void addRecentChatter(const std::shared_ptr<messages::Message> &message) final;
|
||||
void addJoinedUser(const QString &user);
|
||||
void addPartedUser(const QString &user);
|
||||
|
||||
const std::shared_ptr<chatterino::util::EmoteMap> bttvChannelEmotes;
|
||||
const std::shared_ptr<chatterino::util::EmoteMap> ffzChannelEmotes;
|
||||
|
@ -113,6 +115,14 @@ private:
|
|||
RoomModes roomModes;
|
||||
std::mutex roomModeMutex;
|
||||
|
||||
QObject object;
|
||||
std::mutex joinedUserMutex;
|
||||
QStringList joinedUsers;
|
||||
bool joinedUsersMergeQueued = false;
|
||||
std::mutex partedUserMutex;
|
||||
QStringList partedUsers;
|
||||
bool partedUsersMergeQueued = false;
|
||||
|
||||
Communi::IrcConnection *readConnection;
|
||||
|
||||
friend class TwitchServer;
|
||||
|
|
|
@ -114,21 +114,26 @@ void TwitchServer::messageReceived(IrcMessage *message)
|
|||
|
||||
const QString &command = message->command();
|
||||
|
||||
auto &handler = IrcMessageHandler::getInstance();
|
||||
|
||||
if (command == "ROOMSTATE") {
|
||||
IrcMessageHandler::getInstance().handleRoomStateMessage(message);
|
||||
handler.handleRoomStateMessage(message);
|
||||
} else if (command == "CLEARCHAT") {
|
||||
IrcMessageHandler::getInstance().handleClearChatMessage(message);
|
||||
handler.handleClearChatMessage(message);
|
||||
} else if (command == "USERSTATE") {
|
||||
IrcMessageHandler::getInstance().handleUserStateMessage(message);
|
||||
handler.handleUserStateMessage(message);
|
||||
} else if (command == "WHISPER") {
|
||||
IrcMessageHandler::getInstance().handleWhisperMessage(message);
|
||||
handler.handleWhisperMessage(message);
|
||||
} else if (command == "USERNOTICE") {
|
||||
IrcMessageHandler::getInstance().handleUserNoticeMessage(message);
|
||||
handler.handleUserNoticeMessage(message);
|
||||
} else if (command == "MODE") {
|
||||
IrcMessageHandler::getInstance().handleModeMessage(message);
|
||||
handler.handleModeMessage(message);
|
||||
} else if (command == "NOTICE") {
|
||||
IrcMessageHandler::getInstance().handleNoticeMessage(
|
||||
static_cast<IrcNoticeMessage *>(message));
|
||||
handler.handleNoticeMessage(static_cast<IrcNoticeMessage *>(message));
|
||||
} else if (command == "JOIN") {
|
||||
handler.handleJoinMessage(message);
|
||||
} else if (command == "PART") {
|
||||
handler.handlePartMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
/// Behaviour
|
||||
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages", true};
|
||||
BoolSetting mentionUsersWithAt = {"/behaviour/mentionUsersWithAt", false};
|
||||
BoolSetting showJoins = {"/behaviour/showJoins", false};
|
||||
BoolSetting showParts = {"/behaviour/showParts", false};
|
||||
FloatSetting mouseScrollMultiplier = {"/behaviour/mouseScrollMultiplier", 1.0};
|
||||
|
||||
// Auto-completion
|
||||
|
|
|
@ -34,6 +34,10 @@ BehaviourPage::BehaviourPage()
|
|||
{
|
||||
form->addRow("Window:", this->createCheckBox(WINDOW_TOPMOST, app->settings->windowTopMost));
|
||||
form->addRow("Messages:", this->createCheckBox(INPUT_EMPTY, app->settings->hideEmptyInput));
|
||||
form->addRow("", this->createCheckBox("Show which users joined the channel",
|
||||
app->settings->showJoins));
|
||||
form->addRow("", this->createCheckBox("Show which users parted the channel",
|
||||
app->settings->showParts));
|
||||
form->addRow("Pause chat:",
|
||||
this->createCheckBox(PAUSE_HOVERING, app->settings->pauseChatHover));
|
||||
|
||||
|
|
Loading…
Reference in a new issue