Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multiple accounts (Airgram instances) with TdLib #77

Closed
volodalexey opened this issue Jan 26, 2020 · 2 comments
Closed

Use multiple accounts (Airgram instances) with TdLib #77

volodalexey opened this issue Jan 26, 2020 · 2 comments

Comments

@volodalexey
Copy link
Contributor

Issue type:

[x] question

Airgram version:

[x] 2.3.0

TDLib version:

[x] 1.5.0

Steps to reproduce or a small repository showing the problem:

How can I run Airgram as a bot and Airgram as a user at the same time?
If I use this (the same apiId and apiHash):

import { Airgram, Auth } from 'airgram';

const apiId = '...';
const apiHash = '...';
const tdLibPath = '...';

const airgramUser = new Airgram({
  apiId,
  apiHash,
  command: tdLibPath,
  databaseDirectory: '.../userdb',
  logVerbosityLevel: 2,
});

airgramUser.use(
  new Auth({
      phoneNumber: '...',
      code: '...',
  }),
);

const airgramBot = new Airgram({
  apiId,
  apiHash,
  command: tdLibPath,
  databaseDirectory: '.../botdb',
  logVerbosityLevel: 2,
});

airgramBot.use(
  new Auth({
      token: '...'
  }),
);

const userInfo = await airgramUser.api.getMe();
const botInfo = await airgramBot.api.getMe();

I get an error:

[ 0][t 0][1580065911.360865116][Client.cpp:272]	Check `!is_locked` failed

I see that this is possible here

One TDLib Client can manage only one account, but there is no limit on number of clients that can be created in one process. So you can create as much TDLib Clients as you want and initialize them with different database and file folders for different accounts.

@volodalexey volodalexey changed the title Use multiple accounts with TdLib Use multiple accounts (Airgram instances) with TdLib Jan 26, 2020
@esindger
Copy link
Collaborator

esindger commented Feb 1, 2020

Each Airgram instance creates new TDLib client. Perhaps it is not a cause of the error. Have you seen this issue?

@volodalexey
Copy link
Contributor Author

volodalexey commented Feb 1, 2020

I do not know why, but migration to the version 3.0.2 solved this issue too. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants