mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Added a "CleanChannelName" virtual method to AbstractIrcServer
the TwitchServer implementation makes the channelName full lowercase Fixes #293
This commit is contained in:
parent
8e7d89dd40
commit
dca11406b9
|
@ -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
|
// try get channel
|
||||||
ChannelPtr chan = this->getChannel(channelName);
|
ChannelPtr chan = this->getChannel(channelName);
|
||||||
if (chan != Channel::getEmpty()) {
|
if (chan != Channel::getEmpty()) {
|
||||||
|
@ -137,8 +139,10 @@ std::shared_ptr<Channel> AbstractIrcServer::addChannel(const QString &channelNam
|
||||||
return chan;
|
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);
|
std::lock_guard<std::mutex> lock(this->channelMutex);
|
||||||
|
|
||||||
// try get special channel
|
// try get special channel
|
||||||
|
@ -210,6 +214,11 @@ std::shared_ptr<Channel> AbstractIrcServer::getCustomChannel(const QString &chan
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AbstractIrcServer::CleanChannelName(const QString &dirtyChannelName)
|
||||||
|
{
|
||||||
|
return dirtyChannelName;
|
||||||
|
}
|
||||||
|
|
||||||
void AbstractIrcServer::addFakeMessage(const QString &data)
|
void AbstractIrcServer::addFakeMessage(const QString &data)
|
||||||
{
|
{
|
||||||
auto fakeMessage = Communi::IrcMessage::fromData(data.toUtf8(), this->readConnection.get());
|
auto fakeMessage = Communi::IrcMessage::fromData(data.toUtf8(), this->readConnection.get());
|
||||||
|
|
|
@ -22,8 +22,8 @@ public:
|
||||||
void sendMessage(const QString &channelName, const QString &message);
|
void sendMessage(const QString &channelName, const QString &message);
|
||||||
|
|
||||||
// channels
|
// channels
|
||||||
std::shared_ptr<Channel> addChannel(const QString &channelName);
|
std::shared_ptr<Channel> addChannel(const QString &dirtyChannelName);
|
||||||
std::shared_ptr<Channel> getChannel(const QString &channelName);
|
std::shared_ptr<Channel> getChannel(const QString &dirtyChannelName);
|
||||||
|
|
||||||
// signals
|
// signals
|
||||||
pajlada::Signals::NoArgSignal connected;
|
pajlada::Signals::NoArgSignal connected;
|
||||||
|
@ -51,6 +51,8 @@ protected:
|
||||||
|
|
||||||
virtual std::shared_ptr<Channel> getCustomChannel(const QString &channelName);
|
virtual std::shared_ptr<Channel> getCustomChannel(const QString &channelName);
|
||||||
|
|
||||||
|
virtual QString CleanChannelName(const QString &dirtyChannelName);
|
||||||
|
|
||||||
QMap<QString, std::weak_ptr<Channel>> channels;
|
QMap<QString, std::weak_ptr<Channel>> channels;
|
||||||
std::mutex channelMutex;
|
std::mutex channelMutex;
|
||||||
|
|
||||||
|
|
|
@ -168,6 +168,11 @@ void TwitchServer::forEachChannelAndSpecialChannels(std::function<void(ChannelPt
|
||||||
func(this->mentionsChannel);
|
func(this->mentionsChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString TwitchServer::CleanChannelName(const QString &dirtyChannelName)
|
||||||
|
{
|
||||||
|
return dirtyChannelName.toLower();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace twitch
|
} // namespace twitch
|
||||||
} // namespace providers
|
} // namespace providers
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -33,6 +33,8 @@ protected:
|
||||||
virtual void writeConnectionMessageReceived(Communi::IrcMessage *message) override;
|
virtual void writeConnectionMessageReceived(Communi::IrcMessage *message) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<Channel> getCustomChannel(const QString &channelname) override;
|
virtual std::shared_ptr<Channel> getCustomChannel(const QString &channelname) override;
|
||||||
|
|
||||||
|
QString CleanChannelName(const QString &dirtyChannelName) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace twitch
|
} // namespace twitch
|
||||||
|
|
Loading…
Reference in a new issue