wechaty-puppet-official-account
Version:
Wechaty Puppet for WeChat Official Accounts
86 lines • 3.27 kB
TypeScript
/// <reference types="node" />
import type { MiniProgram, UrlLink } from 'wechaty-puppet/payloads';
import type { FileBoxInterface } from 'file-box';
import { EventEmitter } from 'events';
import { Webhook, VerifyArgs } from './webhook.js';
import { SimpleUnirest } from './simple-unirest.js';
import type { OAMessageType, OAMediaType, OAContactPayload, OATagPayload } from './schema.js';
import { PayloadStore } from './payload-store.js';
export interface OfficialAccountOptions {
appId: string;
appSecret: string;
port?: number;
token: string;
webhookProxyUrl?: string;
personalMode?: boolean;
accessTokenProxyUrl?: string;
}
export interface AccessTokenPayload {
expiresIn: number;
timestamp: number;
token: string;
}
type StopperFn = () => void;
declare class OfficialAccount extends EventEmitter {
options: OfficialAccountOptions;
payloadStore: PayloadStore;
protected webhook: Webhook;
protected simpleUnirest: SimpleUnirest;
protected accessTokenPayload?: AccessTokenPayload;
protected stopperFnList: StopperFn[];
protected oaId: string;
protected accessTokenProxyUrl?: string;
get accessToken(): string;
constructor(options: OfficialAccountOptions);
verify(args: VerifyArgs): boolean;
start(): Promise<void>;
stop(): Promise<void>;
protected updateAccessToken(): Promise<boolean>;
/**
* https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_access_token.html
*/
protected startSyncingAccessToken(): Promise<StopperFn>;
sendCustomMessagePersonal(args: {
touser: string;
msgtype: OAMessageType;
content: string;
}): Promise<string>;
/**
* 客服接口-发消息
* https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html#7
*/
sendCustomMessage(args: {
touser: string;
msgtype: OAMessageType;
content: string;
}): Promise<string>;
sendCustomLink(args: {
touser: string;
urlLinkPayload: UrlLink;
}): Promise<string>;
sendCustomMiniProgram(args: {
miniProgram: MiniProgram;
touser: string;
}): Promise<string>;
sendFile(args: {
file: FileBoxInterface;
touser: string;
msgtype: OAMediaType;
}): Promise<string>;
getContactList(): Promise<string[]>;
getContactPayload(openId: string): Promise<void | OAContactPayload>;
updateContactRemark(openId: string, remark: string): Promise<void>;
createTag(name: string): Promise<void | string>;
getTagList(): Promise<OATagPayload[]>;
private getTagIdByName;
deleteTag(tagName: string): Promise<void>;
addTagToMembers(tagName: string, openIdList: string[]): Promise<void>;
removeTagFromMembers(tagName: string, openIdList: string[]): Promise<void>;
getMemberTags(openid: string): Promise<string[]>;
getAudioUrl(mediaId: string): Promise<string>;
setMemberRemark(openid: string, remark: string): Promise<void>;
sendBatchTextMessageByTagId(tagId: number, msg: string): Promise<void>;
sendBatchTextMessageByOpenidList(openidList: string[], msg: string): Promise<void>;
}
export { OfficialAccount };
//# sourceMappingURL=official-account.d.ts.map