mirror of
				https://github.com/LamGC/ScalaBot.git
				synced 2025-10-31 16:46:54 +00:00 
			
		
		
		
	fix(example): 修复 Reply 判断条件不充分的问题.
由于条件判断不充分, 导致运行时可能会出现 NPE 的问题.
This commit is contained in:
		| @ -37,11 +37,16 @@ public class SayHelloExtension implements AbilityExtension { | ||||
|      */ | ||||
|     public Ability test() { | ||||
|         ReplyFlow botHello = ReplyFlow.builder(bot.db()) | ||||
|                 .enableStats("say_hello") | ||||
|                 .action((bot, upd) -> bot.silent().send("What is u name?", upd.getMessage().getChatId())) | ||||
|                 .onlyIf(update -> "hello".equalsIgnoreCase(update.getMessage().getText())) | ||||
|                 .onlyIf(update -> update.hasMessage() | ||||
|                         && update.getMessage().hasText() | ||||
|                         && "hello".equalsIgnoreCase(update.getMessage().getText())) | ||||
|                 .next(Reply.of((bot, upd) -> bot.silent() | ||||
|                                 .send("OK! You name is " + upd.getMessage().getText().substring("my name is ".length()), upd.getMessage().getChatId()), | ||||
|                         upd -> upd.getMessage().getText().startsWith("my name is "))) | ||||
|                         upd -> upd.hasMessage() | ||||
|                                 && upd.getMessage().hasText() | ||||
|                                 && upd.getMessage().getText().startsWith("my name is "))) | ||||
|                 .build(); | ||||
|  | ||||
|         return Ability.builder() | ||||
|  | ||||
		Reference in New Issue
	
	Block a user