-
Notifications
You must be signed in to change notification settings - Fork 2
/
tgc_auth.cpp
51 lines (38 loc) · 1.33 KB
/
tgc_auth.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "tgclient.h"
#include "apisecrets.h"
#include "tlschema.h"
TgLongVariant TgClient::authSendCode(QString phoneNumber)
{
TGOBJECT(TLType::AuthSendCodeMethod, method);
TGOBJECT(TLType::CodeSettings, codeSettings);
method["settings"] = codeSettings;
method["phone_number"] = phoneNumber;
#if defined(KUTEGRAM_API_ID)
method["api_id"] = KUTEGRAM_API_ID;
#else
#error "Please, specify an API id."
#endif
#if defined(KUTEGRAM_API_HASH)
method["api_hash"] = KUTEGRAM_API_HASH;
#else
#error "Please, specify an API hash."
#endif
return sendObject<&writeTLMethodAuthSendCode>(method);
}
TgLongVariant TgClient::authSignIn(QString phoneNumber, QString phoneCodeHash, QString phoneCode)
{
TGOBJECT(TLType::AuthSignInMethod, method);
method["phone_number"] = phoneNumber;
method["phone_code_hash"] = phoneCodeHash;
method["phone_code"] = phoneCode;
return sendObject<&writeTLMethodAuthSignIn>(method);
}
TgLongVariant TgClient::authSignUp(QString phoneNumber, QString phoneCodeHash, QString firstName, QString lastName)
{
TGOBJECT(TLType::AuthSignUpMethod, method);
method["phone_number"] = phoneNumber;
method["phone_code_hash"] = phoneCodeHash;
method["first_name"] = firstName;
method["last_name"] = lastName;
return sendObject<&writeTLMethodAuthSignUp>(method);
}