npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

qq-group-bot

v1.1.0

Published

qq机器人开发SDK

Downloads

340

Readme

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 | | | | | 见获取用户详情 | | 获取频道列表 | getGuildList | | | | | Guild[] | | 获取频道详情 | getGuildInfo | guild_id | | | | Guild | | 获取频道成员列表 | getGuildMemberList | guild_id | | | | Member[] | | 获取频道成员详情 | getGuildMemberInfo | guild_id | member_id | | | Member | | 获取子频道列表 | getChannelList | guild_id | | | | Channel[] | | 获取子频道详情 | getChannelInfo | guild_id | channel_id | | | Channel | | 发送频道消息 | sendGuildMessage | channel_id | message | | | - | | 发送频道私信消息 | sendDirectMessage | guild_id | message | | | - | | 发送群消息 | sendGroupMessage | group_id | message | | | - | | 发送私信消息 | sendPrivateMessage | user_openid | message | | | - | | 更多API文档信息待补充 | | | | | | - |