本文整理汇总了Java中org.telegram.telegrambots.api.methods.send.SendPhoto类的典型用法代码示例。如果您正苦于以下问题:Java SendPhoto类的具体用法?Java SendPhoto怎么用?Java SendPhoto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SendPhoto类属于org.telegram.telegrambots.api.methods.send包,在下文中一共展示了SendPhoto类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildPhotoMessage
import org.telegram.telegrambots.api.methods.send.SendPhoto; //导入依赖的package包/类
/**
* Build image response message
*
* @param post - 9GAG post with image
* @param chatId - chat id for response
* @return - completed response message
*/
private SendPhoto buildPhotoMessage(Post post, Long chatId) {
// TODO Fallback if LARGE not exists
SendPhoto message = new SendPhoto();
message.setChatId(chatId);
message.setCaption(post.getTitle());
message.setPhoto(post.getImageUrls().get(ImageType.LARGE));
message.setReplyMarkup(getKeyboard(post));
return message;
}
开发者ID:paramoshkinandrew,项目名称:ninegag-telegram-bot,代码行数:17,代码来源:ResponseBuilder.java
示例2: sendPhotoToChannel
import org.telegram.telegrambots.api.methods.send.SendPhoto; //导入依赖的package包/类
/**
*
* @param chatID
* @param photoPath
*/
public void sendPhotoToChannel(String chatID, String message, String photoPath) {
SendPhoto sendPhotoRequest = new SendPhoto();
sendPhotoRequest.setChatId(chatID);
sendPhotoRequest.setNewPhoto(new File(photoPath));
try {
sendPhoto(sendPhotoRequest);
sendMessageToChannel(chatID, message);
} catch (TelegramApiException ex) {
LOG.error("Error sending a photo", ex);
}
}
开发者ID:freedomotic,项目名称:freedomotic,代码行数:19,代码来源:FreedomoticBotHandlers.java
示例3: sendPhotoMessage
import org.telegram.telegrambots.api.methods.send.SendPhoto; //导入依赖的package包/类
private void sendPhotoMessage(long chatId, String id, String caption) throws TelegramApiException {
SendPhoto msg = new SendPhoto().setChatId(chatId).setPhoto(id).setCaption(caption);
sendPhoto(msg);
}
开发者ID:jesuino,项目名称:java-ml-projects,代码行数:5,代码来源:ClassifierBot.java
示例4: sendSongAndCover
import org.telegram.telegrambots.api.methods.send.SendPhoto; //导入依赖的package包/类
/**
* Отправляем песню и картинку песни
*/
void sendSongAndCover(final Message request, final Song song) throws TelegramApiException {
if (!TextUtils.isEmpty(song.getPoster())) {
// sendMessage(request.getChatId().toString(), "Вот фотокарточка");
// скачиваем (или берём с диска) картинку и отправляем
File cachedFile = FileUtils.getCachedFile(song.getPoster());
if (cachedFile == null) {
cachedFile =
FileUtils.writeResponseBodyToDisk(
resourcesService.downloadFile(song.getPoster()),
song.getPoster());
// if (cachedFile != null) {
// try {
// BufferedImage srcImage = ImageIO.read(cachedFile);
// ImageIO.write(
// Scalr.resize(srcImage, IMAGE_PARAM),
// "jpg",
// cachedFile);
// } catch (final IOException ioe) {
// LOGGER.error("Can't read and resize image " + cachedFile, ioe);
// }
// }
}
sendAction(request.getChatId().toString(), ActionType.UPLOADPHOTO);
SendPhoto sendPhoto = new SendPhoto();
sendPhoto.setChatId(request.getChatId().toString());
if (cachedFile == null) {
sendMessage(
request.getChatId().toString(),
"Что-то пошло не так со скачиванием картинки");
return;
}
sendPhoto.setNewPhoto(cachedFile);
getBot().sendPhoto(sendPhoto);
// sendMessage(request.getChatId().toString(), "Сейчас и песню пришлю");
} else {
if (Constants.SKIP_MUSIC) {
return;
}
sendMessage(request.getChatId().toString(), "Сейчас пришлю");
}
if (Constants.SKIP_MUSIC) {
return;
}
// скачиваем музло (или берём с диска) и отправляем
File cachedMusicFile = FileUtils.getCachedFile(song.getFileMp3());
if (cachedMusicFile == null) {
cachedMusicFile = FileUtils.writeResponseBodyToDisk(resourcesService.downloadFile(song.getFileMp3()), song.getFileMp3());
}
sendAction(request.getChatId().toString(), ActionType.UPLOADAUDIO);
SendAudio audio = new SendAudio();
if (cachedMusicFile == null) {
sendMessage(
request.getChatId().toString(),
"Что-то пошло не так со скачиванием музыки");
return;
}
audio.setNewAudio(cachedMusicFile);
// телеграм не ест кириллицу, транслитим транслитом
audio.setPerformer(Translit.cyr2lat(song.getPerformer()));
audio.setTitle(Translit.cyr2lat(song.getTrackName()));
audio.setChatId(request.getChatId().toString());
getBot().sendAudio(audio);
}
开发者ID:SammyVimes,项目名称:gopstopbot,代码行数:80,代码来源:BaseMuzisController.java
注:本文中的org.telegram.telegrambots.api.methods.send.SendPhoto类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论