This repository was archived by the owner on Jun 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (41 loc) · 1.23 KB
/
main.py
File metadata and controls
47 lines (41 loc) · 1.23 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
import os
import sys
import settings
import telegram
import random
import re
import twitter_
from util import press_enter
import converter
def main():
"""Main function of the program.
:return: None
"""
if os.name == 'nt':
from util import download_ffmpeg
download_ffmpeg()
random.seed()
cfg = settings.Settings()
while True:
try:
tgclass = telegram.TGBot(cfg)
tg = tgclass.bot
print("Bot successfully started. Do CTRL-C to stop.")
if cfg.telegram_user_id is None:
link_key = ""
for i in range (0, 6):
link_key = link_key + str(random.randint(0,9))
print("Please send your bot the following code as a Telegram message: " + link_key)
tgclass.set_auth_code(link_key)
tg.polling()
tg.stop_bot()
print("Bot stopped. It may be because you pressed CTRL-C or because an error occurred. Press enter.")
press_enter()
cfg.edit_settings()
except ValueError as e:
print("Error. " + e.args)
sys.exit()
except KeyboardInterrupt:
pass
if __name__ == "__main__":
main()