make helper function for trimming a twitch channel name from irc

This commit is contained in:
Rasmus Karlsson
2018-03-25 11:37:57 +02:00
committed by fourtf
parent 9886021c6a
commit 6e1096710d
7 changed files with 68 additions and 24 deletions
+9 -1
View File
@@ -2,6 +2,7 @@
#include "providers/twitch/ircmessagehandler.hpp"
#include "providers/twitch/twitchaccount.hpp"
#include "providers/twitch/twitchhelpers.hpp"
#include "providers/twitch/twitchmessagebuilder.hpp"
#include "singletons/accountmanager.hpp"
#include "util/posttothread.hpp"
@@ -14,6 +15,7 @@ using namespace chatterino::singletons;
namespace chatterino {
namespace providers {
namespace twitch {
TwitchServer::TwitchServer()
: whispersChannel(new Channel("/mentions"))
, mentionsChannel(new Channel("/mentions"))
@@ -72,8 +74,13 @@ std::shared_ptr<Channel> TwitchServer::createChannel(const QString &channelName)
void TwitchServer::privateMessageReceived(IrcPrivateMessage *message)
{
QString channelName;
if (!TrimChannelName(message->target(), channelName)) {
return;
}
this->onPrivateMessage.invoke(message);
auto chan = TwitchServer::getInstance().getChannel(message->target().mid(1));
auto chan = TwitchServer::getInstance().getChannel(channelName);
if (!chan) {
return;
@@ -163,6 +170,7 @@ void TwitchServer::forEachChannelAndSpecialChannels(std::function<void(ChannelPt
func(this->whispersChannel);
func(this->mentionsChannel);
}
} // namespace twitch
} // namespace providers
} // namespace chatterino