summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-11-10 06:33:04 +0100
committerFlorent Le Coz <louiz@louiz.org>2013-11-10 06:33:04 +0100
commit10d528717723a72dd3240c634980a461cf9fa2df (patch)
tree51f640715c78b4d76a04a4952edb5c6a5acf6de0 /src/irc
parent7ba2d0fb45e7466e6fb38002bf1866d1f5e39c28 (diff)
downloadbiboumi-10d528717723a72dd3240c634980a461cf9fa2df.tar.gz
biboumi-10d528717723a72dd3240c634980a461cf9fa2df.tar.bz2
biboumi-10d528717723a72dd3240c634980a461cf9fa2df.tar.xz
biboumi-10d528717723a72dd3240c634980a461cf9fa2df.zip
Handle private messages, both ways
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/irc_client.cpp13
-rw-r--r--src/irc/irc_client.hpp4
2 files changed, 16 insertions, 1 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index 8de7c8f..71b0fe2 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -147,6 +147,11 @@ bool IrcClient::send_channel_message(const std::string& chan_name, const std::st
return true;
}
+void IrcClient::send_private_message(const std::string& username, const std::string& body)
+{
+ this->send_message(IrcMessage("PRIVMSG", {username, body}));
+}
+
void IrcClient::send_part_command(const std::string& chan_name, const std::string& status_message)
{
IrcChannel* channel = this->get_channel(chan_name);
@@ -211,7 +216,13 @@ void IrcClient::on_channel_message(const IrcMessage& message)
iid.chan = message.arguments[0];
iid.server = this->hostname;
const std::string body = message.arguments[1];
- this->bridge->send_muc_message(iid, nick, body);
+ bool muc = true;
+ if (!this->get_channel(iid.chan)->joined)
+ {
+ iid.chan = nick;
+ muc = false;
+ }
+ this->bridge->send_message(iid, nick, body, muc);
}
void IrcClient::on_topic_received(const IrcMessage& message)
diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp
index 33ab894..bb51a4e 100644
--- a/src/irc/irc_client.hpp
+++ b/src/irc/irc_client.hpp
@@ -76,6 +76,10 @@ public:
*/
bool send_channel_message(const std::string& chan_name, const std::string& body);
/**
+ * Send a PRIVMSG command for an user
+ */
+ void send_private_message(const std::string& username, const std::string& body);
+ /**
* Send the PART irc command
*/
void send_part_command(const std::string& chan_name, const std::string& status_message);