Пример #1
0
 private void specificView(ViewContext ctx, JSONObject data, boolean showBullets)
     throws JSONException {
   ctx.respond(
       "#module %s #plain module -- %s", data.getString("name"), data.getString("description"));
   final String[] examples = data.getStringArray("examples");
   if (examples == null || examples.length == 0) {
     ctx.respond("No examples available");
   } else {
     ctx.respond("Examples:");
     for (String example : examples) {
       final MessageBuilder builder = ctx.buildResponse();
       builder.add(showBullets ? MessageBuilder.BULLET + " " : "  ");
       for (String piece : example.split(" ")) {
         if (piece.length() > 1 && piece.startsWith(".")) {
           builder.add("#command %s ", new Object[] {piece});
         } else if (piece.length() > 2 && piece.startsWith("_") && piece.endsWith("_")) {
           builder.add("#argument %s ", new Object[] {piece.substring(1, piece.length() - 1)});
         } else {
           builder.add("%s ", new Object[] {piece});
         }
       }
       builder.send();
     }
   }
 }
Пример #2
0
 @View(method = "general")
 public void plainGeneralView(ViewContext ctx, JSONObject data) throws JSONException {
   ctx.respond("Use .#command help #module MODULE #plain to get examples for a specific module:");
   ctx.respond("List of modules: #([, ] #module %s)", (Object) data.getStringArray("modules"));
 }