-
Notifications
You must be signed in to change notification settings - Fork 0
/
convertusers.py
41 lines (28 loc) · 1.15 KB
/
convertusers.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
from socbot.config import ConfigObj
from socbot.tools import validateConfig
from socbot.userdb import UserDB
if __name__ == "__main__":
users = ConfigObj('conf/users.conf', configspec='conf/users.spec', unrepr=True)
invalid = validateConfig(users)
if invalid:
log.error('\n'.join(invalid))
exit(1)
db = UserDB('conf/users.db')
for nick, config in users['users'].iteritems():
print "Found user %s" % nick
user = db.getUser(nick)
try:
user.register(nick, config['passhash'], config['email'])
print "Registered to DB."
except Exception:
print "User was already registered!"
reg = user.getRegistration(nick)
for perm in config['permissions']:
reg.addPerm(perm)
print "Added %s perm." % perm
for mask in config['hostmasks']:
reg.addHostmask(mask)
print "Added %s hostmask." % mask
print "-----"
db.saveSession()
print "New db saved as conf/users.db."