Example #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;
 }
Example #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;
  }