@alemonjs/onebot
Advanced tools
+166
-10
@@ -45,3 +45,3 @@ import { definePlatform, cbpPlatform, createResult, ResultCode } from 'alemonjs'; | ||
| const groupId = String(event.group_id); | ||
| const replyId = event.message.find(item => item.type === 'reply')?.data?.id; | ||
| const ReplyId = event.message.find(item => item.type === 'reply')?.data?.id; | ||
| const e = { | ||
@@ -62,5 +62,6 @@ name: 'message.create', | ||
| OpenId: UserId, | ||
| replyId, | ||
| CreateAt: Date.now(), | ||
| tag: 'message.create', | ||
| ReplyId, | ||
| replyId: ReplyId, | ||
| BotId: BotMe.id, | ||
| _tag: 'message.create', | ||
| value: event | ||
@@ -75,3 +76,3 @@ }; | ||
| const [isMaster, UserKey] = getMaster(UserId); | ||
| const replyId = event.message.find(item => item.type === 'reply')?.data?.id; | ||
| const ReplyId = event.message.find(item => item.type === 'reply')?.data?.id; | ||
| const e = { | ||
@@ -89,5 +90,6 @@ name: 'private.message.create', | ||
| OpenId: String(event.user_id), | ||
| CreateAt: Date.now(), | ||
| replyId, | ||
| tag: 'private.message.create', | ||
| ReplyId, | ||
| replyId: ReplyId, | ||
| BotId: BotMe.id, | ||
| _tag: 'private.message.create', | ||
| value: event | ||
@@ -97,2 +99,156 @@ }; | ||
| }); | ||
| client.on('NOTICE_GROUP_MEMBER_INCREASE', event => { | ||
| const UserId = String(event.user_id); | ||
| const UserAvatar = createUserAvatar(UserId); | ||
| const [isMaster, UserKey] = getMaster(UserId); | ||
| const groupId = String(event.group_id); | ||
| const e = { | ||
| name: 'member.add', | ||
| Platform: platform, | ||
| GuildId: groupId, | ||
| ChannelId: groupId, | ||
| SpaceId: groupId, | ||
| UserId: UserId, | ||
| UserKey, | ||
| UserAvatar: UserAvatar, | ||
| IsMaster: isMaster, | ||
| IsBot: false, | ||
| MessageId: '', | ||
| BotId: BotMe.id, | ||
| _tag: 'NOTICE_GROUP_MEMBER_INCREASE', | ||
| value: event | ||
| }; | ||
| cbp.send(e); | ||
| }); | ||
| client.on('NOTICE_GROUP_MEMBER_REDUCE', event => { | ||
| const UserId = String(event.user_id); | ||
| const UserAvatar = createUserAvatar(UserId); | ||
| const [isMaster, UserKey] = getMaster(UserId); | ||
| const groupId = String(event.group_id); | ||
| const e = { | ||
| name: 'member.remove', | ||
| Platform: platform, | ||
| GuildId: groupId, | ||
| ChannelId: groupId, | ||
| SpaceId: groupId, | ||
| UserId: UserId, | ||
| UserKey, | ||
| UserAvatar: UserAvatar, | ||
| IsMaster: isMaster, | ||
| IsBot: false, | ||
| MessageId: '', | ||
| BotId: BotMe.id, | ||
| _tag: 'NOTICE_GROUP_MEMBER_REDUCE', | ||
| value: event | ||
| }; | ||
| cbp.send(e); | ||
| }); | ||
| client.on('REQUEST_ADD_FRIEND', event => { | ||
| const UserId = String(event.user_id); | ||
| const UserAvatar = createUserAvatar(UserId); | ||
| const [isMaster, UserKey] = getMaster(UserId); | ||
| const e = { | ||
| name: 'private.friend.add', | ||
| Platform: platform, | ||
| UserId: UserId, | ||
| UserKey, | ||
| UserAvatar: UserAvatar, | ||
| IsMaster: isMaster, | ||
| IsBot: false, | ||
| MessageId: String(event.flag ?? ''), | ||
| BotId: BotMe.id, | ||
| _tag: 'REQUEST_ADD_FRIEND', | ||
| value: event | ||
| }; | ||
| cbp.send(e); | ||
| }); | ||
| client.on('REQUEST_ADD_GROUP', event => { | ||
| const UserId = String(event.user_id); | ||
| const UserAvatar = createUserAvatar(UserId); | ||
| const [isMaster, UserKey] = getMaster(UserId); | ||
| const e = { | ||
| name: 'private.guild.add', | ||
| Platform: platform, | ||
| UserId: UserId, | ||
| UserKey, | ||
| UserAvatar: UserAvatar, | ||
| IsMaster: isMaster, | ||
| IsBot: false, | ||
| MessageId: String(event.flag ?? ''), | ||
| BotId: BotMe.id, | ||
| _tag: 'REQUEST_ADD_GROUP', | ||
| value: event | ||
| }; | ||
| cbp.send(e); | ||
| }); | ||
| client.on('NOTICE_GROUP_RECALL', event => { | ||
| const groupId = String(event.group_id); | ||
| const e = { | ||
| name: 'message.delete', | ||
| Platform: platform, | ||
| GuildId: groupId, | ||
| ChannelId: groupId, | ||
| SpaceId: groupId, | ||
| MessageId: String(event.message_id ?? ''), | ||
| BotId: BotMe.id, | ||
| _tag: 'NOTICE_GROUP_RECALL', | ||
| value: event | ||
| }; | ||
| cbp.send(e); | ||
| }); | ||
| client.on('NOTICE_FRIEND_RECALL', event => { | ||
| const e = { | ||
| name: 'private.message.delete', | ||
| Platform: platform, | ||
| MessageId: String(event.message_id ?? ''), | ||
| BotId: BotMe.id, | ||
| _tag: 'NOTICE_FRIEND_RECALL', | ||
| value: event | ||
| }; | ||
| cbp.send(e); | ||
| }); | ||
| client.on('NOTICE_GROUP_BAN', event => { | ||
| const UserId = String(event.user_id); | ||
| const UserAvatar = createUserAvatar(UserId); | ||
| const [isMaster, UserKey] = getMaster(UserId); | ||
| const groupId = String(event.group_id); | ||
| if (event.sub_type === 'ban') { | ||
| const e = { | ||
| name: 'member.ban', | ||
| Platform: platform, | ||
| GuildId: groupId, | ||
| ChannelId: groupId, | ||
| SpaceId: groupId, | ||
| UserId: UserId, | ||
| UserKey, | ||
| UserAvatar: UserAvatar, | ||
| IsMaster: isMaster, | ||
| IsBot: false, | ||
| MessageId: '', | ||
| BotId: BotMe.id, | ||
| _tag: 'NOTICE_GROUP_BAN', | ||
| value: event | ||
| }; | ||
| cbp.send(e); | ||
| } | ||
| else if (event.sub_type === 'lift_ban') { | ||
| const e = { | ||
| name: 'member.unban', | ||
| Platform: platform, | ||
| GuildId: groupId, | ||
| ChannelId: groupId, | ||
| SpaceId: groupId, | ||
| UserId: UserId, | ||
| UserKey, | ||
| UserAvatar: UserAvatar, | ||
| IsMaster: isMaster, | ||
| IsBot: false, | ||
| MessageId: '', | ||
| BotId: BotMe.id, | ||
| _tag: 'NOTICE_GROUP_BAN_LIFT', | ||
| value: event | ||
| }; | ||
| cbp.send(e); | ||
| } | ||
| }); | ||
| const DataToMessage = async (val = []) => { | ||
@@ -116,3 +272,3 @@ const empty = { | ||
| const options = item.options || {}; | ||
| if (options.belong === 'everyone') { | ||
| if (item.value === 'everyone' || item.value === 'all' || item.value === '' || typeof item.value !== 'string') { | ||
| return { | ||
@@ -184,3 +340,3 @@ type: 'at', | ||
| data: { | ||
| file: `base64://${item.value.toString('base64')}` | ||
| file: `base64://${item.value}` | ||
| } | ||
@@ -187,0 +343,0 @@ }; |
@@ -10,2 +10,5 @@ import { MESSAGES_TYPE, DIRECT_MESSAGE_TYPE, META_EVENT_LIFECYCLE, META_EVENT_HEARTBEAT } from './types'; | ||
| NOTICE_GROUP_MEMBER_REDUCE: any; | ||
| NOTICE_GROUP_RECALL: any; | ||
| NOTICE_FRIEND_RECALL: any; | ||
| NOTICE_GROUP_BAN: any; | ||
| }; |
+21
-5
@@ -34,3 +34,3 @@ import WebSocket, { WebSocketServer } from 'ws'; | ||
| connect() { | ||
| const { url, access_token: token, reverse_enable, reverse_port } = this.#options; | ||
| const { url, access_token: token, reverse_enable: reverseEnable, reverse_port: reversePort } = this.#options; | ||
| const notToken = !token || token === ''; | ||
@@ -78,2 +78,17 @@ const c = notToken | ||
| } | ||
| else if (event?.notice_type === 'group_recall') { | ||
| if (this.#events['NOTICE_GROUP_RECALL']) { | ||
| this.#events['NOTICE_GROUP_RECALL'](event); | ||
| } | ||
| } | ||
| else if (event?.notice_type === 'friend_recall') { | ||
| if (this.#events['NOTICE_FRIEND_RECALL']) { | ||
| this.#events['NOTICE_FRIEND_RECALL'](event); | ||
| } | ||
| } | ||
| else if (event?.notice_type === 'group_ban') { | ||
| if (this.#events['NOTICE_GROUP_BAN']) { | ||
| this.#events['NOTICE_GROUP_BAN'](event); | ||
| } | ||
| } | ||
| } | ||
@@ -102,3 +117,4 @@ else if (event?.post_type === 'request') { | ||
| logger.error(`[OneBot] WebSocket closed: ${code} - ${reason.toString('utf8')}`); | ||
| if (reverse_enable) { | ||
| this.__ws = null; | ||
| if (reverseEnable) { | ||
| return; | ||
@@ -112,4 +128,4 @@ } | ||
| if (!this.__ws) { | ||
| if (reverse_enable) { | ||
| const server = new WebSocketServer({ port: reverse_port ?? 17158 }); | ||
| if (reverseEnable) { | ||
| const server = new WebSocketServer({ port: reversePort ?? 17158 }); | ||
| server.on('connection', ws => { | ||
@@ -119,3 +135,3 @@ this.__ws = ws; | ||
| this.__ws.on('close', onClose); | ||
| logger.info(`[OneBot] connected: ws://127.0.0.1:${reverse_port}`); | ||
| logger.info(`[OneBot] connected: ws://127.0.0.1:${reversePort}`); | ||
| }); | ||
@@ -122,0 +138,0 @@ } |
+1
-1
| { | ||
| "name": "@alemonjs/onebot", | ||
| "version": "2.1.0-alpha.17", | ||
| "version": "2.1.0", | ||
| "description": "oneBot v11", | ||
@@ -5,0 +5,0 @@ "author": "lemonade", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
49173
13.87%1544
12.78%1
-50%