added send and receive for irc messages
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "providers/irc/Irc2.hpp"
|
||||
#include "providers/irc/IrcChannel2.hpp"
|
||||
|
||||
@@ -31,11 +32,21 @@ IrcServer::~IrcServer()
|
||||
delete this->data_;
|
||||
}
|
||||
|
||||
int IrcServer::getId()
|
||||
int IrcServer::id()
|
||||
{
|
||||
return this->data_->id;
|
||||
}
|
||||
|
||||
const QString &IrcServer::user()
|
||||
{
|
||||
return this->data_->user;
|
||||
}
|
||||
|
||||
const QString &IrcServer::nick()
|
||||
{
|
||||
return this->data_->nick;
|
||||
}
|
||||
|
||||
void IrcServer::initializeConnection(IrcConnection *connection, bool isRead,
|
||||
bool isWrite)
|
||||
{
|
||||
@@ -47,13 +58,13 @@ void IrcServer::initializeConnection(IrcConnection *connection, bool isRead,
|
||||
|
||||
connection->setUserName(this->data_->user);
|
||||
connection->setNickName(this->data_->nick);
|
||||
connection->setRealName(this->data_->nick);
|
||||
connection->setRealName(this->data_->real);
|
||||
connection->setPassword(this->data_->password);
|
||||
}
|
||||
|
||||
std::shared_ptr<Channel> IrcServer::createChannel(const QString &channelName)
|
||||
{
|
||||
return std::make_shared<IrcChannel>(channelName);
|
||||
return std::make_shared<IrcChannel>(channelName, this);
|
||||
}
|
||||
|
||||
bool IrcServer::hasSeparateWriteConnection() const
|
||||
@@ -61,4 +72,27 @@ bool IrcServer::hasSeparateWriteConnection() const
|
||||
return false;
|
||||
}
|
||||
|
||||
void IrcServer::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
||||
{
|
||||
auto target = message->target();
|
||||
target = target.startsWith('#') ? target.mid(1) : target;
|
||||
|
||||
if (auto channel = this->getChannelOrEmpty(target); !channel->isEmpty())
|
||||
{
|
||||
MessageBuilder builder;
|
||||
|
||||
builder.emplace<TextElement>(message->nick() + ":",
|
||||
MessageElementFlag::Username);
|
||||
builder.emplace<TextElement>(message->content(),
|
||||
MessageElementFlag::Text);
|
||||
|
||||
channel->addMessage(builder.release());
|
||||
}
|
||||
}
|
||||
|
||||
void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
|
||||
{
|
||||
qDebug() << QString(message->toData());
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user