27
27
sys.path.insert(0, os.getcwd())
28
28
sys.path.insert(1, os.path.abspath(os.path.join(os.getcwd(), 'myplugs', 'addons')))
38
(options, rest) = getopt.getopt(sys.argv[1:], 'abur:')
48
except getopt.GetoptError, ex:
30
from optparse import OptionParser
32
parser = OptionParser(usage='usage: %prog [options]', version='%prog 0.8.1')
34
parser.add_option('', '-a', action='store_true', default=False, dest='doascii',
35
help="Use ASCII as the default encoding instead of UTF-8")
36
parser.add_option('', '-b', action='store_true', default=False, dest='dobackup',
38
parser.add_option('', '-u', action='store_false', default=True, dest='doumode',
39
help="Check permissions on the gozerdata folder")
40
parser.add_option('', '-r', type='string', default=False, dest='doresume',
42
help="Resume the bot from the folder specified")
44
opts, args = parser.parse_args()
53
49
sys.setdefaultencoding('utf-8')
55
51
sys.setcheckinterval(50)
56
52
socket.setdefaulttimeout(30)
59
from gozerbot.generic import rlog, handle_exception, enable_logging, \
61
from gozerbot.config import config, writeconfig
54
from gozerbot.generic import handle_exception
57
from gozerbot.config import config, writeconfig, writeloadlist
58
from gozerbot.datadir import makedirs
59
from gozerbot.generic import enable_logging
70
from gozerbot.generic import rlog, handle_exception, checkpermissions
62
71
from gozerbot.bot import Bot
63
72
from gozerbot.fleet import fleet
64
73
from gozerbot.plugins import plugins
65
74
from gozerbot.eventhandler import mainhandler
66
75
from gozerbot.users import users
67
76
from gozerbot.thr import start_new_thread
68
from gozerbot.datadir import makedirs
69
77
from gozerbot.partyline import partyline
70
78
from gozerbot.exit import globalshutdown
71
79
except Exception, ex:
76
83
import time, signal, gc, types
86
93
signal.signal(signal.SIGTERM, dostop)
92
96
rlog(10, 'GOZERBOT', 'starting %s' % config['version'])
93
rlog(10, 'gozerbot', 'default encoding is %s' % sys.getdefaultencoding())
97
rlog(5, 'gozerbot', 'default encoding is %s' % sys.getdefaultencoding())
96
100
umask = config['umask']
98
102
checkpermissions('gozerdata', 0700)
119
123
owner += config['owneruserhost']
122
username = users.getname(i)
124
if not users.merge('owner', i):
125
users.add('owner', [i, ], perms = ['USER', 'OPER'])
127
username = users.getname(i)
129
if not users.merge('owner', i):
130
users.add('owner', [i, ], perms = ['USER', 'OPER'])
131
except Exception, ex:
127
135
# register plugins
128
136
start_new_thread(plugins.regplugins, ())
133
141
from gozerbot.jabberbot import Jabberbot
134
142
except ImportError:
135
print "no xmpppy installed"
137
bot = Jabberbot('jabbermain')
145
bot = Jabberbot('jabbermain', config['jabberowner'])
138
146
bot.host = config['jabberhost']
139
147
bot.user = config['jabberuser']
140
148
bot.password = config['jabberpass']
143
bot = Bot(config['owneruserhost'])
153
if not config['ircdisable']:
154
bot = Bot('main', config['owneruserhost'])
144
155
bot.nick = config['nick'] or 'gb1'
145
156
bot.server = config['server'] or 'localhost'
146
157
bot.port = config['port'] or 6667
147
bot.password = config['password']
148
bot.ipv6 = config['ipv6']
158
bot.password = config['password'] or ""
159
bot.ipv6 = config['ipv6'] or 0
160
bot.ssl = config['ssl'] or 0
152
if doresume and os.path.isfile(doresume):
153
fleet.resume(doresume)
164
if opts.doresume and os.path.isfile(opts.doresume):
165
fleet.resume(opts.doresume)
154
166
fleet.startok.wait()
155
partyline.resume(doresume)
156
os.unlink(doresume) # bye
167
partyline.resume(opts.doresume)
168
os.unlink(opts.doresume) # bye