Exemplo n.º 1
0
def main(argv=None):
    # Set up some custom exception handling; handle exceptions nicely using
    # the logger module
    sys.excepthook = eyearexception
    logger.getInstance().level = config.LOG_LEVEL

    # Set up the HTTP server
    reactor.listenTCP(config.HTTP_PORT, http.getInstance())

    # Reconnect users to their servers & channels
    users = database.get('users', {})
    for user in users:
        if 'servers' in user.keys():
            for server in user['servers']:
                try:
                    addr = server['addr']
                    chans = server['channels']
                    irc.connect(user['user'], addr, chans)
                except irc.UserNotConnected:
                    logger.e("%s couldn't connect to %s",
                             user['user'], server)
                    logger.trace()
    # Start doing MAGIC
    reactor.run()
Exemplo n.º 2
0
import plugins.mongodb
DATABASE_HANDLER = plugins.mongodb

# Stuff specific to the mongodb plugin
# Edit these if your mongodb is on a remote server
MONGO_HOST = 'localhost'
MONGO_PORT = 27017
MONGO_DBNAME = 'eyearesee'

# Make certain users admins or read_only
# (so you don't have to faff around editing the database directly)
# NOTE: This changes the users permissions in the database itself too.
import eyearelib.database as db
import eyearelib.permissions as permissions

for user in ADMINS:
    u = db.get('users', {'user': user})
    if len(u) > 0:
        u = u[0]
        eyearelib.logger.i("Making %s an admin", user)
        u['permissions'] = u['permissions'] | permissions.ADMIN
        db.set('users', u)

for user in READ_ONLY:
    u = db.get('users', {'user': user})
    if len(u) > 0:
        u = u[0]
        eyearelib.logger.i("Making %s a read-only user", user)
        u['permissions'] = u['permissions'] | (not permissions.WRITE)
        db.set('users', u)