-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·49 lines (38 loc) · 1.53 KB
/
main.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import argparse
import sys
import vkrine
from vkrine.bots import UserBot, GroupBot
from vkrine.utils import load_token, print_logo, create_dirs_if_not_exists, print_version
def init():
parser = argparse.ArgumentParser(description="VKRINE Bot default runner")
parser.add_argument("-a", "--architecture", default="group", choices=["group", "user"], metavar='type',
help="Select bot realization")
parser.add_argument("-l", "--logger-level", default=vkrine.INFO, choices=vkrine.LEVELS,
metavar='type', help="Select logger log level")
parser.add_argument("-r", "--runtime", metavar='rundir',
help="Select runtime directory, default 'runtime_<architecture>'")
parser.add_argument("-v", "--version", required=False, action='store_true', help='Show bot version and exit')
return parser.parse_args(sys.argv[1:])
if __name__ == "__main__":
print_logo()
args = init()
if args.version:
print_version()
sys.exit(0)
vkrine.args = args
architecture = args.architecture
if args.runtime:
runtime = args.runtime
else:
runtime = "runtime_" + architecture
create_dirs_if_not_exists(runtime)
if architecture == "user":
bot = UserBot(load_token("%s/token" % runtime, True), runtime=runtime)
else:
token = load_token("%s/token" % runtime)
bot = GroupBot(token[0], token[1], runtime=runtime)
vkrine.bot = bot
bot.login()
bot.load_modules()
bot.start()
bot.join()