@luckylillia-dev/plugin-webqq 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ var n;function s(t){n=t}function o(){if(!n)throw new Error("the WebQQ client is used before its apply() ran");return n}var u=(t,e)=>o().toast(t,e);function c(t){let e=n;if(e?.url)return e.url(t);if(!t.startsWith("/")||t.startsWith("//")||t.startsWith("/i/"))return t;let i=typeof location>"u"?"":location.pathname,r=/^\/i\/([^/]+)(?:\/|$)/.exec(i);return r?`/i/${r[1]}${t}`:t}export{s as a,o as b,u as c,c as d};
@@ -1 +1 @@
1
- import{a as t}from"./chunks/chunk-JP6IZEMY.js";import{lazy as i}from"react";var l=i(()=>import("./chunks/WebQQEntry-34LQMVRZ.js")),r="@luckylillia-dev/plugin-webqq",o=e=>{t(e),e.page({id:"webqq",title:"WebQQ",icon:"message-square",component:l,order:50}),e.declareSlot("webqq.chat.actions",{title:"WebQQ \u804A\u5929\u7A97\u53E3\u6309\u94AE",description:"WebQQ \u804A\u5929\u7A97\u53E3\u9876\u680F\u53F3\u4FA7\u7684\u6309\u94AE\uFF0C\u62FF\u5230\u5F53\u524D\u6253\u5F00\u7684\u804A\u5929",cardinality:"list"}),e.declareSlot("webqq.message.element",{title:"WebQQ \u6D88\u606F\u663E\u793A",description:"\u6309\u5143\u7D20\u7C7B\u578B\uFF08elementType\uFF0C\u5982 14 \u662F markdown\uFF09\u6362\u6389 WebQQ \u5BF9\u5B83\u7684\u753B\u6CD5\uFF0C\u6216\u8005\u753B\u51FA WebQQ \u4E0D\u8BA4\u8BC6\u7684\u7C7B\u578B",cardinality:"keyed"}),e.declareSlot("webqq.message.bubble",{title:"WebQQ \u6D88\u606F\u6C14\u6CE1",description:"\u5305\u5728\u6BCF\u6761\u6D88\u606F\u7684\u6C14\u6CE1\u5916\u9762\uFF0C\u80FD\u52A0\u4E1C\u897F\uFF0C\u4E5F\u80FD\u6539\u6389\u91CC\u9762\u7684\u5185\u5BB9",cardinality:"chain"})},b=o;export{b as default,r as name};
1
+ import{a as t}from"./chunks/chunk-MBPE66O6.js";import{lazy as i}from"react";var l=i(()=>import("./chunks/WebQQEntry-QUBLXEFH.js")),r="@luckylillia-dev/plugin-webqq",o=e=>{t(e),e.page({id:"webqq",title:"WebQQ",icon:"message-square",component:l,order:50}),e.declareSlot("webqq.chat.actions",{title:"WebQQ \u804A\u5929\u7A97\u53E3\u6309\u94AE",description:"WebQQ \u804A\u5929\u7A97\u53E3\u9876\u680F\u53F3\u4FA7\u7684\u6309\u94AE\uFF0C\u62FF\u5230\u5F53\u524D\u6253\u5F00\u7684\u804A\u5929",cardinality:"list"}),e.declareSlot("webqq.message.element",{title:"WebQQ \u6D88\u606F\u663E\u793A",description:"\u6309\u5143\u7D20\u7C7B\u578B\uFF08elementType\uFF0C\u5982 14 \u662F markdown\uFF09\u6362\u6389 WebQQ \u5BF9\u5B83\u7684\u753B\u6CD5\uFF0C\u6216\u8005\u753B\u51FA WebQQ \u4E0D\u8BA4\u8BC6\u7684\u7C7B\u578B",cardinality:"keyed"}),e.declareSlot("webqq.message.bubble",{title:"WebQQ \u6D88\u606F\u6C14\u6CE1",description:"\u5305\u5728\u6BCF\u6761\u6D88\u606F\u7684\u6C14\u6CE1\u5916\u9762\uFF0C\u80FD\u52A0\u4E1C\u897F\uFF0C\u4E5F\u80FD\u6539\u6389\u91CC\u9762\u7684\u5185\u5BB9",cardinality:"chain"})},b=o;export{b as default,r as name};
package/lib/index.js CHANGED
@@ -22492,6 +22492,56 @@ function createFaceRoutes(faceDir = path9.resolve(import.meta.dirname, "../asset
22492
22492
  }
22493
22493
 
22494
22494
  // src/events.ts
22495
+ function buildNudgeItems(input) {
22496
+ const action = input.displayAction || "\u6233\u4E86\u6233";
22497
+ const items = [
22498
+ { type: "qq", uid: input.senderUid, uin: String(input.senderUin), nm: input.senderName },
22499
+ { type: "nor", txt: ` ${action} ` }
22500
+ ];
22501
+ if (input.displayActionImgUrl) {
22502
+ items.push({ type: "img", src: input.displayActionImgUrl });
22503
+ }
22504
+ if (input.senderUin && input.receiverUin && input.senderUin === input.receiverUin) {
22505
+ items.push({ type: "nor", txt: "\u81EA\u5DF1" });
22506
+ } else {
22507
+ items.push({ type: "qq", uid: input.receiverUid, uin: String(input.receiverUin), nm: input.receiverName });
22508
+ }
22509
+ if (input.displaySuffix) {
22510
+ items.push({ type: "nor", txt: input.displaySuffix });
22511
+ }
22512
+ return items;
22513
+ }
22514
+ var nudgeSeq = 0;
22515
+ function createNudgeMessage(params) {
22516
+ const nowMs = Date.now();
22517
+ const msgId = `nudge_${nowMs}_${++nudgeSeq}`;
22518
+ return {
22519
+ msgId,
22520
+ msgSeq: "",
22521
+ msgTime: Math.floor(nowMs / 1e3),
22522
+ chatType: params.chatType,
22523
+ peerUin: params.peerUin,
22524
+ peerUid: params.peerUid,
22525
+ peerName: params.peerName,
22526
+ senderUin: params.senderUin,
22527
+ senderUid: params.senderUid,
22528
+ sendNickName: params.sendNickName,
22529
+ sendMemberName: "",
22530
+ elements: [
22531
+ {
22532
+ elementType: ElementType.GrayTip,
22533
+ elementId: `${msgId}_0`,
22534
+ grayTipElement: {
22535
+ subElementType: 17,
22536
+ jsonGrayTipElement: {
22537
+ busiId: "1061",
22538
+ jsonStr: JSON.stringify({ items: params.items })
22539
+ }
22540
+ }
22541
+ }
22542
+ ]
22543
+ };
22544
+ }
22495
22545
  function forwardEvents(ctx, sseClients) {
22496
22546
  const broadcastMessage = (event, data) => {
22497
22547
  const serializedData = serializeResult(data);
@@ -22511,6 +22561,47 @@ data: ${JSON.stringify(serializedData)}
22511
22561
  }
22512
22562
  }
22513
22563
  };
