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

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

There is a newer version: 1.3.7
Show newest version
package com.antonioaltieri.telegram.botapi.requests;

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

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class SendAudioRequest implements ApiRequest {

    private Map args = new HashMap<>();
    private RequestStrategy requestStrategy;

    public SendAudioRequest(int chatId, File audioFile) {
        this(chatId, audioFile, null);
    }

    public SendAudioRequest(int chatId, File audioFile, com.antonioaltieri.telegram.botapi.requests.OptionalArgs optionalArgs) {
        args.put("chat_id", String.valueOf(chatId));

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

        requestStrategy = new MultipartStrategy(audioFile, "audio");
    }

    public SendAudioRequest(int chatId, String audioString) {
        this(chatId, audioString, null);
    }

    public SendAudioRequest(int chatId, String audioString, OptionalArgs optionalArgs) {
        args.put("chat_id", String.valueOf(chatId));
        args.put("audio", audioString);

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

        requestStrategy = new PostStrategy();
    }

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

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

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

    @Override
    public RequestStrategy getRequestStrategy() {
        return requestStrategy;
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy