Skip to content

Commit

Permalink
新增功能退群
Browse files Browse the repository at this point in the history
  • Loading branch information
yusheng929 committed Aug 5, 2024
1 parent db44def commit f8474f6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
29 changes: 29 additions & 0 deletions apps/BotAssistant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { karin, logger, segment, common } from 'node-karin'

/**
* 退群
*/
export const QuitGroup = karin.command(/^#?退/, async (e) => {
let groupId = e.msg.replace(/#?退/g, "").trim()

if (!groupId) return e.reply("群号不能为空")

if (!/^\d+$/.test(groupId)) return e.reply("请输入正确的群号")
const res = await e.bot.GetGroupInfo(groupId)
if (!res) {
await e.reply('\n你好像没加入这个群', { at: true })
return true
}
try {
if (groupId == e.group_id) {
await e.reply("3秒后退出本群聊")
await common.sleep(3000)
}
await e.bot.LeaveGroup(groupId)
e.reply(`已退出群聊『${groupId}』`)
} catch (error) {
await e.reply('\n错误: 未知原因❌', { at: true })
return true
}
return true
}, { name: "退群", priority: "-1" })
5 changes: 1 addition & 4 deletions apps/GroupAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,8 @@ export const kickMember = karin.command(/^#踢/, async (e) => {
}

if (res.role === 'admin') {
/** 需要是群主 */
if (info.role !== 'owner') {
await e.reply('\n这个人是管理员,少女做不到呜呜~(>_<)~', { at: true })
await e.reply('\n少女不能踢出管理员呜呜~(>_<)~', { at: true })
return true
}
}
} catch {
return e.reply('\n这个群好像没这个人', { at: true })
Expand Down

0 comments on commit f8474f6

Please sign in to comment.