-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
34 lines (28 loc) · 1.21 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from typing import Optional
from mainloop import MainLoop
from telegram.auth.api import APIAuth
from telegram.auth.base import StaticSecrets
from telegram.auth.schemes.development import TelegramDevelopment
from telegram.client import TelegramClient
from telegram.tgmodules.getcode import GetAuthCode
from telegram.tgmodules.userinfo import UserInfo
from telegram.util import Environment
def main():
core = MainLoop(Environment.Development)
def testClientForClosure(phonenumber, username: Optional[str]=None, secrets: Optional[StaticSecrets]=None):
scheme = TelegramDevelopment(phonenumber, core.API_ID, core.API_HASH, "accounts/" + phonenumber, secrets)
return TelegramClient(APIAuth(phonenumber, scheme), [
UserInfo(phonenumber, core.accounts, username),
GetAuthCode()
])
async def onStart():
for account in await core.accounts.getAccounts():
await core.addClient(testClientForClosure(
account.phone_number,
account.username,
None if account.two_factor_password is None else StaticSecrets(account.two_factor_password)
))
# core.addClient(testClientForClosure(TelegramDevelopment.generate_phone(), None, False))
core.mainLoop(onStart, testClientForClosure)
if __name__ == "__main__":
main()