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

com.antonioaltieri.telegram.botapi.requests.SendMessageRequest Maven / Gradle / Ivy

package com.antonioaltieri.telegram.botapi.requests;

import com.antonioaltieri.telegram.botapi.types.Message;

import java.util.HashMap;
import java.util.Map;

public final class SendMessageRequest implements ApiRequest {

    private Map args = new HashMap<>();

    public SendMessageRequest(long chatId, String text) {
        this(chatId, text, null);
    }

    public SendMessageRequest(String chatId, String text) {
        this(chatId, text, null);
    }

    public SendMessageRequest(long chatId, String text, OptionalArgs optionalArgs) {
        this(String.valueOf(chatId),text,optionalArgs);
    }

    public SendMessageRequest(String chatId, String text, OptionalArgs optionalArgs) {
        args.put("chat_id", chatId);
        args.put("text", text);

        if (optionalArgs != null)
            args.putAll(optionalArgs.options());
    }

    @Override
    public String getMethodName() {
        return "sendMessage";
    }

    @Override
    public ResultTypes getResultType() {
        return ResultTypes.MESSAGE;
    }

    @Override
    public Map getArgs() {
        return args;
    }

    @Override
    public RequestStrategy getRequestStrategy() {
        return new PostStrategy();
    }

    @Override
    public String toString() {
        return "SendMessageRequest{" +
                "args=" + args +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy