Skip to content

Commit

Permalink
fix: 新增获取群列表
Browse files Browse the repository at this point in the history
  • Loading branch information
yusheng929 committed Sep 19, 2024
1 parent 2efe015 commit 70387d2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
11 changes: 7 additions & 4 deletions apps/Assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,11 @@ export const 发好友 = karin.command(/^#发好友/, async (e) => {
}, { name: '发好友', priority: '-1', permission: 'master' })
export const 获取群列表 = karin.command(/^#(查看|获取)群列表$/, async (e) => {
let group_list = await e.bot.GetGroupList()
let match = group_list.length
let msgs = []
for (const group_id of group_list) {
}
let msgs = []
let data = group_list.map((item, index) => `${index + 1}. ${item.group_name} (${item.group_id})`).join('\n')
msgs.push(segment.text(data))
msgs.push(segment.text("可使用 *#退群1234567890* 来退出群聊"))
msgs.unshift(segment.text(`群列表如下: 总共${group_list.length}个群`))
const msg = await common.makeForward(msgs, e.self_id, e.bot.account.name)
return await e.bot.sendForwardMessage(e.contact, msg)
}, { name: '获取群列表', priority: '-1', permission: 'master' })
17 changes: 15 additions & 2 deletions apps/测试(仅测试,无功能).js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import { karin, segment, common, Cfg, YamlEditor } from 'node-karin'
import { Config } from '#components'
export const test = karin.command(/^测试/, async (e) => {
let msg = await e.bot.GetGroupList()
console.log(msg)
let data = await e.bot.GetGroupList()

let msgs = []
let match = 1
console.log(msgs)
if (msgs.length === 0) console.log('1')
data.forEach(item => {
let group_id = item.group_id
let group_name = item.group_name
msgs[0].push(segment.text(`\n${match}.${group_name}(${group_id})`))
match++
})
const msg = await common.makeForward(msgs, e.self_id, e.bot.account.name)
return await e.bot.sendForwardMessage(e.contact, msg)

}, { name: '测试', priority: '-1' })

0 comments on commit 70387d2

Please sign in to comment.