Skip to content

Commit

Permalink
feat: allow cloning Api instances (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
KnorpelSenf authored Jun 3, 2024
1 parent d62a142 commit 9fbf2a1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/core/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,23 @@ export class Api<R extends RawApi = RawApi> {
readonly installedTransformers: () => Transformer<R>[];
};

/**
* Constructs a new instance of `Api`. It is independent from all other
* instances of this class. For example, this lets you install a custom set
* if transformers.
*
* @param token Bot API token obtained from [@BotFather](https://t.me/BotFather)
* @param options Optional API client options for the underlying client instance
* @param webhookReplyEnvelope Optional envelope to handle webhook replies
*/
constructor(
token: string,
config?: ApiClientOptions,
public readonly token: string,
public readonly options?: ApiClientOptions,
webhookReplyEnvelope?: WebhookReplyEnvelope,
) {
const { raw, use, installedTransformers } = createRawApi<R>(
token,
config,
options,
webhookReplyEnvelope,
);
this.raw = raw;
Expand Down

0 comments on commit 9fbf2a1

Please sign in to comment.