22564
+ const resolveGroupMemberName = async (groupCode, uin, uid) => {
22565
+ try {
22566
+ const card = await ctx.store.getGroupMemberCardName(groupCode, uin);
22567
+ if (card) return card;
22568
+ } catch {
22569
+ }
22570
+ if (uid) {
22571
+ try {
22572
+ const user = await ctx.ntUserApi.getUserByUid(uid);
22573
+ if (user?.nick) return user.nick;
22574
+ } catch {
22575
+ }
22576
+ }
22577
+ return String(uin);
22578
+ };
22579
+ const resolveGroupName = async (groupCode) => {
22580
+ try {
22581
+ const groups = await ctx.ntGroupApi.getGroups(false);
22582
+ const hit = groups.find((g) => Number(g.groupCode) === Number(groupCode));
22583
+ if (hit?.groupName) return hit.groupName;
22584
+ } catch {
22585
+ }
22586
+ return "";
22587
+ };
22588
+ const resolveFriendName = async (uin, uid) => {
22589
+ try {
22590
+ const result = await ctx.ntFriendApi.getFriends(false);
22591
+ const list = Array.isArray(result) ? result : result?.friends ?? [];
22592
+ const hit = list.find((f) => Number(f.uin) === Number(uin));
22593
+ if (hit) return hit.remark || hit.nick || String(uin);
22594
+ } catch {
22595
+ }
22596
+ if (uid) {
22597
+ try {
22598
+ const user = await ctx.ntUserApi.getUserByUid(uid);
22599
+ if (user?.nick) return user.nick;
22600
+ } catch {
22601
+ }
22602
+ }
22603
+ return String(uin);
22604
+ };
22514
22605
  ctx.on("nt/message-created", async (data) => {
22515
22606
  if (sseClients.size === 0) return;
22516
22607
  await fillPeerUin(data.message);
@@ -22559,6 +22650,75 @@ data: ${JSON.stringify(serializedData)}
22559
22650
  }
22560
22651
  });
