mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-29 22:27:31 +00:00
refactor(extension): 移除 ScalaBotExtension 类.
该类的作用不大, 实现的细节可以由开发者自行实现(或许会设计地更好), 故移除该类. DEPRECATED: 移除 ScalaBotExtension 类 由于该抽象类设计过于简单, 且并未达到其存在的预期目的(简化开发扩展的复杂性), 故移除本类. 开发者应将扩展类由继承 ScalaBotExtension 更改为实现 AbilityExtension 类, `getSender(): MessageSender` 和 `getDBContext():DBContext` 方法以及 `bot`(BaseAbilityBot) 字段应手动添加, 并根据需要通过构造方法获取并存储.
This commit is contained in:
parent
142eddfa28
commit
2b88134207
@ -1,32 +0,0 @@
|
|||||||
package net.lamgc.scalabot.extension;
|
|
||||||
|
|
||||||
import org.telegram.abilitybots.api.bot.BaseAbilityBot;
|
|
||||||
import org.telegram.abilitybots.api.db.DBContext;
|
|
||||||
import org.telegram.abilitybots.api.sender.MessageSender;
|
|
||||||
import org.telegram.abilitybots.api.util.AbilityExtension;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public abstract class ScalaBotExtension implements AbilityExtension {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 扩展所属的机器人对象.
|
|
||||||
*
|
|
||||||
* <p> 不要给该属性添加 Getter, 会被当成 Ability 添加, 导致出现异常.
|
|
||||||
*/
|
|
||||||
protected final BaseAbilityBot bot;
|
|
||||||
|
|
||||||
public ScalaBotExtension(BaseAbilityBot bot) {
|
|
||||||
this.bot = bot;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected MessageSender getSender() {
|
|
||||||
return bot.sender();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DBContext getDBContext() {
|
|
||||||
return bot.db();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user