コード例 #1
0
  /** On register */
  @Override
  public void onRegister() {
    // Call parent method to ensure "register" status is tracked
    super.onRegister();

    // execute commands
    CommandParser parser = CommandParser.getInstance();

    this.updateNickMatchPattern();
    for (String command : server.getConnectCommands()) {
      parser.parse(command, server, server.getConversation(ServerInfo.DEFAULT_NAME), service);
    }

    // TODO: Detect "You are now identified for <nick>" notices from NickServ and handle
    //       auto joins in onNotice instead if the user has chosen to wait for NickServ
    //       identification before auto joining channels.

    // delay 1 sec before auto joining channels
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      // do nothing
    }

    // join channels
    if (autojoinChannels != null) {
      for (String channel : autojoinChannels) {
        // Add support for channel keys
        joinChannel(channel);
      }
    } else {
      for (String channel : server.getAutoJoinChannels()) {
        joinChannel(channel);
      }
    }

    Message infoMessage = new Message(service.getString(R.string.message_login_done));
    infoMessage.setColor(Message.COLOR_GREY);
    server.getConversation(ServerInfo.DEFAULT_NAME).addMessage(infoMessage);

    Intent intent =
        Broadcast.createConversationIntent(
            Broadcast.CONVERSATION_MESSAGE, server.getId(), ServerInfo.DEFAULT_NAME);

    service.sendBroadcast(intent);
  }