PIRCBOT-如何为频道中的所有用户添加语音-Java



我正在使用pircbot制作IRC机器人。我如何让机器人为频道中的所有用户添加语音?或者用户何时加入?

可能是这样的:

import org.jibble.pircbot.*;
public class MyBot extends PircBot {
  public MyBot() {
    this.setName("MyBot");
  }
  public void onJoin(String channel, String sender,
                   String login, String hostname, String message) {
    this.voice(channel, sender);
  }
  public void voiceAll(String channel) {
    int i = 0;
    User[] users = this.getUsers(channel);
    while (i < users.length)
      this.voice(channel, users[i++].getNick());
  }
}
public class MyBotMain {
  public static void main(String[] args) throws Exception {
    MyBot bot = new MyBot();
    bot.connect("irc.freenode.net");
    bot.joinChannel("#chan");
    bot.voiceAll("#chan"); 
  }
}

你应该在发声前核实一些东西(你在chan吗?你是接线员吗?)。查看API页面:http://www.jibble.org/javadocs/pircbot/index.html.

最新更新