wechaty-puppet-padplus
Version:
Puppet Padplus for Wechaty
130 lines • 6.95 kB
TypeScript
/// <reference types="node" />
import { MemoryCard } from 'memory-card';
import FileBox from 'file-box';
import LRU from 'lru-cache';
import { GrpcEventEmitter } from '../server-manager/grpc-event-emitter';
import { PadplusContactPayload, PadplusMessagePayload, PadplusMessageType, PadplusRoomPayload, FriendshipPayload, PadplusRichMediaData, PadplusMediaData, GrpcSearchContact, PadplusRoomMemberMap, GetContactSelfInfoGrpcResponse } from '../schemas';
import { GrpcQrCodeLogin } from '../schemas/grpc-schemas';
import { CacheManager } from '../server-manager/cache-manager';
import { EventEmitter } from 'events';
export interface PadplusMemorySlot {
qrcodeId: string;
uin: string;
userName: string;
}
export interface ManagerOptions {
token: string;
name: unknown;
endpoint?: string;
}
export declare type PadplusManagerEvent = 'error' | 'scan' | 'login' | 'logout' | 'contact-list' | 'contact-modify' | 'contact-delete' | 'message' | 'room-member-list' | 'room-member-modify' | 'status-notify' | 'ready' | 'reset' | 'heartbeat' | 'EXPIRED_TOKEN' | 'INVALID_TOKEN';
export declare class PadplusManager extends EventEmitter {
options: ManagerOptions;
private grpcGatewayEmitter?;
private readonly state;
private requestClient?;
private padplusUser?;
private padplusMesasge?;
private padplusContact?;
private padplusRoom?;
private padplusFriendship?;
cacheManager?: CacheManager;
private memory?;
private memorySlot;
private qrcodeStatus?;
private loginStatus?;
readonly cachePadplusMessagePayload: LRU<string, PadplusMessagePayload>;
private contactAndRoomData?;
private resetThrottleQueue;
private getContactQueue;
private getRoomMemberQueue;
constructor(options: ManagerOptions);
emit(event: 'scan', qrcode: string, status: number, data?: string): boolean;
emit(event: 'login', data: GrpcQrCodeLogin): boolean;
emit(event: 'logout'): boolean;
emit(event: 'contact-list', data: string): boolean;
emit(event: 'contact-modify', data: string): boolean;
emit(event: 'contact-delete', data: string): boolean;
emit(event: 'message', msg: PadplusMessagePayload): boolean;
emit(event: 'room-member-list', data: string): boolean;
emit(event: 'room-member-modify', data: string): boolean;
emit(event: 'status-notify', data: string): boolean;
emit(event: 'ready'): boolean;
emit(event: 'reset', reason: string): boolean;
emit(event: 'heartbeat', data: string): boolean;
emit(event: 'error', error: Error): boolean;
emit(event: never, listener: never): never;
on(event: 'scan', listener: ((this: PadplusManager, qrcode: string, status: number, data?: string) => void)): this;
on(event: 'login', listener: ((this: PadplusManager, data: GrpcQrCodeLogin) => void)): this;
on(event: 'logout', listener: ((this: PadplusManager) => void)): this;
on(event: 'message', listener: ((this: PadplusManager, msg: PadplusMessagePayload) => void)): this;
on(event: 'status-notify', listener: ((this: PadplusManager, data: string) => void)): this;
on(event: 'ready', listener: ((this: PadplusManager) => void)): this;
on(event: 'reset', listener: ((this: PadplusManager, reason: string) => void)): this;
on(event: 'heartbeat', listener: ((this: PadplusManager, data: string) => void)): this;
on(event: 'error', listener: ((this: PadplusManager, error: Error) => void)): this;
on(event: never, listener: never): never;
start(): Promise<void>;
stop(): Promise<void>;
logout(selfId: string): Promise<void>;
setMemory(memory: MemoryCard): void;
setContactAndRoomData(): Promise<void>;
initGrpcGatewayListener(grpcGatewayEmitter: GrpcEventEmitter): Promise<void>;
/**
* Contact Self Section
*/
contactSelfQrcode(): Promise<string>;
contactSelfName(name: string): Promise<void>;
contactSelfSignature(signature: string): Promise<void>;
contactSelfInfo(): Promise<GetContactSelfInfoGrpcResponse>;
/**
* Message Section
*/
loadRichMediaData(mediaData: PadplusRichMediaData): Promise<PadplusMediaData>;
sendMessage(selfId: string, receiver: string, text: string, type: PadplusMessageType, mention?: string): Promise<import("../schemas").GrpcResponseMessageData>;
sendContact(selfId: string, receiver: string, contentStr: string): Promise<import("../schemas").GrpcResponseMessageData>;
addFriend(contactId: string, hello: string | undefined, isPhoneNumber: number, strangerV1: string, strangerV2: string): Promise<import("../schemas").AddContactGrpcResponse>;
generatorFileUrl(file: FileBox): Promise<string>;
sendFile(selfId: string, receiverId: string, url: string, fileName: string, subType: string, fileSize?: number): Promise<import("../schemas").GrpcResponseMessageData>;
sendUrlLink(selfId: string, receiver: string, content: string): Promise<import("../schemas").GrpcResponseMessageData>;
private onProcessMessage;
/**
* Contact Section
*/
setContactAlias(contactId: string, alias: string): Promise<void>;
getContactIdList(selfId: string): Promise<string[]>;
getContact(contactId: string): Promise<PadplusContactPayload | null | undefined>;
getContactPayload(contactId: string): Promise<PadplusContactPayload>;
searchContact(contactId: string): Promise<GrpcSearchContact>;
syncContacts(): Promise<void>;
/**
* Room Section
*/
setRoomTopic(roomId: string, topic: string): Promise<unknown>;
getRoomQrcode(roomId: string): Promise<string>;
getRoomIdList(): Promise<string[]>;
getRoomMemberIdList(roomId: string): Promise<string[]>;
getRoomInfo(roomId: string): Promise<PadplusRoomPayload>;
getRoom(roomId: string): Promise<PadplusRoomPayload | null | undefined>;
getRoomMembers(roomId: string): Promise<PadplusRoomMemberMap>;
deleteRoomMember(roomId: string, contactId: string): Promise<void>;
setAnnouncement(roomId: string, announcement: string): Promise<string>;
getAnnouncement(roomId: string): Promise<string>;
roomAddMember(roomId: string, memberId: string): Promise<void>;
createRoom(topic: string, memberIdList: string[]): Promise<string>;
quitRoom(roomId: string): Promise<void>;
/**
*
* room event
*
*/
roomInvitationRawPayload(roomInvitationId: string): Promise<import("../schemas").PadplusRoomInvitationPayload>;
/**
* Friendship Section
*/
getFriendship(friendshipId: string): Promise<import("wechaty-puppet").FriendshipPayloadConfirm | import("wechaty-puppet").FriendshipPayloadReceive | import("wechaty-puppet").FriendshipPayloadVerify | undefined>;
confirmFriendship(contactId: string, encryptUserName: string, ticket: string): Promise<void>;
saveFriendship(friendshipId: string, friendship: FriendshipPayload): Promise<void>;
}
export default PadplusManager;
//# sourceMappingURL=padplus-manager.d.ts.map