-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall_bot.py
More file actions
executable file
·64 lines (52 loc) · 1.33 KB
/
install_bot.py
File metadata and controls
executable file
·64 lines (52 loc) · 1.33 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /usr/bin/env python
"""
install_bot.py
Installs a bot in the system.
usage:
./install_bot.py <username> <recoveryKey>
"""
import os
import sys
import time
import string
import random
from flow import Flow
if len(sys.argv) < 3:
print("usage: %s <username> <recoveryKey>" % sys.argv[0])
sys.exit(os.EX_USAGE)
username = sys.argv[1]
password = sys.argv[2]
flow = Flow()
print("* Checking if account is already installed...")
try:
flow.start_up(
username=username,
)
print("* Account already installed.")
sys.exit(0)
except Flow.FlowError as flow_err:
pass
print("* Account not installed, trying local device creation...")
try:
flow.create_device(
username=username,
password=password,
device_name="test-device",
)
time.sleep(2)
print("* Account has been installed locally.")
except Flow.FlowError as flow_err:
pass
print("* Account does not exist, creating account...")
try:
flow.create_account(
username=username,
password=password,
device_name="test_device",
phone_number="".join(random.choice(string.digits) for _ in range(10)),
)
time.sleep(2)
print("* Account has been successfully created and installed locally.")
sys.exit(0)
except Flow.FlowError as flow_err:
print("# Error: Account couldn't be installed.")