use of org.telegram.telegrambots.api.methods.send.SendMessage in project webofneeds by researchstudio-sat.
the class TelegramMessageGenerator method getHintMessage.
public SendMessage getHintMessage(Long chatId, URI remoteNeedUri, URI yourNeedUri) {
Dataset remoteNeedRDF = eventListenerContext.getLinkedDataSource().getDataForResource(remoteNeedUri);
DefaultNeedModelWrapper needModelWrapper = new DefaultNeedModelWrapper(remoteNeedRDF);
String title = needModelWrapper.getSomeTitleFromIsOrAll("en", "de");
String description = needModelWrapper.getSomeDescription(NeedContentPropertyType.ALL, "en", "de");
SendMessage sendMessage = new SendMessage();
sendMessage.setChatId(chatId);
String text = "<b>We found a Match for you!\n\n</b><a href='" + remoteNeedUri + "'>" + title + "\n\n</a>";
if (description != null) {
text = text + "<em>" + description + "</em>";
}
sendMessage.setText(text);
sendMessage.setReplyMarkup(getConnectionActionKeyboard("Request", "Close"));
sendMessage.enableHtml(true);
return sendMessage;
}
use of org.telegram.telegrambots.api.methods.send.SendMessage in project webofneeds by researchstudio-sat.
the class TelegramMessageGenerator method getCreatedNeedMessage.
public SendMessage getCreatedNeedMessage(Long chatId, URI needURI) {
Dataset createdNeedRDF = eventListenerContext.getLinkedDataSource().getDataForResource(needURI);
DefaultNeedModelWrapper needModelWrapper = new DefaultNeedModelWrapper(createdNeedRDF);
String title = needModelWrapper.getSomeTitleFromIsOrAll("en", "de");
String description = needModelWrapper.getSomeDescription(NeedContentPropertyType.ALL, "en", "de");
SendMessage sendMessage = new SendMessage();
sendMessage.setChatId(chatId);
String text = "<b>We created a Need for you!\n\n</b><a href='" + needURI + "'>" + title + "\n\n</a>";
if (description != null) {
text = text + "<em>" + description + "</em>";
}
sendMessage.setText(text);
sendMessage.enableHtml(true);
return sendMessage;
}
use of org.telegram.telegrambots.api.methods.send.SendMessage in project webofneeds by researchstudio-sat.
the class TelegramMessageGenerator method getConnectionTextMessage.
public SendMessage getConnectionTextMessage(Long chatId, URI remoteNeedUri, URI yourNeedUri, WonMessage message) {
SendMessage sendMessage = new SendMessage();
sendMessage.setChatId(chatId);
sendMessage.setText("<a href='" + remoteNeedUri + "'>URI</a>: " + extractTextMessageFromWonMessage(message));
sendMessage.enableHtml(true);
return sendMessage;
}
use of org.telegram.telegrambots.api.methods.send.SendMessage in project telegram-notifications-plugin by jenkinsci.
the class StatusCommand method execute.
@Override
public void execute(AbsSender absSender, User user, Chat chat, String[] strings) {
Subscribers subscribers = Subscribers.getInstance();
String toSend;
Long id = chat.getId();
boolean isSubscribed = subscribers.isSubscribed(id);
if (isSubscribed) {
boolean isApproved = subscribers.isApproved(id);
if (GlobalConfiguration.getInstance().getApprovalType() == UserApprover.ApprovalType.ALL) {
toSend = botStrings.get("message.status.approved");
} else {
toSend = isApproved ? botStrings.get("message.status.approved") : botStrings.get("message.status.unapproved");
}
} else {
toSend = botStrings.get("message.status.unsubscribed");
}
SendMessage answer = new SendMessage();
answer.setChatId(chat.getId().toString());
answer.setText(toSend);
try {
absSender.execute(answer);
} catch (TelegramApiException e) {
BotLogger.error(LOG_TAG, e);
}
}
use of org.telegram.telegrambots.api.methods.send.SendMessage in project telegram-notifications-plugin by jenkinsci.
the class SubCommand method execute.
@Override
public void execute(AbsSender absSender, User user, Chat chat, String[] strings) {
Subscribers subscribers = Subscribers.getInstance();
String ans;
Long id = chat.getId();
String name = chat.isUserChat() ? user.getUserName() : chat.getTitle();
boolean isSubscribed = subscribers.isSubscribed(id);
if (!isSubscribed) {
subscribers.subscribe(name, id);
ans = botStrings.get("message.sub.success");
} else {
ans = botStrings.get("message.sub.alreadysub");
}
SendMessage answer = new SendMessage();
answer.setChatId(chat.getId().toString());
answer.setText(ans);
try {
absSender.execute(answer);
} catch (TelegramApiException e) {
BotLogger.error(LOG_TAG, e);
}
}
Aggregations