com.antonioaltieri.telegram.botapi.requests.SendVoiceRequest Maven / Gradle / Ivy
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 SendVoiceRequest implements ApiRequest {
private Map args = new HashMap<>();
private RequestStrategy requestStrategy;
public SendVoiceRequest(int chatId, File voiceFile) {
this(chatId, voiceFile, null);
}
public SendVoiceRequest(int chatId, File voiceFile, com.antonioaltieri.telegram.botapi.requests.OptionalArgs optionalArgs) {
args.put("chat_id", String.valueOf(chatId));
if (optionalArgs != null)
args.putAll(optionalArgs.options());
requestStrategy = new MultipartStrategy(voiceFile, "voice");
}
public SendVoiceRequest(int chatId, String voiceString) {
this(chatId, voiceString, null);
}
public SendVoiceRequest(int chatId, String voiceString, OptionalArgs optionalArgs) {
args.put("chat_id", String.valueOf(chatId));
args.put("voice", voiceString);
if (optionalArgs != null)
args.putAll(optionalArgs.options());
requestStrategy = new PostStrategy();
}
@Override
public String getMethodName() {
return "sendVoice";
}
@Override
public ResultTypes getResultType() {
return ResultTypes.MESSAGE;
}
@Override
public Map getArgs() {
return args;
}
@Override
public RequestStrategy getRequestStrategy() {
return requestStrategy;
}
@Override
public String toString() {
return "SendVoiceRequest{" +
"args=" + args +
", requestStrategy=" + requestStrategy +
'}';
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy