@hkai-ai/weibo-api
Version:
香港人工智能协会封装的新浪微博API
96 lines • 2.63 kB
TypeScript
import { Mblog, Pic, type Card, type GetIndexResponseBody, type IndexResponseType } from "../types/api/container/getIndex.ts";
import { Option } from "effect";
export declare function multiply(a: number, b: number): number;
type ContainerId = string;
export type ParsedTabInfo = {
[K in IndexResponseType['kind']]?: ContainerId;
};
/**
* 目前看起来只有发原创推文和转发推文的情况
*/
export type WeiboUserActionType = 'tweet' | 'retweet';
export type ParsedWeiboUserInfo = {
id: number;
name: string;
avatar: string;
description: string;
};
export type BaseWeiboInfo = {
action: WeiboUserActionType;
user: ParsedWeiboUserInfo;
/**
* 微博图片
*/
pics?: Pic[];
/**
* 微博文本,包括富文本格式
*/
text: string;
/**
* 微博原始文本
*/
rawText: string;
/**
* 评论数
*/
commentsCount: number;
/**
* 转发数
*/
retweetCount: number;
/**
* 点赞数
*/
attitudesCount: number;
createdAt: string;
/**
* 博文 Id
*/
weiboId: string;
/**
* 发微博的Ip定位
*/
region?: string;
};
/**
* 原创推文
*/
export type OrginalWeiboInfo = BaseWeiboInfo & {
action: 'tweet';
};
/**
* 转发的推文
*/
export type RetweetWeiboInfo = BaseWeiboInfo & {
action: 'retweet';
retweetedWeibo: OrginalWeiboInfo;
};
export type WeiboInfo = OrginalWeiboInfo | RetweetWeiboInfo;
/**
* 从 init 响应体中解析出 tab 信息,通过 tab 信息中的 ContainerId 获取用户主页中不同分类的微博信息(精选、微博、视频、相册等)
* @param res
* @returns
*/
export declare const parseTabInfoFromInitResponseBody: (res: GetIndexResponseBody<{
kind: "init";
}>) => ParsedTabInfo;
export declare const extractUserWeiboContainerId: (parsedTabInfo: ParsedTabInfo) => Option.Option<ContainerId>;
export declare const extractCardInfosFromWeiboResponseBody: (res: GetIndexResponseBody<{
kind: "weibo";
}>) => Option.Option<Card[]>;
export declare const isWeiboBeBlocked: (weibo: Mblog) => boolean;
/**
* 将卡片信息解析为微博推文信息
* 需要注意的是微博可能会存在被屏蔽的问题
* @param cardInfos
* @returns
*/
export declare const parseCardInfosToWeiboInfos: (cardInfos: Card[]) => WeiboInfo[];
/**
* 判断微博文本是否是全文
* @param text 微博文本
* @returns 如果是全文返回 true,否则返回 false
*/
export declare const isFetchedWeiboTextWereFullText: (text: string) => boolean;
export {};
//# sourceMappingURL=parser.d.ts.map