Skip to content

Commit

Permalink
修复source错误拼写为souce
Browse files Browse the repository at this point in the history
  • Loading branch information
Ceale committed Oct 16, 2024
1 parent 6e24c16 commit 8130d3b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shirosaki-onebot",
"version": "0.1.7",
"version": "0.1.8",
"description": "极简OneBot v11框架",
"type": "module",
"main": "lib/index.cjs",
Expand Down
10 changes: 5 additions & 5 deletions src/Bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { generateRandomHex, wait } from "./Util"
import { Message } from "./Message"
import { At, MessageSegmentType, Text } from "./MessageSegment"
import { error, log } from "node:console"
import { Target, SouceType, Source, MessageEvent } from "./MessageEvent"
import { Target, SourceType, Source, MessageEvent } from "./MessageEvent"

declare global {
interface Array<T> {
Expand Down Expand Up @@ -207,7 +207,7 @@ export class Bot {
}
return message
})()
if (target.type === SouceType.Group) {
if (target.type === SourceType.Group) {
return (await this.callApi("send_group_msg", {
group_id: target.groupId,
message: message.toJSON()
Expand All @@ -225,7 +225,7 @@ export class Bot {
public onMessage(callback: (event: MessageEvent) => void, options?: {
once?: boolean,
at?: boolean,
type?: SouceType,
type?: SourceType,
filter?: {
groupId?: number[],
userId?: number[]
Expand All @@ -234,8 +234,8 @@ export class Bot {
const handle = (eventData: any) => {
const messageEvent = new MessageEvent(eventData, this)

for (const souce of this.sessionList) {
if (messageEvent.source.equals(souce)) return
for (const source of this.sessionList) {
if (messageEvent.source.equals(source)) return
}

// 实现options: at
Expand Down
36 changes: 18 additions & 18 deletions src/MessageEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@ export class Sender {
}
}

export enum SouceType {
export enum SourceType {
Group = "group",
Private = "private"
}

export class Target {
type: SouceType
type: SourceType
userId: number | undefined = undefined;
groupId: number | undefined = undefined;

constructor(souce: Source)
constructor(type: SouceType, id: number)
constructor(source: Source)
constructor(type: SourceType, id: number)
constructor(...args: any[]) {
if (args.length === 1) {
const souce: Source = args[0]
this.type = souce.type
this.groupId = souce.groupId
this.userId = souce.userId
const source: Source = args[0]
this.type = source.type
this.groupId = source.groupId
this.userId = source.userId
} else {
const type: SouceType = args[0]
const type: SourceType = args[0]
const id: number = args[1]
this.type = type
if (type === SouceType.Group) {
if (type === SourceType.Group) {
this.groupId = id
} else {
this.userId = id
Expand All @@ -61,20 +61,20 @@ export class Target {
}

export class Source {
type: SouceType
type: SourceType
groupId?: number
userId: number

constructor(type: SouceType, userId: number, groupId?: number) {
constructor(type: SourceType, userId: number, groupId?: number) {
this.type = type
this.userId = userId
this.groupId = groupId
}

equals(souce: Source) {
if (souce.type !== this.type
|| souce.userId !== this.userId
|| souce.groupId !== this.groupId) return false
equals(source: Source) {
if (source.type !== this.type
|| source.userId !== this.userId
|| source.groupId !== this.groupId) return false
return true
}
}
Expand Down Expand Up @@ -109,9 +109,9 @@ export class Session {
private source: Source
private target: Target

constructor(souce: Source, bot: Bot) {
constructor(source: Source, bot: Bot) {
this.bot = bot
this.source = souce
this.source = source
this.target = new Target(this.source)
}

Expand Down

0 comments on commit 8130d3b

Please sign in to comment.