/*
 * The MIT License
 *
 * Copyright (c) 2016 Marcelo "Ataxexe" Guimarães <ataxexe@devnull.tools>
 *
 * Permission  is hereby granted, free of charge, to any person obtaining
 * a  copy  of  this  software  and  associated  documentation files (the
 * "Software"),  to  deal  in the Software without restriction, including
 * without  limitation  the  rights to use, copy, modify, merge, publish,
 * distribute,  sublicense,  and/or  sell  copies of the Software, and to
 * permit  persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * The  above  copyright  notice  and  this  permission  notice  shall be
 * included  in  all  copies  or  substantial  portions  of the Software.
 *
 * THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY OF ANY KIND,
 * EXPRESS  OR  IMPLIED,  INCLUDING  BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN  NO  EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM,  DAMAGES  OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT  OR  OTHERWISE,  ARISING  FROM,  OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE   OR   THE   USE   OR   OTHER   DEALINGS  IN  THE  SOFTWARE.
 */

package tools.devnull.boteco.plugins.ping;

import tools.devnull.boteco.message.IncomeMessage;
import tools.devnull.boteco.message.MessageProcessor;

import static tools.devnull.boteco.message.MessageChecker.check;
import static tools.devnull.boteco.Predicates.command;

/**
 * A simple processor that responds to a "ping" command with a
 * "pong" response.
 */
public class PingMessageProcessor implements MessageProcessor {

  @Override
  public String id() {
    return "ping";
  }

  @Override
  public boolean canProcess(IncomeMessage message) {
    return check(message).accept(command("ping"));
  }

  @Override
  public void process(IncomeMessage message) {
    message.reply("%s: pong", message.sender());
  }

}

@@ -1285,16 +1285,62 @@
 .ping;%0A%0A
+import tools.devnull.boteco.ContentFormatter;%0A
 import t
@@ -1949,24 +1949,80 @@
  message) %7B%0A
+    ContentFormatter f = message.channel().formatter();%0A
     message.
@@ -2039,16 +2039,26 @@
  pong%22, 
+f.mention(
 message.
@@ -2066,16 +2066,17 @@
 ender())
+)
 ;%0A  %7D%0A%0A%7D

add a mention to the user