Added a "CleanChannelName" virtual method to AbstractIrcServer

the TwitchServer implementation makes the channelName full lowercase

Fixes #293
This commit is contained in:
Rasmus Karlsson
2018-04-01 15:10:15 +02:00
parent 58fe1f6dcc
commit d075231081
4 changed files with 22 additions and 4 deletions
+11 -2
View File
@@ -95,8 +95,10 @@ void AbstractIrcServer::writeConnectionMessageReceived(Communi::IrcMessage *mess
{
}
std::shared_ptr<Channel> AbstractIrcServer::addChannel(const QString &channelName)
std::shared_ptr<Channel> AbstractIrcServer::addChannel(const QString &dirtyChannelName)
{
auto channelName = this->CleanChannelName(dirtyChannelName);
// try get channel
ChannelPtr chan = this->getChannel(channelName);
if (chan != Channel::getEmpty()) {
@@ -137,8 +139,10 @@ std::shared_ptr<Channel> AbstractIrcServer::addChannel(const QString &channelNam
return chan;
}
std::shared_ptr<Channel> AbstractIrcServer::getChannel(const QString &channelName)
std::shared_ptr<Channel> AbstractIrcServer::getChannel(const QString &dirtyChannelName)
{
auto channelName = this->CleanChannelName(dirtyChannelName);
std::lock_guard<std::mutex> lock(this->channelMutex);
// try get special channel
@@ -210,6 +214,11 @@ std::shared_ptr<Channel> AbstractIrcServer::getCustomChannel(const QString &chan
return nullptr;
}
QString AbstractIrcServer::CleanChannelName(const QString &dirtyChannelName)
{
return dirtyChannelName;
}
void AbstractIrcServer::addFakeMessage(const QString &data)
{
auto fakeMessage = Communi::IrcMessage::fromData(data.toUtf8(), this->readConnection.get());
+4 -2
View File
@@ -22,8 +22,8 @@ public:
void sendMessage(const QString &channelName, const QString &message);
// channels
std::shared_ptr<Channel> addChannel(const QString &channelName);
std::shared_ptr<Channel> getChannel(const QString &channelName);
std::shared_ptr<Channel> addChannel(const QString &dirtyChannelName);
std::shared_ptr<Channel> getChannel(const QString &dirtyChannelName);
// signals
pajlada::Signals::NoArgSignal connected;
@@ -51,6 +51,8 @@ protected:
virtual std::shared_ptr<Channel> getCustomChannel(const QString &channelName);
virtual QString CleanChannelName(const QString &dirtyChannelName);
QMap<QString, std::weak_ptr<Channel>> channels;
std::mutex channelMutex;
+5
View File
@@ -168,6 +168,11 @@ void TwitchServer::forEachChannelAndSpecialChannels(std::function<void(ChannelPt
func(this->mentionsChannel);
}
QString TwitchServer::CleanChannelName(const QString &dirtyChannelName)
{
return dirtyChannelName.toLower();
}
} // namespace twitch
} // namespace providers
} // namespace chatterino
+2
View File
@@ -33,6 +33,8 @@ protected:
virtual void writeConnectionMessageReceived(Communi::IrcMessage *message) override;
virtual std::shared_ptr<Channel> getCustomChannel(const QString &channelname) override;
QString CleanChannelName(const QString &dirtyChannelName) override;
};
} // namespace twitch