@madzoffc/baileys-shard
Version:
A lightweight baileys multi session for whatsapp bot.
115 lines (105 loc) • 3.1 kB
text/typescript
import { EventEmitter } from 'events';
interface ShardInfoConstructorParams {
id: string | number;
index: number;
total: number;
phoneNumber?: string | null;
status?: string;
}
interface ShardInfoUpdateFields {
id?: string | number;
index?: number;
total?: number;
phoneNumber?: string | null;
status?: string;
}
interface ShardOptions {
id?: string;
phoneNumber?: string;
socket?: any;
}
interface ShardConfig {
session?: string;
}
declare class ShardInfo {
id: string | number;
index: number;
total: number;
phoneNumber: string | null;
status: string;
updatedAt: Date;
constructor({ id, index, total, phoneNumber, status }: ShardInfoConstructorParams);
update(fields?: ShardInfoUpdateFields): void;
}
type ShardInfo$1_ShardInfo = ShardInfo;
declare const ShardInfo$1_ShardInfo: typeof ShardInfo;
declare namespace ShardInfo$1 {
export { ShardInfo$1_ShardInfo as ShardInfo };
}
declare class ShardManager extends EventEmitter {
#private;
private _patched?;
constructor(config?: ShardConfig);
checkSessionStatus(sessionDirectory: string): Promise<{
exists: boolean;
registered: boolean;
valid: boolean;
reason?: string;
}>;
validateAndCleanSession(sessionDirectory: string): Promise<void>;
cleanupCorruptSessions(): Promise<void>;
private setupShardEventHandlers;
createShard(options?: ShardOptions): Promise<{
id: string;
sock: any;
}>;
recreateShard(options: {
id: string;
clearSession?: boolean;
retryCount?: number;
forceRecreate?: boolean;
} & Partial<ShardOptions>): Promise<{
id: string;
sock: any;
}>;
getSessionInfo(id: string): Promise<{
exists: boolean;
registered: boolean;
valid: boolean;
reason?: string;
}>;
connect(id: string): Promise<{
id: string;
sock: any;
}>;
stopShard(id: string): Promise<boolean>;
loadAllShards(): Promise<string[]>;
socket(id: string): any | undefined;
shard(id: string): EventEmitter | null;
onAny(listener: (event: string, ...args: any[]) => void): void;
getShardInfo(id: string): ShardInfo | null;
getAllShardInfo(): ShardInfo[];
}
type index_ShardManager = ShardManager;
declare const index_ShardManager: typeof ShardManager;
declare namespace index {
export { index_ShardManager as ShardManager };
}
declare class ShardError extends Error {
code: string;
constructor(message: string, code?: string);
}
declare const _default$1: {
ShardError: typeof ShardError;
};
type Error$1_ShardError = ShardError;
declare const Error$1_ShardError: typeof ShardError;
declare namespace Error$1 {
export { Error$1_ShardError as ShardError, _default$1 as default };
}
declare const _default: {
ShardManager: typeof ShardManager;
ShardInfo: typeof ShardInfo;
ShardError: typeof ShardError;
};
export { Error$1 as ShardError, ShardInfo$1 as ShardInfo, index as ShardManager, _default as default };