mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-22 19:24:53 +08:00
/nbnhhsh will send 404 while no content, add some javadoc
This commit is contained in:
parent
031a799070
commit
f990df70ea
@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur
|
||||
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
|
||||
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s
|
||||
|
||||
VERSION = 1.0.0-RC3.3
|
||||
VERSION = 1.0.0-RC3.4
|
||||
|
||||
USE_DELTA = false
|
||||
VERSION_DELTA =
|
||||
|
@ -18,6 +18,12 @@ public class Log {
|
||||
*/
|
||||
public static final Logger logger = new Logger(new ConsoleAppender());
|
||||
|
||||
/**
|
||||
* 获取异常的堆栈信息.
|
||||
* @param e 异常体
|
||||
* @return {@link String} 格式的异常的堆栈报告信息.
|
||||
* @see 1.0.0-alpha5
|
||||
*/
|
||||
public static String exceptionLog (Exception e) {
|
||||
final StringWriter stackTrace = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(stackTrace));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cc.sukazyo.cono.morny.bot.command;
|
||||
|
||||
import cc.sukazyo.cono.morny.data.TelegramStickers;
|
||||
import cc.sukazyo.cono.morny.util.tgapi.InputCommand;
|
||||
import com.pengrad.telegrambot.model.Update;
|
||||
import com.pengrad.telegrambot.model.request.ParseMode;
|
||||
@ -7,6 +8,7 @@ import com.pengrad.telegrambot.request.SendMessage;
|
||||
|
||||
import cc.sukazyo.cono.morny.MornyCoeur;
|
||||
import cc.sukazyo.cono.morny.data.NbnhhshQuery;
|
||||
import com.pengrad.telegrambot.request.SendSticker;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@ -24,13 +26,17 @@ public class Nbnhhsh implements ITelegramCommand {
|
||||
@Override
|
||||
public void execute (@Nonnull InputCommand command, @Nonnull Update event) {
|
||||
|
||||
class TagNoContent extends Exception {}
|
||||
try {
|
||||
|
||||
String queryTarget = "";
|
||||
String queryTarget;
|
||||
if (event.message().replyToMessage() != null && event.message().replyToMessage().text() != null)
|
||||
queryTarget = event.message().replyToMessage().text();
|
||||
if (command.hasArgs())
|
||||
else if (command.hasArgs())
|
||||
queryTarget = stringsConnecting(command.getArgs(), " ", 0, command.getArgs().length-1);
|
||||
else {
|
||||
throw new TagNoContent();
|
||||
}
|
||||
|
||||
NbnhhshQuery.GuessResult response = NbnhhshQuery.sendGuess(queryTarget);
|
||||
|
||||
@ -58,6 +64,10 @@ public class Nbnhhsh implements ITelegramCommand {
|
||||
message.toString()
|
||||
).parseMode(ParseMode.HTML).replyToMessageId(event.message().messageId()));
|
||||
|
||||
} catch (TagNoContent tag) {
|
||||
MornyCoeur.extra().exec(new SendSticker(
|
||||
event.message().chat().id(), TelegramStickers.ID_404
|
||||
).replyToMessageId(event.message().messageId()));
|
||||
} catch (Exception e) {
|
||||
MornyCoeur.extra().exec(new SendMessage(
|
||||
event.message().chat().id(),
|
||||
|
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* 一系列的 telegram bot 命令的声明.
|
||||
* <p>
|
||||
* 命令将在 {@link cc.sukazyo.cono.morny.bot.command.MornyCommands} 当中实例化并注册管理,并通过事件
|
||||
* {@link cc.sukazyo.cono.morny.bot.event.OnTelegramCommand} 调用.
|
||||
*/
|
||||
package cc.sukazyo.cono.morny.bot.command;
|
Loading…
Reference in New Issue
Block a user