Java PircBot如何获取主机名
有人知道如何在皮尔博茨使用这个吗? 我只需要获得一个用户主机名并禁止他们。谢谢你的阅读Java PircBot如何获取主机名,java,irc,Java,Irc,有人知道如何在皮尔博茨使用这个吗? 我只需要获得一个用户主机名并禁止他们。谢谢你的阅读 if (cmd.equalsIgnoreCase("ban")) { if (command[1] != null && command[2] != null) { //Command[1] is the users name.
if (cmd.equalsIgnoreCase("ban")) {
if (command[1] != null && command[2] != null) {
//Command[1] is the users name.
//Command[2] is the reason.
//how do i make this ban someone?
}
}
你不能有理由禁止,只有有理由踢。在本例中,我假设您想要kban,即kick+ban
if (cmd.equalsIgnoreCase("ban")) {
if (command[1] != null && command[2] != null) {
//Command[1] is the users name.
//Command[2] is the reason.
//how do i make this ban someone?
// ban first
//make sure to input the current channel in "currentChannel"
ban(currentChannel, command[1]+"!*@*");
// kick with a reason
kick(currentChannel, command[1], command[2]);
}
}
如果您的命令需要一个主机掩码,您应该让用户指定它-他可能需要一个特定的禁令,可能需要一个整个范围的禁令等等。否则,生成一个糟糕的昵称禁令(如果用户脱机,您可以使用“whowas”来查找,否则您应该使用“whois”。请注意,“whowas”可能不起作用。)
来自皮尔博特的JavaDoc-
ban(字符串通道、字符串主机掩码)
禁止用户访问频道
踢腿(琴弦通道、琴弦缺口)
从频道踢用户
井涌(管柱通道、管柱缺口、管柱原因)
将用户踢出频道,给出原因。虽然这是一个老问题,但我想我会与大家分享我是如何解决这个问题的。我假设您正在处理
onMessage
事件中的ban命令。在这种情况下,您必须在地图中保存命令[1]
。然后打电话
sendRawLine("WHO " + command[1]);
重写服务器响应上的
onServerResponse
并循环捕获代码RPL\u,然后split(\\s”)
响应。然后你可以在地图上用键查找splitResult[5]
,主机将在splitResult[3]
中,然后你可以用String.format(“*!*%s”,splitResult[3])
读到这里,我只是不知道如何解析主机名@吉姆加里森