Java irc bot乒乓球

时间:2012-05-22 20:58:04

标签: java bots irc

if (serverResponse.contains("PING ")) {
    writer.write("PONG " + serverResponse.substring(5) + "\r\n");
    writer.write("PRIVMSG " + c.getHomechannel() + " :I got pinged!\r\n");
    System.out.println("pinged");
    writer.flush( );
}

if (cmd.equalsIgnoreCase("PING")) {
    TCPRequestManager.sendWrite("PONG " + param);
    TCPRequestManager.doMsg("c.getHomechannel()", ":I got pinged!");
    TCPConnectionManager.getWriter().flush( );
}

两个SEEM工作并向我发送消息说客户端已被ping,但我不认为它实际上由于断开而返回pong,我做错了什么?

1 个答案:

答案 0 :(得分:0)

PONG message contain a destination不应该吗?我猜第一个代码块中的serverResponse.substring(5)是服务器的服务器名称​​ ping 您的服务器。它期望从您的服务器 irc服务器的PONG

通常,交易看起来像这样, a.com 是irc服务器的主机名, b.com 是连接到它的机器人的主机名:

PING :a.com          (sent from a.com to b.com)
PONG b.com :a.com    (sent from b.com to a.com)

看起来你发送的内容(前面的例子)是:

PING :a.com          (sent from a.com to b.com)
PONG :a.com          (sent from b.com to a.com, except there's no origin)