Skip to content

Commit

Permalink
Merge pull request #38 from rubenlagus/dev
Browse files Browse the repository at this point in the history
Merge Dev
  • Loading branch information
rubenlagus committed Apr 17, 2016
2 parents 118ced4 + fbae731 commit 3f2c0e2
Show file tree
Hide file tree
Showing 69 changed files with 1,121 additions and 1,029 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ I recommend using getUpdates methods.

## Usage

Just import add the library to your project using [Maven, Gradly, ...](https://jitpack.io/#rubenlagus/TelegramBots/v2.0.2) or download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v2.0.2)
Just import add the library to your project using [Maven, Gradly, ...](https://jitpack.io/#rubenlagus/TelegramBots/v2.1) or download the jar(including all dependencies) from [here](https://github.com/rubenlagus/TelegramBots/releases/tag/v2.1)

In order to use Long Polling mode, just create your own bot extending `org.telegram.telegrambots.bots.TelegramLongPollingBot`.

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<packaging>jar</packaging>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>2.0.2</version>
<version>2.1</version>

<name>Telegram Bots</name>
<description>Easy to use library to create Telegram Bots</description>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/telegram/telegrambots/TelegramBotsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.telegram.telegrambots.api.methods.updates.SetWebhook;
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import org.telegram.telegrambots.bots.TelegramWebhookBot;
import org.telegram.telegrambots.updatesreceivers.UpdatesThread;
import org.telegram.telegrambots.updatesreceivers.BotSession;
import org.telegram.telegrambots.updatesreceivers.Webhook;

import java.io.File;
Expand Down Expand Up @@ -122,12 +122,12 @@ private static void setWebhook(String webHookURL, String botToken, String public
}

/**
*
* Register a bot. The Bot Session is started immediately, and may be disconnected by calling close.
* @param bot
*/
public void registerBot(TelegramLongPollingBot bot) throws TelegramApiException {
public BotSession registerBot(TelegramLongPollingBot bot) throws TelegramApiException {
setWebhook(bot.getBotToken());
new UpdatesThread(bot.getBotToken(), bot);
return new BotSession(bot.getBotToken(), bot);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.telegram.telegrambots.api.methods;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
Expand All @@ -24,15 +25,42 @@ public class AnswerCallbackQuery extends BotApiMethod<Boolean> {
private static final String TEXT_FIELD = "text";
private static final String SHOWALERT_FIELD = "show_alert";

@JsonProperty(CALLBACKQUERYID_FIELD)
private String callbackQueryId; ///< Unique identifier for the query to be answered
@JsonProperty(TEXT_FIELD)
private String text; ///< Text of the notification. If not specified, nothing will be shown to the user
@JsonProperty(SHOWALERT_FIELD)
private Boolean showAlert; ///< Optional. If true, an alert will be shown by the client instead of a notificaiton at the top of the chat screen. Defaults to false.


public AnswerCallbackQuery() {
super();
}

public String getCallbackQueryId() {
return this.callbackQueryId;
}

public void setCallbackQueryId(String callbackQueryId) {
this.callbackQueryId = callbackQueryId;
}

public String getText() {
return this.text;
}

public void setText(String text) {
this.text = text;
}

public Boolean getShowAlert() {
return this.showAlert;
}

public void setShowAlert(Boolean showAlert) {
this.showAlert = showAlert;
}

@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,56 +44,63 @@ public String getInlineQueryId() {
return inlineQueryId;
}

public void setInlineQueryId(String inlineQueryId) {
public AnswerInlineQuery setInlineQueryId(String inlineQueryId) {
this.inlineQueryId = inlineQueryId;
return this;
}

public List<InlineQueryResult> getResults() {
return results;
}

public void setResults(List<InlineQueryResult> results) {
public AnswerInlineQuery setResults(List<InlineQueryResult> results) {
this.results = results;
return this;
}

public Integer getCacheTime() {
return cacheTime;
}

public void setCacheTime(Integer cacheTime) {
public AnswerInlineQuery setCacheTime(Integer cacheTime) {
this.cacheTime = cacheTime;
return this;
}

public Boolean getPersonal() {
return isPersonal;
}

public void setPersonal(Boolean personal) {
public AnswerInlineQuery setPersonal(Boolean personal) {
isPersonal = personal;
return this;
}

public String getNextOffset() {
return nextOffset;
}

public void setNextOffset(String nextOffset) {
public AnswerInlineQuery setNextOffset(String nextOffset) {
this.nextOffset = nextOffset;
return this;
}

public String getSwitchPmText() {
return switchPmText;
}

public void setSwitchPmText(String switchPmText) {
public AnswerInlineQuery setSwitchPmText(String switchPmText) {
this.switchPmText = switchPmText;
return this;
}

public String getSwitchPmParameter() {
return switchPmParameter;
}

public void setSwitchPmParameter(String switchPmParameter) {
public AnswerInlineQuery setSwitchPmParameter(String switchPmParameter) {
this.switchPmParameter = switchPmParameter;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,27 @@ public String getChatId() {
return chatId;
}

public void setChatId(String chatId) {
public ForwardMessage setChatId(String chatId) {
this.chatId = chatId;
return this;
}

public Integer getFromChatId() {
return fromChatId;
}

public void setFromChatId(Integer fromChatId) {
public ForwardMessage setFromChatId(Integer fromChatId) {
this.fromChatId = fromChatId;
return this;
}

public Integer getMessageId() {
return messageId;
}

public void setMessageId(Integer messageId) {
public ForwardMessage setMessageId(Integer messageId) {
this.messageId = messageId;
return this;
}

public Boolean getDisableNotification() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public String getFileId() {
return fileId;
}

public void setFileId(String fileId) {
public GetFile setFileId(String fileId) {
this.fileId = fileId;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,29 @@ public Integer getUserId() {
return userId;
}

public void setUserId(Integer userId) {
public GetUserProfilePhotos setUserId(Integer userId) {
this.userId = userId;
return this;
}

public Integer getOffset() {
return offset;
}

public void setOffset(Integer offset) {
public GetUserProfilePhotos setOffset(Integer offset) {
this.offset = offset;
return this;
}

public Integer getLimit() {
return limit;
}

public void setLimit(Integer limit) {
public GetUserProfilePhotos setLimit(Integer limit) {
this.limit = limit;
return this;
}

@Override
public JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ public String getChatId() {
return chatId;
}

public void setChatId(String chatId) {
public KickChatMember setChatId(String chatId) {
this.chatId = chatId;
return this;
}

public Integer getUserId() {
return userId;
}

public void setUserId(Integer userId) {
public KickChatMember setUserId(Integer userId) {
this.userId = userId;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ public String getChatId() {
return chatId;
}

public void setChatId(String chatId) {
public UnbanChatMember setChatId(String chatId) {
this.chatId = chatId;
return this;
}

public Integer getUserId() {
return userId;
}

public void setUserId(Integer userId) {
public UnbanChatMember setUserId(Integer userId) {
this.userId = userId;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ public Integer getDuration() {
return this.duration;
}

public void setDuration(Integer duration) {
public SendAudio setDuration(Integer duration) {
this.duration = duration;
return this;
}

public String getChatId() {
return chatId;
}

public void setChatId(String chatId) {
public SendAudio setChatId(String chatId) {
this.chatId = chatId;
return this;
}

public String getAudio() {
Expand All @@ -69,9 +71,10 @@ public String getAudio() {
* @param audio File_id of the audio to send
* @note The file_id must have already been received or sent by your bot
*/
public void setAudio(String audio) {
public SendAudio setAudio(String audio) {
this.audio = audio;
this.isNewAudio = false;
return this;
}

/**
Expand All @@ -80,54 +83,61 @@ public void setAudio(String audio) {
* @param audio Path to the new file in your server
* @param audioName Name of the file itself
*/
public void setNewAudio(String audio, String audioName) {
public SendAudio setNewAudio(String audio, String audioName) {
this.audio = audio;
this.isNewAudio = true;
this.audioName = audioName;
return this;
}

public Integer getReplayToMessageId() {
return replayToMessageId;
}

public void setReplayToMessageId(Integer replayToMessageId) {
public SendAudio setReplayToMessageId(Integer replayToMessageId) {
this.replayToMessageId = replayToMessageId;
return this;
}

public ReplyKeyboard getReplayMarkup() {
return replayMarkup;
}

public void setReplayMarkup(ReplyKeyboard replayMarkup) {
public SendAudio setReplayMarkup(ReplyKeyboard replayMarkup) {
this.replayMarkup = replayMarkup;
return this;
}

public String getPerformer() {
return performer;
}

public void setPerformer(String performer) {
public SendAudio setPerformer(String performer) {
this.performer = performer;
return this;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
public SendAudio setTitle(String title) {
this.title = title;
return this;
}

public Boolean getDisableNotification() {
return disableNotification;
}

public void enableNotification() {
public SendAudio enableNotification() {
this.disableNotification = false;
return this;
}

public void disableNotification() {
public SendAudio disableNotification() {
this.disableNotification = true;
return this;
}

public boolean isNewAudio() {
Expand Down
Loading

0 comments on commit 3f2c0e2

Please sign in to comment.