-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
66 lines (49 loc) · 2.01 KB
/
Main.py
File metadata and controls
66 lines (49 loc) · 2.01 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
import threading
import SeleniumPart.Selenium_main as selenium
import TelegramPart.Telegram_main as telegram
import TelegramPart.libs.keyboard_presets as keyboard
import time
async def main():
pass
def starting(users):
start_users = list((user for user in users if user.state == "start_checking"))
for x in start_users:
x.state = "starting"
for x in start_users:
if (x.login == " " or x.password == " "):
x.session = selenium.Checker(x.url)
else:
x.session = selenium.Checker(x.url, x.login, x.password)
answer = x.session.start()
if(answer == "error on start"):
x.state = "none"
telegram.send_message("Error take place on starting, maybe bad login credentials", x.id, keyboard.menu_keyboard())
continue
telegram.send_message("Bot started", x.id, keyboard.on_check_keyboard())
x.state = "on_check"
def check(users):
check_users = (user for user in users if user.state == "on_check")
for x in check_users:
answer = x.session.check()
if (answer == "error on check"):
x.state = "none"
telegram.send_message("Error take place while checking, maybe meeting ended\nHowever, there last records\n" + '\n'.join(map(str, x.session.participants)),
x.id,
keyboard.menu_keyboard())
continue
def close(users):
check_users = (user for user in users if user.state == "on_end")
for x in check_users:
telegram.send_message("List of participants:\n" +'\n'.join(map(str, x.session.participants)) + "\nBot stopped", x.id, keyboard.menu_keyboard())
x.session.close()
x.state = "none"
if __name__ == '__main__':
user = []
print("Starting bot")
while True:
telegram.look_for_update()
x = threading.Thread(target=starting, args=(telegram.users,))
x.start()
check(telegram.users)
close(telegram.users)
time.sleep(1)