qq-official-bot
Version:
46 lines (45 loc) • 2.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const bot_1 = require("./bot");
const base_1 = require("./receivers/base");
// 创建机器人
const bot = new bot_1.Bot({
// appid:'102073979', // qq机器人的appID (必填)
appid: '102005927', // qq机器人的appID (必填)
// secret:'d4WyQsKmFiBe7a4Y2W0UyTyTyTyTzV1X',
secret: 'ta4KSL5av30iDTYO', // qq机器人的secret (必填)
sandbox: false, // 是否是沙箱环境 默认 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', // 频道私信事件
'MESSAGE_AUDIT', // 消息审核事件
'GUILD_MESSAGE_REACTIONS', // 频道消息表态事件
'GUILDS', // 频道变更事件
'GUILD_MEMBERS', // 频道成员变更事件
'DIRECT_MESSAGE', // 频道私信事件
], // (必填)
mode: base_1.ReceiverMode.WEBSOCKET,
});
// 启动机器人
bot.start().then(async () => {
const guildList = await bot.getGuildList();
console.log(guildList);
// const channelList= await bot.getChannelList("12807596788983546605")
// const result=await bot.sendGuildMessage("634415831",'https://tool.liucl.cn/r?url=www.baidu.com')
// console.log(result)
});
bot.on('message.private', (e) => {
e.reply(`hello, user ${e.sender.user_name}(${e.sender.user_id})`);
});
bot.on('message.group', (e) => {
e.reply(`hello, from group ${e.group_name}(${e.group_id}) user ${e.sender.user_name}(${e.sender.user_id})`);
});
bot.on('message.guild', (e) => {
e.reply(`hello, from guild ${e.guild_name}(${e.guild_id}) channel ${e.channel_name}(${e.channel_id}) user ${e.sender.user_name}(${e.sender.user_id})`);
});