1.0.42 • Published 2 months ago

qq-group-bot v1.0.42

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

qq-group-bot

qq group

安装依赖

npm i qq-group-bot # or yarn add qq-group-bot

使用

const {Bot} = require('qq-group-bot')
// 创建机器人
const bot = new Bot({
	appid: '', // qq机器人的appID (必填)
	secret: '', // qq机器人的secret (必填)
	sandbox: true, // 是否是沙箱环境 默认 false
	removeAt: true, // 移除第一个at 默认 false
	logLevel: 'info', // 日志等级 默认 info
	maxRetry: 10, // 最大重连次数 默认 10
	intents: [
		'GROUP_AT_MESSAGE_CREATE', // 群聊@消息事件 没有群权限请注释
		'C2C_MESSAGE_CREATE', // 私聊事件 没有私聊权限请注释
		'GUILD_MESSAGES', // 私域机器人频道消息事件 公域机器人请注释
		'PUBLIC_GUILD_MESSAGES', // 公域机器人频道消息事件 私域机器人请注释
		'DIRECT_MESSAGE', // 频道私信事件
		'GUILD_MESSAGE_REACTIONS', // 频道消息表态事件
		'GUILDS', // 频道变更事件
		'GUILD_MEMBERS', // 频道成员变更事件
		'DIRECT_MESSAGE', // 频道私信事件
	], // (必填)
})
// 启动机器人
bot.start()

发送消息

const {Bot} = require('qq-group-bot')
const bot = new Bot({
	// ...
})
// 只有启动后,才能发送
bot.start().then(() => {
	// 频道被动回复
	bot.on('message.guild', (e) => {
		e.reply('hello world')
	})
	// 频道私信被动回复
	bot.on('message.direct', (e) => {
		e.reply('hello world')
	})
	// 群聊被动回复
	bot.on('message.group', (e) => {
		e.reply('hello world')
	})
	// 私聊被动回复
	bot.on('message.private', (e) => {
		e.reply('hello world')
	})
	// 主动发送频道消息
	bot.sendGuildMessage(channel_id, 'hello')
	// 主动发送群消息
	bot.sendGroupMessage(group_id, 'hello')
	// 主动发送私聊消息
	bot.sendPrivateMessage(user_id, 'hello')
	// 主动发送频道消息,注:需要先调用bot.createDirectSession(guild_id,user_id)创建私信会话,此处传入的guild_id为创建的session会话中返回的guild_id
	bot.sendDirectMessage(guild_id, 'hello')
})

API

功能方法名参数1参数2参数3参数4返回值
获取当前机器人信息getSelfInfo获取用户详情
获取频道列表getGuildListGuild[]
获取频道详情getGuildInfoguild_idGuild
获取频道成员列表getGuildMemberListguild_idMember[]
获取频道成员详情getGuildMemberInfoguild_idmember_idMember
获取子频道列表getChannelListguild_idChannel[]
获取子频道详情getChannelInfoguild_idchannel_idChannel
发送频道消息sendGuildMessagechannel_idmessage-
发送频道私信消息sendDirectMessageguild_idmessage-
发送群消息sendGroupMessagegroup_idmessage-
发送私信消息sendPrivateMessageuser_openidmessage-
更多API文档信息待补充-
1.0.42

2 months ago

1.0.41

2 months ago

1.0.37

2 months ago

1.0.36

2 months ago

1.0.39

2 months ago

1.0.38

2 months ago

1.0.40

2 months ago

1.0.34

3 months ago

1.0.33

3 months ago

1.0.32

3 months ago

1.0.31

3 months ago

1.0.22

4 months ago

1.0.21

4 months ago

1.0.26

4 months ago

1.0.25

4 months ago

1.0.24

4 months ago

1.0.23

4 months ago

1.0.29

4 months ago

1.0.30

4 months ago

1.0.20

4 months ago

1.0.19

4 months ago

1.0.18

4 months ago

1.0.17

4 months ago

1.0.16

4 months ago

1.0.11

4 months ago

1.0.10

4 months ago

1.0.15

4 months ago

1.0.14

4 months ago

1.0.13

4 months ago

1.0.12

4 months ago

1.0.9

4 months ago

1.0.8

4 months ago

1.0.2

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.1

5 months ago

1.0.0

5 months ago

0.0.7-1

6 months ago

0.0.7-17

5 months ago

0.0.7-18

5 months ago

0.0.7-15

5 months ago

0.0.7-16

5 months ago

0.0.7-13

5 months ago

0.0.7-14

5 months ago

0.0.7-11

5 months ago

0.0.7-12

5 months ago

0.0.7-10

5 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.7-5

6 months ago

0.0.7-4

6 months ago

0.0.7-3

6 months ago

0.0.1-alpha

6 months ago

0.0.7-2

6 months ago

0.0.7-9

5 months ago

0.0.5

6 months ago

0.0.7-8

5 months ago

0.0.4

6 months ago

0.0.7-7

6 months ago

0.0.7

6 months ago

0.0.7-6

6 months ago

0.0.6

6 months ago

0.0.1

8 months ago

0.0.0

8 months ago