Skip to content

How to create a custom session store ? #340

Answered by rojvv
itishermann asked this question in Q&A
Discussion options

You must be logged in to vote

Hello there, too, @itishermann!

Creating a custom session store is as easy as implementing your own session class by extending the abstract Session class which is in telegram/sessions.

Here's how you would implement your own session store:

import { Session } from "telegram/sessions";
import { AuthKey } from "telegram/crypto/AuthKey";

export class MySession extends Session {
  setDC(dcId: number, serverAddress: string, port: number) {
    // save dcId, serverAddress and port in your database
  }

  get dcId(): number {
    // return the saved dcId
  }

  get serverAddress(): string {
    // return the saved serverAddress
  }

  get port(): number {
    // return the saved port
  }

  get a…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by itishermann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants