Esempio n. 1
0
def handle_cloudmeet(bot, ievent):
    if not ievent.rest:
        ievent.missing('<nodename>')
        return
    name = ievent.rest
    node = cloud.byname(name)
    if not node:
        ievent.reply('%s is not a cloud node' % name)
        return
    if not node.client.host:
        ievent.reply("can't determine host of %s" % name)
        return
    try:
        if not users.exist(name):
            users.add(name, [
                "cloud@%s" % node.client.host,
            ], [
                'CLOUD',
            ])
            ievent.reply("%s (%s) added to database" %
                         (name, node.client.host))
        else:
            ievent.reply("%s node already exists" % name)
    except Exception, ex:
        ievent.reply('error adding %s to the database: %s' % (name, str(ex)))
Esempio n. 2
0
def addrecord_POST(server, request):
    try:
        input = getpostdata(request)
        name = input['name']
    except KeyError:
        rlog(5, host, 'addrecord .. no name provided')
        return dumps('no name provided')
    rlog(10, 'cloud', 'addrecord request for %s (%s)' % (name, request.ip)) 
    try:
        if not users.exist(name):
            users.add(name, ["cloud@%s" % request.ip, ], ['CLOUD', ])
            return dumps("%s added" % name)
    except Exception, ex:
        pass
Esempio n. 3
0
def handle_register(bot, ievent):
    if not cfg.get('enable'):
        ievent.reply('register is not enabled')
        return
    if 'OPER' in cfg.get('perms'):
        ievent.reply("can't use OPER permission in register command")
        return
    if not ievent.rest:
        ievent.missing('<username>')
        return
    name = ievent.args[0]
    if users.exist(name):
        ievent.reply('we already have a user with the name %s' % name)
        return
    uh = ievent.userhost
    username = users.getname(uh)
    if username:
        ievent.reply('we already have a user with userhost %s' % uh)
        return
    if users.add(name, [uh, ], perms = cfg.get('perms')):
        throttlestate['level'][uh] = 10
        ievent.reply('%s added to the user database with permission %s' % \
(uh, cfg.get('perms')))
    else:
        ievent.reply('error adding %s (%s) in the user database' % (name, uh))
Esempio n. 4
0
def handle_testplugs(bot, msg):
    if not ievent.isdcc:
        ievent.reply('use this command in a /dcc chat with the bot')
        return
    gozerbot.utils.url.geturl = dummy
    gozerbot.utils.url.geturl2 = dummy
    gozerbot.generic.geturl = dummy
    gozerbot.generic.geturl2 = dummy
    if msg.rest:
        match = msg.rest
    else:
        match = ""
    try:
        users.add('test', ['test@test',], ['USER', 'OPER'])
    except Exception, ex:
        pass
Esempio n. 5
0
def handle_meet(bot, ievent):
    """ user-meet <nick> .. introduce a new user to the bot """
    try:
        nick = ievent.args[0].lower()
    except IndexError:
        ievent.missing('<nick>')
        return
    if users.exist(nick):
        ievent.reply('there is already a user with username %s' % nick)
        return
    userhost = getwho(bot, nick)
    if not userhost:
        ievent.reply("can't find userhost of %s" % nick)
        return
    username = users.getname(userhost)
    if username:
        ievent.reply('we already have a user with userhost %s (%s)' % \
(userhost, username))
        return
    result = 0
    try:
        result = users.add(nick.lower(), [userhost, ], ['USER', ])
    except Exception, ex:
        ievent.reply('ERROR: %s' % str(ex))
        return
Esempio n. 6
0
def addrecord_POST(server, request):
    try:
        input = getpostdata(request)
        name = input['name']
    except KeyError:
        rlog(5, host, 'addrecord .. no name provided')
        return dumps('no name provided')
    rlog(10, 'cloud', 'addrecord request for %s (%s)' % (name, request.ip))
    try:
        if not users.exist(name):
            users.add(name, [
                "cloud@%s" % request.ip,
            ], [
                'CLOUD',
            ])
            return dumps("%s added" % name)
    except Exception, ex:
        pass
Esempio n. 7
0
def handle_testplugs(bot, msg):
    if not ievent.isdcc:
        ievent.reply('use this command in a /dcc chat with the bot')
        return
    gozerbot.utils.url.geturl = dummy
    gozerbot.utils.url.geturl2 = dummy
    gozerbot.generic.geturl = dummy
    gozerbot.generic.geturl2 = dummy
    if msg.rest:
        match = msg.rest
    else:
        match = ""
    try:
        users.add('test', [
            'test@test',
        ], ['USER', 'OPER'])
    except Exception, ex:
        pass
