Skip to content

Commit

Permalink
fix: callme
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-fish committed Apr 23, 2024
1 parent 718cc8c commit a54526f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/plugins/callme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class PatchCallme extends BasePlugin {
ctx
.command('callme', '', { minInterval: Time.hour, maxUsage: 5 })
.channelFields(['disable'])
.userFields(['name'])
.userFields(['name', 'id'])
.check(({ session, options }, name) => {
if (
session!.channel?.disable?.includes('callme') ||
Expand All @@ -35,7 +35,7 @@ export default class PatchCallme extends BasePlugin {
return
}
if (!name) {
const escapedName = segment.escape(session!.user.name)
const escapedName = segment.escape(session?.user?.name || '')
return session!.user?.name ? (
<random>
<template>SILI认得你,{escapedName},你好~</template>
Expand Down Expand Up @@ -82,5 +82,22 @@ export default class PatchCallme extends BasePlugin {
)
}
})
.check(async ({ session }, name) => {
if (!name) return
const existUser = await session.app.database.get('user', { name })
if (
existUser.length &&
existUser.some((user) => user.id !== session.user.id)
) {
return (
<>
<random>
<template>这个名字已经被占用了哟~</template>
<template>这个名字已经有人用过了~</template>
</random>
</>
)
}
})
}
}

0 comments on commit a54526f

Please sign in to comment.