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_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
|
||||||
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s
|
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
|
USE_DELTA = false
|
||||||
VERSION_DELTA =
|
VERSION_DELTA =
|
||||||
|
@ -18,6 +18,12 @@ public class Log {
|
|||||||
*/
|
*/
|
||||||
public static final Logger logger = new Logger(new ConsoleAppender());
|
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) {
|
public static String exceptionLog (Exception e) {
|
||||||
final StringWriter stackTrace = new StringWriter();
|
final StringWriter stackTrace = new StringWriter();
|
||||||
e.printStackTrace(new PrintWriter(stackTrace));
|
e.printStackTrace(new PrintWriter(stackTrace));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cc.sukazyo.cono.morny.bot.command;
|
package cc.sukazyo.cono.morny.bot.command;
|
||||||
|
|
||||||
|
import cc.sukazyo.cono.morny.data.TelegramStickers;
|
||||||
import cc.sukazyo.cono.morny.util.tgapi.InputCommand;
|
import cc.sukazyo.cono.morny.util.tgapi.InputCommand;
|
||||||
import com.pengrad.telegrambot.model.Update;
|
import com.pengrad.telegrambot.model.Update;
|
||||||
import com.pengrad.telegrambot.model.request.ParseMode;
|
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.MornyCoeur;
|
||||||
import cc.sukazyo.cono.morny.data.NbnhhshQuery;
|
import cc.sukazyo.cono.morny.data.NbnhhshQuery;
|
||||||
|
import com.pengrad.telegrambot.request.SendSticker;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -24,13 +26,17 @@ public class Nbnhhsh implements ITelegramCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void execute (@Nonnull InputCommand command, @Nonnull Update event) {
|
public void execute (@Nonnull InputCommand command, @Nonnull Update event) {
|
||||||
|
|
||||||
|
class TagNoContent extends Exception {}
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String queryTarget = "";
|
String queryTarget;
|
||||||
if (event.message().replyToMessage() != null && event.message().replyToMessage().text() != null)
|
if (event.message().replyToMessage() != null && event.message().replyToMessage().text() != null)
|
||||||
queryTarget = event.message().replyToMessage().text();
|
queryTarget = event.message().replyToMessage().text();
|
||||||
if (command.hasArgs())
|
else if (command.hasArgs())
|
||||||
queryTarget = stringsConnecting(command.getArgs(), " ", 0, command.getArgs().length-1);
|
queryTarget = stringsConnecting(command.getArgs(), " ", 0, command.getArgs().length-1);
|
||||||
|
else {
|
||||||
|
throw new TagNoContent();
|
||||||
|
}
|
||||||
|
|
||||||
NbnhhshQuery.GuessResult response = NbnhhshQuery.sendGuess(queryTarget);
|
NbnhhshQuery.GuessResult response = NbnhhshQuery.sendGuess(queryTarget);
|
||||||
|
|
||||||
@ -58,6 +64,10 @@ public class Nbnhhsh implements ITelegramCommand {
|
|||||||
message.toString()
|
message.toString()
|
||||||
).parseMode(ParseMode.HTML).replyToMessageId(event.message().messageId()));
|
).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) {
|
} catch (Exception e) {
|
||||||
MornyCoeur.extra().exec(new SendMessage(
|
MornyCoeur.extra().exec(new SendMessage(
|
||||||
event.message().chat().id(),
|
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