Normalize imports, typings and formatting
Reorder and normalize imports, add missing type imports, and fix whitespace/formatting across multiple files. Notable updates: eslint.config.ts import ordering; core bridge APIs (group-album, misc, web) now import Json types; tests/highway pipeline import ordering and added type imports; protocol changes (element-builder, highway client/pipeline) reorganized imports and added proto type imports; many oidb service modules moved protobuf encode/decode imports for consistency; web group modules (album, essence, honor, notice, request-util) reordered imports, adjusted typings/indentation, and small whitespace fixes. These edits are stylistic and typing improvements and should not change runtime behavior.
This commit is contained in:
1 parent
80ee12ecc2
commit
456086599c
23 files changed
+83
-83
No files matched your search
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
import js from '@eslint/js';
|
import js from '@eslint/js';
|
||||||
import globals from 'globals';
|
|
||||||
import reactHooks from 'eslint-plugin-react-hooks';
|
import reactHooks from 'eslint-plugin-react-hooks';
|
||||||
import reactRefresh from 'eslint-plugin-react-refresh';
|
import reactRefresh from 'eslint-plugin-react-refresh';
|
||||||
import tseslint from 'typescript-eslint';
|
|
||||||
import { defineConfig, globalIgnores } from 'eslint/config';
|
import { defineConfig, globalIgnores } from 'eslint/config';
|
||||||
|
import globals from 'globals';
|
||||||
|
import tseslint from 'typescript-eslint';
|
||||||
|
|
||||||
const tsconfigRootDir = decodeURIComponent(new URL('.', import.meta.url).pathname).replace(/^\/(.:\/)/, '$1');
|
const tsconfigRootDir = decodeURIComponent(new URL('.', import.meta.url).pathname).replace(/^\/(.:\/)/, '$1');
|
||||||
|
|
||||||
@@ -102,4 +102,4 @@ export default defineConfig([
|
|||||||
'react-hooks/set-state-in-effect': 'off',
|
'react-hooks/set-state-in-effect': 'off',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { JsonObject, JsonValue } from '@snowluma/common/json';
|
||||||
import type {
|
import type {
|
||||||
DeleteMediasRequest,
|
DeleteMediasRequest,
|
||||||
DeleteMediasResponse,
|
DeleteMediasResponse,
|
||||||
@@ -6,12 +7,11 @@ import type {
|
|||||||
DoQunLikeRequest,
|
DoQunLikeRequest,
|
||||||
DoQunLikeResponse,
|
DoQunLikeResponse,
|
||||||
GetMediaListRequest,
|
GetMediaListRequest,
|
||||||
MediaInfo,
|
|
||||||
GetMediaListResponse,
|
GetMediaListResponse,
|
||||||
|
MediaInfo,
|
||||||
} from '@snowluma/proto-defs/oidb-actions/group-album';
|
} from '@snowluma/proto-defs/oidb-actions/group-album';
|
||||||
import { getGroupAlbumList, uploadImageToGroupAlbum } from '@snowluma/protocol/web/group-album';
|
import { getGroupAlbumList, uploadImageToGroupAlbum } from '@snowluma/protocol/web/group-album';
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import type { JsonObject, JsonValue } from '@snowluma/common/json';
|
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
import type { JsonObject, JsonValue } from '@snowluma/common/json';
|
||||||
import type {
|
import type {
|
||||||
MiniAppShareReq,
|
MiniAppShareReq,
|
||||||
MiniAppShareResp,
|
MiniAppShareResp,
|
||||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import type { JsonObject, JsonValue } from '@snowluma/common/json';
|
|
||||||
import type { BridgeContext } from '../bridge-context';
|
import type { BridgeContext } from '../bridge-context';
|
||||||
// Migrated OIDB cmds — facade methods are one-line forwarders.
|
// Migrated OIDB cmds — facade methods are one-line forwarders.
|
||||||
import { ClickInlineKeyboardButton } from '@snowluma/protocol/oidb-services/misc/click-inline-keyboard-button';
|
import { ClickInlineKeyboardButton } from '@snowluma/protocol/oidb-services/misc/click-inline-keyboard-button';
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import {
|
|||||||
deleteGroupNotice as deleteGroupNoticeHttp,
|
deleteGroupNotice as deleteGroupNoticeHttp,
|
||||||
getGroupNoticeWebAPI,
|
getGroupNoticeWebAPI,
|
||||||
setGroupNoticeWebAPI,
|
setGroupNoticeWebAPI,
|
||||||
type SetNoticeRetSuccess,
|
|
||||||
uploadGroupNoticeImage,
|
uploadGroupNoticeImage,
|
||||||
|
type SetNoticeRetSuccess,
|
||||||
} from '@snowluma/protocol/web/group-notice';
|
} from '@snowluma/protocol/web/group-notice';
|
||||||
import { RequestUtil } from '@snowluma/protocol/web/request-util';
|
import { RequestUtil } from '@snowluma/protocol/web/request-util';
|
||||||
import type { Bridge } from '../bridge';
|
import type { Bridge } from '../bridge';
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
// The OIDB response is built with real protobuf encoding so we exercise
|
// The OIDB response is built with real protobuf encoding so we exercise
|
||||||
// the actual decode path inside the pipeline.
|
// the actual decode path inside the pipeline.
|
||||||
|
|
||||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||||
|
|
||||||
vi.mock('@snowluma/protocol/highway', () => ({
|
vi.mock('@snowluma/protocol/highway', () => ({
|
||||||
fetchHighwaySession: vi.fn(async () => ({ sessionId: 'fake-session' })),
|
fetchHighwaySession: vi.fn(async () => ({ sessionId: 'fake-session' })),
|
||||||
@@ -16,6 +16,8 @@ vi.mock('@snowluma/protocol/highway', () => ({
|
|||||||
GROUP_IMAGE_CMD_ID: 1004,
|
GROUP_IMAGE_CMD_ID: 1004,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
import type { EncodableMediaMsgInfo, NTV2UploadRichMediaReq, NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway';
|
||||||
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import * as highway from '@snowluma/protocol/highway';
|
import * as highway from '@snowluma/protocol/highway';
|
||||||
import {
|
import {
|
||||||
finalizeMediaMsgInfo,
|
finalizeMediaMsgInfo,
|
||||||
@@ -24,8 +26,6 @@ import {
|
|||||||
runNtv2Upload,
|
runNtv2Upload,
|
||||||
type MediaSubFileUpload,
|
type MediaSubFileUpload,
|
||||||
} from '@snowluma/protocol/highway/pipeline';
|
} from '@snowluma/protocol/highway/pipeline';
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
|
||||||
import type { EncodableMediaMsgInfo, NTV2UploadRichMediaReq, NTV2UploadRichMediaResp } from '@snowluma/proto-defs/highway';
|
|
||||||
|
|
||||||
interface FakeUploadResponse {
|
interface FakeUploadResponse {
|
||||||
upload?: {
|
upload?: {
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
|
import type {
|
||||||
|
MarkdownData,
|
||||||
|
MentionExtraSend,
|
||||||
|
} from '@snowluma/proto-defs/action';
|
||||||
|
import type { Elem, GroupFileExtra } from '@snowluma/proto-defs/element';
|
||||||
import { protobuf_encode } from '@snowluma/proton';
|
import { protobuf_encode } from '@snowluma/proton';
|
||||||
import { deflateSync } from 'zlib';
|
|
||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
|
import { deflateSync } from 'zlib';
|
||||||
import type { BridgeContext } from './bridge-context';
|
import type { BridgeContext } from './bridge-context';
|
||||||
import type { MessageElement } from './events';
|
import type { MessageElement } from './events';
|
||||||
import { uploadImageMsgInfo } from './highway/image-upload';
|
import { uploadImageMsgInfo } from './highway/image-upload';
|
||||||
import { hexToBytes } from './highway/pipeline';
|
import { hexToBytes } from './highway/pipeline';
|
||||||
import { uploadPttMsgInfo } from './highway/ptt-upload';
|
import { uploadPttMsgInfo } from './highway/ptt-upload';
|
||||||
import { uploadVideoMsgInfo } from './highway/video-upload';
|
import { uploadVideoMsgInfo } from './highway/video-upload';
|
||||||
import type {
|
|
||||||
MarkdownData,
|
|
||||||
MentionExtraSend,
|
|
||||||
} from '@snowluma/proto-defs/action';
|
|
||||||
import type { Elem, GroupFileExtra } from '@snowluma/proto-defs/element';
|
|
||||||
|
|
||||||
type ProtoElem = Partial<Elem>;
|
type ProtoElem = Partial<Elem>;
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
||||||
import net from 'net';
|
|
||||||
import type { BridgeContext } from '../bridge-context';
|
|
||||||
import type {
|
import type {
|
||||||
|
HighwayMsgInfoBody,
|
||||||
HttpConn0x6FF501Request,
|
HttpConn0x6FF501Request,
|
||||||
HttpConn0x6FF501Response,
|
HttpConn0x6FF501Response,
|
||||||
HighwayMsgInfoBody,
|
|
||||||
NTV2IPv4,
|
NTV2IPv4,
|
||||||
NTV2RichMediaHighwayExt,
|
NTV2RichMediaHighwayExt,
|
||||||
NTV2UploadRespMsgInfo,
|
NTV2UploadRespMsgInfo,
|
||||||
ReqDataHighwayHead,
|
ReqDataHighwayHead,
|
||||||
RespDataHighwayHead,
|
RespDataHighwayHead,
|
||||||
} from '@snowluma/proto-defs/highway';
|
} from '@snowluma/proto-defs/highway';
|
||||||
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
|
import net from 'net';
|
||||||
|
import type { BridgeContext } from '../bridge-context';
|
||||||
import { computeMd5, packHighwayFrame, unpackHighwayFrame } from './utils';
|
import { computeMd5, packHighwayFrame, unpackHighwayFrame } from './utils';
|
||||||
|
|
||||||
const HIGHWAY_APP_ID = 1600001604;
|
const HIGHWAY_APP_ID = 1600001604;
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
||||||
import crypto from 'crypto';
|
|
||||||
import { createLogger } from '@snowluma/common/logger';
|
import { createLogger } from '@snowluma/common/logger';
|
||||||
import type { BridgeContext } from '../bridge-context';
|
|
||||||
import { makeOidbEnvelope } from '../bridge-oidb';
|
|
||||||
import type {
|
import type {
|
||||||
EncodableMediaMsgInfo,
|
EncodableMediaMsgInfo,
|
||||||
HighwayMsgInfoBody,
|
HighwayMsgInfoBody,
|
||||||
NTV2ExtBizInfo,
|
NTV2ExtBizInfo,
|
||||||
NTV2UploadInfo,
|
NTV2UploadInfo,
|
||||||
|
NTV2UploadRespBody,
|
||||||
NTV2UploadRichMediaReq,
|
NTV2UploadRichMediaReq,
|
||||||
NTV2UploadRichMediaResp,
|
NTV2UploadRichMediaResp,
|
||||||
NTV2UploadRespBody,
|
|
||||||
} from '@snowluma/proto-defs/highway';
|
} from '@snowluma/proto-defs/highway';
|
||||||
import { OidbBase } from '@snowluma/proto-defs/oidb';
|
import { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
|
import crypto from 'crypto';
|
||||||
|
import type { BridgeContext } from '../bridge-context';
|
||||||
|
import { makeOidbEnvelope } from '../bridge-oidb';
|
||||||
import { buildHighwayExtend, fetchHighwaySession, uploadHighwayHttp } from './highway-client';
|
import { buildHighwayExtend, fetchHighwaySession, uploadHighwayHttp } from './highway-client';
|
||||||
|
|
||||||
const moduleLog = createLogger('Highway');
|
const moduleLog = createLogger('Highway');
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
// while-loop until the server stops emitting a next cursor and
|
// while-loop until the server stops emitting a next cursor and
|
||||||
// concatenates results into the public FriendInfo[] shape.
|
// concatenates results into the public FriendInfo[] shape.
|
||||||
|
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
||||||
import type { OidbBase, OidbSvcTrpcTcp0xFD4_1Response } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase, OidbSvcTrpcTcp0xFD4_1Response } from '@snowluma/proto-defs/oidb';
|
||||||
import type { OidbFriendListRequest } from '@snowluma/proto-defs/oidb-actions/base';
|
import type { OidbFriendListRequest } from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||||
|
|
||||||
export namespace FetchFriendListPage {
|
export namespace FetchFriendListPage {
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
// state that's per-Bridge (and is what stops Tencent risk-control
|
// state that's per-Bridge (and is what stops Tencent risk-control
|
||||||
// from banning the account on busy clients — see #42).
|
// from banning the account on busy clients — see #42).
|
||||||
|
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
||||||
import type { OidbBase, OidbSvcTrpcTcp0xFE7_3Response } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase, OidbSvcTrpcTcp0xFE7_3Response } from '@snowluma/proto-defs/oidb';
|
||||||
import type { OidbGroupMemberListRequest } from '@snowluma/proto-defs/oidb-actions/base';
|
import type { OidbGroupMemberListRequest } from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||||
|
|
||||||
export namespace FetchGroupMemberListPage {
|
export namespace FetchGroupMemberListPage {
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
// — the facade swallows the namespace-level exception and surfaces
|
// — the facade swallows the namespace-level exception and surfaces
|
||||||
// `null` so callers get a clean retcode.
|
// `null` so callers get a clean retcode.
|
||||||
|
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import type { OidbStrangerStatusReq, OidbStrangerStatusResp } from '@snowluma/proto-defs/oidb-actions/base';
|
import type { OidbStrangerStatusReq, OidbStrangerStatusResp } from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||||
|
|
||||||
export interface StrangerStatus {
|
export interface StrangerStatus {
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
// means group). Pairs with the c2c-scope variant `GetPrivatePttUrl`
|
// means group). Pairs with the c2c-scope variant `GetPrivatePttUrl`
|
||||||
// (0x126D_200) which only differs in scene.
|
// (0x126D_200) which only differs in scene.
|
||||||
|
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
|
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
|
||||||
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||||
import {
|
import {
|
||||||
normalizeMediaNode, parseNtv2DownloadUrl, type NtMediaIndex,
|
normalizeMediaNode, parseNtv2DownloadUrl, type NtMediaIndex,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
// GetGroupPttUrl; `requestType=2 + businessType=2` swaps voice for
|
// GetGroupPttUrl; `requestType=2 + businessType=2` swaps voice for
|
||||||
// video. The scene's `group` block carries the group uin.
|
// video. The scene's `group` block carries the group uin.
|
||||||
|
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
|
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
|
||||||
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||||
import {
|
import {
|
||||||
normalizeMediaNode, parseNtv2DownloadUrl, type NtMediaIndex,
|
normalizeMediaNode, parseNtv2DownloadUrl, type NtMediaIndex,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
// `scene` is `c2c` rather than `group`. Needs the bot's own uid to
|
// `scene` is `c2c` rather than `group`. Needs the bot's own uid to
|
||||||
// fill the c2c.targetUid slot.
|
// fill the c2c.targetUid slot.
|
||||||
|
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
|
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
|
||||||
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||||
import {
|
import {
|
||||||
normalizeMediaNode, parseNtv2DownloadUrl, type NtMediaIndex,
|
normalizeMediaNode, parseNtv2DownloadUrl, type NtMediaIndex,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
// `scene.c2c.targetUid` is the bot's own uid; the server uses it as
|
// `scene.c2c.targetUid` is the bot's own uid; the server uses it as
|
||||||
// the read-side identity for the asset lookup.
|
// the read-side identity for the asset lookup.
|
||||||
|
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
|
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
|
||||||
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||||
import {
|
import {
|
||||||
normalizeMediaNode, parseNtv2DownloadUrl, type NtMediaIndex,
|
normalizeMediaNode, parseNtv2DownloadUrl, type NtMediaIndex,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
// owning the button (so the bot can react). All identity fields go on
|
// owning the button (so the bot can react). All identity fields go on
|
||||||
// the wire as uint_64 → callers pass JS numbers and we widen here.
|
// the wire as uint_64 → callers pass JS numbers and we widen here.
|
||||||
|
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import type { Oidb0x112eReq, Oidb0x112eResp } from '@snowluma/proto-defs/oidb-actions/base';
|
import type { Oidb0x112eReq, Oidb0x112eResp } from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||||
|
|
||||||
export interface InlineButtonClickResult {
|
export interface InlineButtonClickResult {
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
// Self lookup needs the bot's own UID, hence the `identity` dependency.
|
// Self lookup needs the bot's own UID, hence the `identity` dependency.
|
||||||
// For other users we use `resolveUserUid` to translate the uin first.
|
// For other users we use `resolveUserUid` to translate the uin first.
|
||||||
|
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import type { Oidb0x7edReq, Oidb0x7edResp } from '@snowluma/proto-defs/oidb-actions/base';
|
import type { Oidb0x7edReq, Oidb0x7edResp } from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import type { BridgeContext } from '../../bridge-context';
|
import type { BridgeContext } from '../../bridge-context';
|
||||||
|
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||||
|
|
||||||
export interface LikeInfo {
|
export interface LikeInfo {
|
||||||
[key: string]: import('@snowluma/common/json').JsonValue;
|
[key: string]: import('@snowluma/common/json').JsonValue;
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
// protobuf field, so the namespace's `serialize` / `deserialize` do
|
// protobuf field, so the namespace's `serialize` / `deserialize` do
|
||||||
// the JSON marshalling.
|
// the JSON marshalling.
|
||||||
|
|
||||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
|
||||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||||
import type { Oidb0xe17Req, Oidb0xe17Resp } from '@snowluma/proto-defs/oidb-actions/base';
|
import type { Oidb0xe17Req, Oidb0xe17Resp } from '@snowluma/proto-defs/oidb-actions/base';
|
||||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||||
import type { BridgeContext } from '../../bridge-context';
|
import type { BridgeContext } from '../../bridge-context';
|
||||||
|
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||||
|
|
||||||
export interface UnidirectionalFriendEntry {
|
export interface UnidirectionalFriendEntry {
|
||||||
[key: string]: import('@snowluma/common/json').JsonValue;
|
[key: string]: import('@snowluma/common/json').JsonValue;
|
||||||
@@ -25,7 +25,7 @@ export namespace GetUnidirectionalFriendList {
|
|||||||
* `OidbSvcTrpcTcp.0xNNNN_N` namespace. */
|
* `OidbSvcTrpcTcp.0xNNNN_N` namespace. */
|
||||||
export const wireName = (): string => 'MQUpdateSvc_com_qq_ti.web.OidbSvc.0xe17_0';
|
export const wireName = (): string => 'MQUpdateSvc_com_qq_ti.web.OidbSvc.0xe17_0';
|
||||||
|
|
||||||
export interface Params {}
|
export interface Params { }
|
||||||
|
|
||||||
export type Deps = OidbSender & Pick<BridgeContext, 'identity'>;
|
export type Deps = OidbSender & Pick<BridgeContext, 'identity'>;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { RequestUtil, cookieToString, getBknFromCookie } from './request-util';
|
|
||||||
import { createHash } from 'crypto';
|
|
||||||
import { statSync, createReadStream, writeFileSync, unlinkSync } from 'fs';
|
|
||||||
import { basename, join } from 'path';
|
|
||||||
import { tmpdir } from 'os';
|
|
||||||
import type { JsonValue } from '@snowluma/common/json';
|
import type { JsonValue } from '@snowluma/common/json';
|
||||||
|
import { createHash } from 'crypto';
|
||||||
|
import { createReadStream, statSync, unlinkSync, writeFileSync } from 'fs';
|
||||||
|
import { tmpdir } from 'os';
|
||||||
|
import { basename, join } from 'path';
|
||||||
|
import { RequestUtil, cookieToString, getBknFromCookie } from './request-util';
|
||||||
|
|
||||||
// 群相册信息
|
// 群相册信息
|
||||||
export interface GroupAlbumInfo {
|
export interface GroupAlbumInfo {
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import { RequestUtil, cookieToString, getBknFromCookie } from './request-util';
|
|
||||||
import { createLogger } from '@snowluma/common/logger';
|
|
||||||
import type { JsonObject } from '@snowluma/common/json';
|
import type { JsonObject } from '@snowluma/common/json';
|
||||||
|
import { createLogger } from '@snowluma/common/logger';
|
||||||
|
import { RequestUtil, cookieToString, getBknFromCookie } from './request-util';
|
||||||
|
|
||||||
const log = createLogger('Bridge.Web');
|
const log = createLogger('Bridge.Web');
|
||||||
|
|
||||||
// 定义接口返回类型
|
// 定义接口返回类型
|
||||||
export interface GroupEssenceMsgRet {
|
export interface GroupEssenceMsgRet {
|
||||||
retcode: number;
|
retcode: number;
|
||||||
data: {
|
data: {
|
||||||
is_end: boolean;
|
is_end: boolean;
|
||||||
msg_list: JsonObject[]; // 具体结构视需要补充
|
msg_list: JsonObject[]; // 具体结构视需要补充
|
||||||
[key: string]: JsonObject[] | boolean | string | number | null;
|
[key: string]: JsonObject[] | boolean | string | number | null;
|
||||||
};
|
};
|
||||||
[key: string]: JsonObject | JsonObject[] | boolean | string | number | null;
|
[key: string]: JsonObject | JsonObject[] | boolean | string | number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,4 +69,4 @@ export async function getGroupEssenceMsgAll(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RequestUtil, cookieToString } from './request-util';
|
|
||||||
import { createLogger } from '@snowluma/common/logger';
|
import { createLogger } from '@snowluma/common/logger';
|
||||||
|
import { RequestUtil, cookieToString } from './request-util';
|
||||||
|
|
||||||
const log = createLogger('Bridge.Web');
|
const log = createLogger('Bridge.Web');
|
||||||
|
|
||||||
@@ -24,11 +24,11 @@ interface HonorInitialState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum WebHonorType {
|
export enum WebHonorType {
|
||||||
TALKATIVE = 'talkative',
|
TALKATIVE = 'talkative',
|
||||||
PERFORMER = 'performer',
|
PERFORMER = 'performer',
|
||||||
LEGEND = 'legend',
|
LEGEND = 'legend',
|
||||||
EMOTION = 'emotion',
|
EMOTION = 'emotion',
|
||||||
ALL = 'all',
|
ALL = 'all',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -70,4 +70,4 @@ export async function getHonorListWebAPI(cookieObject: Record<string, string>, g
|
|||||||
groupCode, type, e instanceof Error ? (e.stack ?? e.message) : String(e));
|
groupCode, type, e instanceof Error ? (e.stack ?? e.message) : String(e));
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,40 +1,40 @@
|
|||||||
import { RequestUtil, cookieToString } from './request-util';
|
|
||||||
import https from 'node:https';
|
|
||||||
import { createLogger } from '@snowluma/common/logger';
|
|
||||||
import type { JsonValue } from '@snowluma/common/json';
|
import type { JsonValue } from '@snowluma/common/json';
|
||||||
|
import { createLogger } from '@snowluma/common/logger';
|
||||||
|
import https from 'node:https';
|
||||||
|
import { RequestUtil, cookieToString } from './request-util';
|
||||||
|
|
||||||
const log = createLogger('Bridge.Web');
|
const log = createLogger('Bridge.Web');
|
||||||
|
|
||||||
export interface SetNoticeRetSuccess {
|
export interface SetNoticeRetSuccess {
|
||||||
ec?: number;
|
ec?: number;
|
||||||
em?: string;
|
em?: string;
|
||||||
[key: string]: JsonValue | undefined;
|
[key: string]: JsonValue | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UploadImageRetSuccess {
|
export interface UploadImageRetSuccess {
|
||||||
ec?: number;
|
ec?: number;
|
||||||
id?: string;
|
id?: string;
|
||||||
[key: string]: JsonValue | undefined;
|
[key: string]: JsonValue | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebApiGroupNoticeFeed {
|
export interface WebApiGroupNoticeFeed {
|
||||||
fid: string;
|
fid: string;
|
||||||
u: number;
|
u: number;
|
||||||
pubt: number;
|
pubt: number;
|
||||||
msg: {
|
msg: {
|
||||||
text: string;
|
text: string;
|
||||||
pics?: Array<{ id: string; w: number; h: number }>;
|
pics?: Array<{ id: string; w: number; h: number }>;
|
||||||
};
|
};
|
||||||
settings: JsonValue;
|
settings: JsonValue;
|
||||||
read_num: number;
|
read_num: number;
|
||||||
[key: string]: JsonValue;
|
[key: string]: JsonValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WebApiGroupNoticeRet {
|
export interface WebApiGroupNoticeRet {
|
||||||
ec: number;
|
ec: number;
|
||||||
em?: string;
|
em?: string;
|
||||||
feeds?: Record<string, WebApiGroupNoticeFeed>;
|
feeds?: Record<string, WebApiGroupNoticeFeed>;
|
||||||
[key: string]: JsonValue | Record<string, WebApiGroupNoticeFeed> | undefined;
|
[key: string]: JsonValue | Record<string, WebApiGroupNoticeFeed> | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calculateBkn(key: string): string {
|
export function calculateBkn(key: string): string {
|
||||||
@@ -174,7 +174,7 @@ export async function uploadGroupNoticeImage(
|
|||||||
imageBuffer: Buffer
|
imageBuffer: Buffer
|
||||||
): Promise<{ id: string; width: number; height: number } | undefined> {
|
): Promise<{ id: string; width: number; height: number } | undefined> {
|
||||||
try {
|
try {
|
||||||
const bkn = calculateBkn(cookieObject['skey']);
|
const bkn = calculateBkn(cookieObject['skey']);
|
||||||
const boundary = `-----------------------------${Date.now()}`;
|
const boundary = `-----------------------------${Date.now()}`;
|
||||||
|
|
||||||
const parts: Buffer[] = [];
|
const parts: Buffer[] = [];
|
||||||
@@ -271,4 +271,4 @@ export async function deleteGroupNotice(
|
|||||||
log.warn('deleteGroupNotice failed (group=%s fid=%s): %s', groupCode, fid, e instanceof Error ? (e.stack ?? e.message) : String(e));
|
log.warn('deleteGroupNotice failed (group=%s fid=%s): %s', groupCode, fid, e instanceof Error ? (e.stack ?? e.message) : String(e));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import https from 'node:https';
|
|
||||||
import http from 'node:http';
|
import http from 'node:http';
|
||||||
|
import https from 'node:https';
|
||||||
|
|
||||||
type RequestBody = string | Buffer | Uint8Array | Record<string, unknown> | undefined;
|
type RequestBody = string | Buffer | Uint8Array | Record<string, unknown> | undefined;
|
||||||
|
|
||||||
@@ -53,8 +53,8 @@ export class RequestUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: RequestBody, headers: {
|
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: RequestBody, headers: {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
} = {}, isJsonRet: boolean = true, isArgJson: boolean = true, maxRedirects: number = 5): Promise<T> {
|
} = {}, isJsonRet: boolean = true, isArgJson: boolean = true, maxRedirects: number = 5): Promise<T> {
|
||||||
const option = new URL(url);
|
const option = new URL(url);
|
||||||
const protocol = url.startsWith('https://') ? https : http;
|
const protocol = url.startsWith('https://') ? https : http;
|
||||||
const options = {
|
const options = {
|
||||||
|
|||||||
Reference in new issue
Block a user