forked from CloudBotIRC/CloudBotLegacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbot.py
38 lines (29 loc) · 838 Bytes
/
cloudbot.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
#!/usr/bin/env python
from core import bot
import os
import sys
import signal
# check python version
if sys.version_info < (2, 7, 0):
print "CloudBot requires Python 2.7 or newer."
sys.exit(1)
# set up enviroment
os.chdir(sys.path[0] or '.') # do stuff relative to the install directory
# this is not the code you are looking for
if os.path.exists(os.path.abspath('lib')):
sys.path += ['lib']
print 'CloudBot2 <http://git.io/cloudbotirc>'
def exit_gracefully(signum, frame):
cloudbot.stop()
# store the original SIGINT handler
original_sigint = signal.getsignal(signal.SIGINT)
signal.signal(signal.SIGINT, exit_gracefully)
# create new bot object
cloudbot = bot.Bot()
cloudbot.run()
if cloudbot.do_restart:
# this kills the bot
# TODO: make it not just kill the bot
sys.exit()
else:
sys.exit()