Fixed broken CTCP

master
Tomatix 5 years ago
parent 18a87ceef2
commit b39afed624
  1. 2
      ICommand/Internal/ctcp.cpp
  2. 2
      ICommand/Internal/me.cpp
  3. 32
      IRCClient/IRCBase.cpp
  4. 3
      IRCClient/IRCBase.h
  5. 5
      IdealIRC/IRC.cpp

@ -10,5 +10,5 @@ void ICommandPriv::cmd_ctcp(const std::string& target, const std::string& comman
.arg(qmsg)
.arg(target.c_str()));
connection.ctcp(target, command, message);
connection.ctcpRequest(target, command, message);
}

@ -6,7 +6,7 @@ using namespace Command::Internal;
void ICommandPriv::cmd_me(const std::string& target, const std::string& message)
{
connection.ctcp(target, ACTION, message);
connection.ctcpRequest(target, ACTION, message);
std::string mynick = connection.getNickname();
IWin* cw = status.getActiveWindow();

@ -324,6 +324,20 @@ struct IRCBasePriv
sock->write_some(asio::buffer(out));
}
void ctcp(const std::string& messageType, const std::string& target, const std::string& command, const std::string& message = "")
{
if (!isConnected)
return;
std::string ctcpdata;
ctcpdata.push_back(CTCPflag);
ctcpdata.append(command);
if (!message.empty())
ctcpdata.append(" " + message);
ctcpdata.push_back(CTCPflag);
write(messageType, { target }, ctcpdata);
}
void addMemberToChannel(const IRCPrefix& prefix, const std::string& channel)
{
auto member = super.getMember(prefix.nickname());
@ -468,7 +482,7 @@ struct IRCBasePriv
return IRCError::NoError;
}
void parseChannelModeMessage(std::shared_ptr<IRCChannel> chan, const std::string& modes, const std::vector<std::string>& args)
void parseChannelModeMessage(std::shared_ptr<IRCChannel> chan, const std::string& modes, const std::vector<std::string>& args) const
{
char sign; // + or -
int argidx = 0;
@ -681,18 +695,14 @@ void IRCBase::raw(const std::string& data)
mp->writeNoMsg(data, {});
}
void IRCBase::ctcp(const std::string& target, const std::string& command, const std::string& message)
void IRCBase::ctcpRequest(const std::string& target, const std::string& command, const std::string& message)
{
if (!mp->isConnected)
return;
mp->ctcp(Command::IRC::PRIVMSG, target, command, message);
}
std::string ctcpdata;
ctcpdata.push_back(CTCPflag);
ctcpdata.append(command);
if (!message.empty())
ctcpdata.append(" " + message);
ctcpdata.push_back(CTCPflag);
mp->write(Command::IRC::PRIVMSG, { target }, ctcpdata);
void IRCBase::ctcpResponse(const std::string& target, const std::string& command, const std::string& message)
{
mp->ctcp(Command::IRC::NOTICE, target, command, message);
}
void IRCBase::setManualKeepalive(std::chrono::seconds freq)

@ -56,7 +56,8 @@ public:
void command(const std::string& command, const std::string& msg);
void raw(const std::string& data);
void ctcp(const std::string& target, const std::string& command, const std::string& message = "");
void ctcpRequest(const std::string& target, const std::string& command, const std::string& message = "");
void ctcpResponse(const std::string& target, const std::string& command, const std::string& message = "");
//! Set to >0 to enable, =0 to disable.
void setManualKeepalive(std::chrono::seconds freq = std::chrono::seconds(30));

@ -611,7 +611,7 @@ void IRC::onMsgCTCPRequest(const IRCPrefix& sender, const std::string& target, c
msg = fmt::format("[CTCP {}] from {}", command, sender.nickname());
}
/* Sent to channel */
/* Sent to channel */
else {
msg = fmt::format("[CTCP {}]:{} from {}", command, target, sender.nickname());
}
@ -621,7 +621,8 @@ void IRC::onMsgCTCPRequest(const IRCPrefix& sender, const std::string& target, c
}
if (command == "VERSION") {
ctcp(sender.nickname(), "VERSION", fmt::format("IdealIRC {} by Tomatix - http://idealirc.org/", VERSION_STRING));
ctcpResponse(sender.nickname(), "VERSION",
fmt::format("IdealIRC {} by Tomatix - http://www.idealirc.org/", VERSION_STRING));
}
contextualScriptEvent(&m_status, ScriptEvent::CtcpRequest, sender.toString(), target, command, message);

Loading…
Cancel
Save