-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #635 from NapNeko/ref/ob-network
refactor: adjust onebot network
- Loading branch information
Showing
10 changed files
with
108 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { NetworkConfigAdapter } from "@/onebot/config/config"; | ||
import { LogWrapper } from "@/common/log"; | ||
import { NapCatCore } from "@/core"; | ||
import { NapCatOneBot11Adapter } from "@/onebot"; | ||
import { ActionMap } from "@/onebot/action"; | ||
import { OB11EmitEventContent, OB11NetworkReloadType } from "@/onebot/network/index"; | ||
|
||
export abstract class IOB11NetworkAdapter<CT extends NetworkConfigAdapter> { | ||
name: string; | ||
isEnable: boolean = false; | ||
config: CT; | ||
readonly logger: LogWrapper; | ||
readonly core: NapCatCore; | ||
readonly obContext: NapCatOneBot11Adapter; | ||
readonly actions: ActionMap; | ||
|
||
constructor(name: string, config: CT, core: NapCatCore, obContext: NapCatOneBot11Adapter, actions: ActionMap) { | ||
this.name = name; | ||
this.config = structuredClone(config); | ||
this.core = core; | ||
this.obContext = obContext; | ||
this.actions = actions; | ||
this.logger = core.context.logger; | ||
} | ||
|
||
abstract onEvent<T extends OB11EmitEventContent>(event: T): void; | ||
|
||
abstract open(): void | Promise<void>; | ||
|
||
abstract close(): void | Promise<void>; | ||
|
||
abstract reload(config: any): OB11NetworkReloadType | Promise<OB11NetworkReloadType>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.