-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__main__.py
54 lines (37 loc) · 1021 Bytes
/
__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
50
51
52
53
54
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
HYDRABOT - "STAY HYDRATED" MESSENGER
A program to randomly generate and send Facebook messenges
which remind people to stay hydrated
(c) 2020 by Alexander Roidl (alexanderroidl@gmail.com)
"""
# Dependencies
import atexit
import colorama
# Local dependencies
from hydrabot_py import config
from hydrabot_py.lib import HydraBot
# Global variables
hydrabot = None
# Called on programs shutdown
def clean_up():
"""Clean up after execution"""
print('Cleaning up...')
if hydrabot is not None:
hydrabot.clean_up()
# Main method
def main():
colorama.init(autoreset=True)
# Create HydraBot instance based of configuration
global hydrabot
hydrabot = HydraBot(**config)
# Register exit handler
atexit.register(clean_up)
# Call main method by default
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
# Call exit function on keyboard interupt as well
clean_up()