Esempio n. 8
0
def handle_cloudmeet(bot, ievent):
    if not ievent.rest:
        ievent.missing('<nodename>')
        return
    name = ievent.rest
    node = cloud.byname(name)
    if not node:
       ievent.reply('%s is not a cloud node' % name)
       return
    if not node.client.host:
       ievent.reply("can't determine host of %s" % name)
       return
    try:
        if not users.exist(name):
            users.add(name, ["cloud@%s" % node.client.host, ], ['CLOUD', ])
            ievent.reply("%s (%s) added to database" % (name, node.client.host))
        else:
            ievent.reply("%s node already exists" % name)
    except Exception, ex:
        ievent.reply('error adding %s to the database: %s' % (name, str(ex)))
Esempio n. 9
0
def handle_adduser(bot, ievent):
    """ user-aadd <name> <userhost> .. introduce a new user to the bot """
    try:
        (name, userhost) = ievent.args
    except ValueError:
        ievent.missing('<name> <userhost>')
        return
    username = users.getname(userhost)
    if username:
        ievent.reply('we already have a user with userhost %s (%s)' % \
(userhost, username))
        return
    result = 0
    try:
        result = users.add(name.lower(), [userhost, ], ['USER', ])
    except Exception, ex:
        ievent.reply("ERROR: %s" % str(ex))
        return
Esempio n. 10
0
def anoncb(bot, ievent):
    try:
        username = users.getname(ievent.userhost)
        if not username:
            if users.add(ievent.nick, [ievent.userhost, ], perms = \
cfg.get('perms')):
                throttlestate['level'][ievent.userhost] = 10
                throttlestate.save()
                rlog(100, 'register', 'added %s (%s)' % (ievent.nick, \
ievent.userhost))
                bot.say(
                    ievent.nick, "you have been added to the bots \
user database .. see %shelp for help" % bot.channels[ievent.channel]['cc'])
            else:
                rlog(
                    100, 'register', "username %s already exists .. can't \
add %s" % (ievent.nick, ievent.userhost))
    except Exception, ex:
        rlog(100, 'register', 'failed to add %s (%s) .. reason: %s' % \
(ievent.nick, ievent.userhost, str(ex)))
Esempio n. 11
0
def anoncb(bot, ievent):
    try:
        username = users.getname(ievent.userhost)
        if not username:
            if users.add(ievent.nick, [ievent.userhost], perms=cfg.get("perms")):
                throttlestate["level"][ievent.userhost] = 10
                throttlestate.save()
                rlog(100, "register", "added %s (%s)" % (ievent.nick, ievent.userhost))
                bot.say(
                    ievent.nick,
                    "you have been added to the bots \
user database .. see %shelp for help"
                    % bot.channels[ievent.channel]["cc"],
                )
            else:
                rlog(
                    100,
                    "register",
                    "username %s already exists .. can't \
add %s"
                    % (ievent.nick, ievent.userhost),
                )
    except Exception, ex:
        rlog(100, "register", "failed to add %s (%s) .. reason: %s" % (ievent.nick, ievent.userhost, str(ex)))
Esempio n. 12
0
enable_logging()
startmaindb()
cfg = Config()
bot = Bot(cfg)
bot.channels.setdefault("#test", {})
bot.channels.setdefault("#dunkbots", {})
bot.userhosts["dunker"] = "*****@*****.**"
bot.userhosts["test"] = "test@test"
bot.server = "localhost"
bot.port = 6667
fleet.addbot(bot)
plugins.regplugins()
time.sleep(5)

try:
    users.add("test", ["test@test"], ["OPER", "USER", "QUOTE", "MAIL"])
except Exception, ex:
    pass

try:
    users.setemail("test", "*****@*****.**")
except Exception, ex:
    pass


def gendoc(f):
    base = os.path.basename(f).replace(".py", "")
    print "=" * (len(base) + 2)
    print " %s " % base.upper()
    print "=" * (len(base) + 2)
    print "| \n"
Esempio n. 13
0

def stop(x, y):
    die()


# register SIGTERM handler to stop
signal.signal(signal.SIGTERM, stop)
signal.signal(signal.SIGINT, stop)

try:
    users.delete('test')
except:
    pass

