-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathcc.py
More file actions
33 lines (26 loc) · 831 Bytes
/
cc.py
File metadata and controls
33 lines (26 loc) · 831 Bytes
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
#!/usr/bin/env python3
# C.C. - telegram bot
import importlib
import sys
import os
from optparse import OptionParser
os.chdir(sys.path[0])
from telegram import Bot
def main(settings_module):
settings = importlib.import_module(settings_module)
bot = Bot(settings)
bot.start()
if __name__ == '__main__':
parser = OptionParser()
parser.add_option('-d', '--daemon', action='store_true', dest='daemon', default=False, help='Run in background')
parser.add_option('-s', '--settings', dest='settings', default='settings', help='Settings module')
options, _ = parser.parse_args()
if options.daemon:
pid = os.fork()
if pid == 0:
os.setsid()
pid = os.fork()
if pid == 0:
main(options.settings)
else:
main(options.settings)