unit tests, insert videos

This commit is contained in:
MrBesen 2020-05-05 17:18:48 +02:00 committed by mrbesen
parent aee04b5a13
commit 225faa948d
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 11 additions and 9 deletions

View File

@ -87,15 +87,11 @@ public class TelegramAPI implements Runnable {
* @param apikey * @param apikey
*/ */
public TelegramAPI(String apikey) { public TelegramAPI(String apikey) {
botname = ""; this(apikey, "");
if (!apikey.matches(TOKENREGEX) ) {
throw new IllegalArgumentException("Invalid API key: " + apikey);
}
this.apikey = apikey;
} }
public TelegramAPI(String apikey, String botname) { public TelegramAPI(String apikey, String botname) {
this.botname = botname; this.botname = botname != null ? botname : "";
if (!apikey.matches(TOKENREGEX) ) { if (!apikey.matches(TOKENREGEX) ) {
throw new IllegalArgumentException("Invalid API key: " + apikey); throw new IllegalArgumentException("Invalid API key: " + apikey);
@ -505,8 +501,10 @@ public class TelegramAPI implements Runnable {
} else { } else {
e = new UserSendMessageEvent(getMsg()); e = new UserSendMessageEvent(getMsg());
//call feedback cmd first //call feedback cmd first
if(feedbackCmd.onMsg((UserSendMessageEvent) e)) { if(!disableFeedback) {
e = null; if (feedbackCmd.onMsg((UserSendMessageEvent) e)) {
e = null;
}
} }
} }
getEventManager().callEvent(e); getEventManager().callEvent(e);
@ -520,8 +518,12 @@ public class TelegramAPI implements Runnable {
TMessage msg = new TMessage(cbq.getJSONObject("message"), api); TMessage msg = new TMessage(cbq.getJSONObject("message"), api);
UserCallbackEvent event = new UserCallbackEvent(from, data, id, msg); UserCallbackEvent event = new UserCallbackEvent(from, data, id, msg);
if(!feedbackCmd.onCallback(event)) if(!disableFeedback) {
if (!feedbackCmd.onCallback(event))
getEventManager().callEvent(event);
} else {
getEventManager().callEvent(event); getEventManager().callEvent(event);
}
} }
} }