Beispiel #1
0
 public boolean matches(BotManager manager, User user) {
   if (manager != managerReceiver) return false;
   for (Pair<IdentHandler, String> pair : dataReceiver) {
     if (!Util.equals(pair.get1().account(user), pair.get2())) return false;
   }
   return true;
 }
Beispiel #2
0
  public static JSONObject write(Tell tell) {
    JSONObject j =
        JSONObject.make(
            "tellid", tell.id,
            "date", (int) (tell.date.getTime() / 1000),
            "message", tell.message,
            "serverFrom", tell.managerSender.name,
            "serverTo", tell.managerReceiver.name);

    JSONList<JSONObject> jSender = j.putNewList("sender").ofObjects();
    for (Pair<IdentHandler, String> pair : tell.dataSender) {
      jSender.add(JSONObject.make("handler", pair.get1().id, "account", pair.get2()));
    }

    JSONList<JSONObject> jReceiver = j.putNewList("receiver").ofObjects();
    for (Pair<IdentHandler, String> pair : tell.dataReceiver) {
      jReceiver.add(JSONObject.make("handler", pair.get1().id, "account", pair.get2()));
    }

    return j;
  }
Beispiel #3
0
  public String buildMessage() {
    boolean hasServer = false;
    for (Pair<IdentHandler, String> pair : dataSender) {
      if (managerSender != managerReceiver) {
        if (pair.get1().id.equals(Plugin.pluginIdent.handlerServer.id)) {
          hasServer = true;
          break;
        }
      }
    }

    return String.format(
        "[%s] %s",
        TimeDuration.format(date) + " ago",
        Plugin.pluginIdent.formatIdent(
            dataSender,
            "<%n%" + (hasServer ? "@%srv%" : "") + "> %arg0%\nAdditional info: %_%",
            message));
  }