Skip to content

Commit

Permalink
0.1.4测试发布
Browse files Browse the repository at this point in the history
  • Loading branch information
Ceale committed Oct 16, 2024
1 parent 8bd82af commit e6130a0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shirosaki-onebot",
"version": "0.1.3",
"version": "0.1.4",
"description": "极简OneBot v11框架",
"type": "module",
"main": "lib/index.cjs",
Expand All @@ -10,18 +10,20 @@
],
"exports": {
".": {
"import": "./lib/index.cjs",
"import": "./lib/index.mjs",
"require": "./lib/index.cjs",
"types": "./lib/index.d.ts"
},
"./package.json": "./package.json"
},
"scripts": {
"test": "tsc",
"build": "unbuild"
"build": "unbuild --minify"
},
"unbuild": {
"outDir": "lib"
"name": "shirosaki-onebot",
"outDir": "lib",
"clean": true
},
"author": "筱莱Ceale",
"license": "Apache-2.0",
Expand Down
12 changes: 6 additions & 6 deletions src/Bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ declare global {
includes(value: any): boolean
}
}

const logger = new Logger("bot")

export type EventCallback<EventData> = (eventData: EventData) => void

export enum EventType {
Message = "message",
Expand Down Expand Up @@ -46,7 +46,7 @@ export enum EventType {

// }

export class OneBot {
export class Bot {
private options: {
url: string,
debug: boolean
Expand Down Expand Up @@ -144,9 +144,9 @@ export class OneBot {
})
}

private eventListenerList = new Map<EventType, Set<EventCallback<any>>>()
private eventListenerList = new Map<EventType, Set<(event: any) => void>>()

public onEvent(eventType: EventType, callback: EventCallback<any>/*, options: EventOptions*/) {
public onEvent(eventType: EventType, callback: (event: any) => void/*, options: EventOptions*/) {
let listenerList = this.eventListenerList.get(eventType)
listenerList!.add(callback)
}
Expand All @@ -166,7 +166,7 @@ export class OneBot {
}
}

public offEvent(eventType: EventType, callback: EventCallback<any>) {
public offEvent(eventType: EventType, callback: (event: any) => void) {
let listenerList = this.eventListenerList.get(eventType)
listenerList!.delete(callback)
}
Expand Down Expand Up @@ -222,7 +222,7 @@ export class OneBot {

public sessionList = new Set<Source>()

public onMessage(callback: EventCallback<MessageEvent>, options?: {
public onMessage(callback: (event: MessageEvent) => void, options?: {
once?: boolean,
at?: boolean,
type?: SouceType,
Expand Down
8 changes: 4 additions & 4 deletions src/MessageEvent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OneBot, EventType } from "./Bot"
import { Bot, EventType } from "./Bot"
import { Message } from "./Message"


Expand Down Expand Up @@ -91,7 +91,7 @@ export class MessageEvent {

public session: Session

constructor(event: any, bot: OneBot) {
constructor(event: any, bot: Bot) {
this.timestamp = event.timestamp
this.source = new Source(event.message_type, event.user_id, event.group_id)

Expand All @@ -105,11 +105,11 @@ export class MessageEvent {

export class Session {

private bot: OneBot
private bot: Bot
private source: Source
private target: Target

constructor(souce: Source, bot: OneBot) {
constructor(souce: Source, bot: Bot) {
this.bot = bot
this.source = souce
this.target = new Target(this.source)
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export * from "./Bot"
export * from "./Message"
export * from "./MessageSegment"
export * from "./ModuleLoader"
export * as Util from "./Util"
export * from "./Util"

0 comments on commit e6130a0

Please sign in to comment.