22561
22652
  });
22653
+ ctx.on("nt/group-nudge", async (data) => {
22654
+ if (sseClients.size === 0) return;
22655
+ const [senderName, receiverName, groupName] = await Promise.all([
22656
+ resolveGroupMemberName(data.groupCode, data.senderUin, data.senderUid),
22657
+ data.receiverUin === data.senderUin ? Promise.resolve("") : resolveGroupMemberName(data.groupCode, data.receiverUin, data.receiverUid),
22658
+ resolveGroupName(data.groupCode)
22659
+ ]);
22660
+ const items = buildNudgeItems({
22661
+ senderUid: data.senderUid || "",
22662
+ senderUin: data.senderUin,
22663
+ senderName,
22664
+ receiverUid: data.receiverUid || "",
22665
+ receiverUin: data.receiverUin,
22666
+ receiverName,
22667
+ displayAction: data.displayAction,
22668
+ displaySuffix: data.displaySuffix,
22669
+ displayActionImgUrl: data.displayActionImgUrl
22670
+ });
22671
+ broadcastMessage("message", {
22672
+ type: "message-created",
22673
+ data: createNudgeMessage({
22674
+ chatType: ChatType.Group,
22675
+ peerUin: data.groupCode,
22676
+ peerUid: String(data.groupCode),
22677
+ peerName: groupName,
22678
+ senderUin: data.senderUin,
22679
+ senderUid: data.senderUid || "",
22680
+ sendNickName: senderName,
22681
+ items
22682
+ })
22683
+ });
22684
+ });
22685
+ ctx.on("nt/friend-nudge", async (data) => {
22686
+ if (sseClients.size === 0) return;
22687
+ const selfInfo = ctx.qqProtocol.selfInfo;
22688
+ const selfUin = Number(selfInfo.uin) || 0;
22689
+ const selfUid = selfInfo.uid || "";
22690
+ const friendName = await resolveFriendName(data.uin, data.uid);
22691
+ const senderUin = data.isSelfSend ? selfUin : data.uin;
22692
+ const senderUid = data.isSelfSend ? selfUid : data.uid || "";
22693
+ const senderName = data.isSelfSend ? selfInfo.nick || "\u4F60" : friendName;
22694
+ const receiverUin = data.isSelfReceive ? selfUin : data.uin;
22695
+ const receiverUid = data.isSelfReceive ? selfUid : data.uid || "";
22696
+ const receiverName = data.isSelfReceive ? selfInfo.nick || "\u4F60" : friendName;
22697
+ const items = buildNudgeItems({
22698
+ senderUid,
22699
+ senderUin,
22700
+ senderName,
22701
+ receiverUid,
22702
+ receiverUin,
22703
+ receiverName,
22704
+ displayAction: data.displayAction,
22705
+ displaySuffix: data.displaySuffix,
22706
+ displayActionImgUrl: data.displayActionImgUrl
22707
+ });
22708
+ broadcastMessage("message", {
22709
+ type: "message-created",
22710
+ data: createNudgeMessage({
22711
+ chatType: ChatType.C2C,
22712
+ peerUin: data.uin,
22713
+ peerUid: data.uid || "",
22714
+ peerName: friendName,
22715
+ senderUin,
22716
+ senderUid,
22717
+ sendNickName: friendName,
22718
+ items
22719
+ })
22720
+ });
22721
+ });
22562
22722
  }
22563
22723
 
22564
22724
  // node_modules/hono/dist/utils/stream.js