users.add('test', ['test@test', ], ['USER', 'OPER', 'ALIAS', 'FORGET', \
'QUOTE'])

bot = Bot('test@test')
bot.channels.data['#dunkbots'] = {}
bot.userhosts['dunker'] = 'test@test'
plugins.regplugins()
time.sleep(5)

queues = []


def qreader():
    while 1:
        for i in queues:
            time.sleep(0.01)
            try:
Esempio n. 14
0
'webserver', 'wikipedia']

config['loglevel'] = 100
enable_logging()

sys.path.insert(0, os.getcwd())

# stop function
def stop(x, y):
    os._exit(0)

# register SIGTERM handler to stop
signal.signal(signal.SIGTERM, stop)

try:
    users.add('test', ['test@test', ], ['OPER', 'USER', 'QUOTE'])
except Exception, ex:
    pass

what = None
try:
    what = sys.argv[1]
except IndexError:
    pass

try:
    if what:
        if what == 'net':
            names =  map(lambda a: a[:-3], glob.glob('tests/*.py'))
            tmp = []
            for i in names:
Esempio n. 15
0
    for i in queues:
        teller += 1
        tmpstr += "%s) %s " % (teller, i[2])
    print tmpstr
    die()

# register SIGTERM handler to stop
signal.signal(signal.SIGTERM, stop)
signal.signal(signal.SIGINT, stop)

try:
    users.delete('test')
except:
    pass

users.add('test', ['test@test', ], ['USER', 'OPER', 'ALIAS', 'FORGET', \
'QUOTE'])

bot = Bot('test@test')
bot.channels.data['#dunkbots'] = {}
bot.userhosts['dunker'] = 'test@test'
print "loading plugins"
plugins.regplugins()

queues = []

def qreader():
    while 1:
        time.sleep(0.01)
        for i in queues:
            (testnr, teller, cmnd, q) = i
            try:
Esempio n. 16
0
cfg.define('whitelist', [])
cfg.define('whitelistenable', 1)
cfg.define('blacklist', [])
cfg.define('showplugs', ['infoitems', 'karma', 'quotes'])
cfg.define('denyplugs', [])
cfg.define('deleteenable', 0)

#cfg.syncold(datadir + os.sep + 'web')
doit = cfg.get('webenable')
if not doit:
    rlog(10, 'webserver', 'not enabled')
else:
    if not users.getname('web@web'):
        users.add('web', [
            'web@web',
        ], [
            'WEB',
        ])
webhostname = cfg.get('webhost')
webport = cfg.get('webport')


def init():
    """ init webserver plugin """
    global httpd
    try:
        if doit:
            httpd = BotHTTPServer((webhostname, webport),
                                  BotHTTPRequestHandler)
    except Exception, ex:
        rlog(10, 'webserver', "can't start server: %s" % str(ex))
Esempio n. 17
0
enable_logging()

sys.path.insert(0, os.getcwd())


# stop function
def stop(x, y):
    os._exit(0)


# register SIGTERM handler to stop
signal.signal(signal.SIGTERM, stop)

try:
    users.add('test', [
        'test@test',
    ], ['OPER', 'USER', 'QUOTE'])
except Exception, ex:
    if 'Duplicate entry' in str(ex):
        pass
    else:
        handle_exception()

what = None
try:
    what = sys.argv[1]
except IndexError:
    pass

try:
    if what:
Esempio n. 18
0
cfg.define('webport', 8088)
cfg.define('webhost', '')
cfg.define('whitelist', [])
cfg.define('whitelistenable', 1)
cfg.define('blacklist', [])
cfg.define('showplugs', ['infoitems', 'karma', 'quotes'])
cfg.define('denyplugs', [])
cfg.define('deleteenable', 0)

#cfg.syncold(datadir + os.sep + 'web')
doit =  cfg.get('webenable')
if not doit:
    rlog(10, 'webserver', 'not enabled')
else:
    if not users.getname('web@web'):
        users.add('web', ['web@web', ], ['WEB', ])
webhostname = cfg.get('webhost')
webport = cfg.get('webport')

def init():
    """ init webserver plugin """
    global httpd
    try:
        if doit:
            httpd = BotHTTPServer((webhostname, webport), BotHTTPRequestHandler)
    except Exception, ex:
        rlog(10, 'webserver', "can't start server: %s" % str(ex))
        return 0
    if httpd:
        webplugs = gozer_import('gozerplugs.webserver.webplugs')
        for i in webplugs.__all__: