All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.split.qos.server.integrations.slack.commands.SlackPingCommand Maven / Gradle / Ivy

There is a newer version: 22.4.3
Show newest version
package io.split.qos.server.integrations.slack.commands;

import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import com.ullink.slack.simpleslackapi.SlackSession;
import com.ullink.slack.simpleslackapi.events.SlackMessagePosted;
import io.split.qos.server.integrations.slack.commandintegration.SlackCommandGetter;
import io.split.qos.server.modules.QOSServerModule;
import io.split.qos.server.util.SlackMessageSender;
import io.split.testrunner.util.SlackColors;

import java.util.List;

/**
 * Created on 11/1/16.
 */
@Singleton
public class SlackPingCommand extends SlackAbstractCommand {

    @Inject
    public SlackPingCommand(
            SlackColors slackColors,
            SlackCommandGetter slackCommandGetter,
            SlackMessageSender slackMessageSender,
            @Named(QOSServerModule.QOS_SERVER_NAME) String serverName) {
        super(slackColors, serverName, slackMessageSender, slackCommandGetter);
    }


    @Override
    public boolean test(SlackMessagePosted messagePosted, SlackSession session) {
        messageSender()
                .sendInfo("PONG",
                        "",
                        messagePosted.getChannel(),
                        session);
        return true;
    }

    @Override
    public String description() {
        return "Server replies with a pong";
    }

    @Override
    public String arguments() {
        return "[server-name (optional)] ping";
    }

    @Override
    public boolean acceptsArguments(List arguments) {
        Preconditions.checkNotNull(arguments);
        return arguments.size() == 0;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy