Ejemplo n.º 1
0
    ievent.done()

cmnds.add('admin-makebot', handle_adminmakebot, 'OPER')
examples.add('admin-makebot', 'create a bot', 'admin-makebot cmndxmpp xmpp')

## admin-stop command

def handle_adminstop(bot, ievent):
    """ no arguments - stop the bot. """
    if bot.isgae: ievent.reply("this command doesn't work on the GAE") ; return
    if bot.ownercheck(ievent.userhost): mainhandler.put(0, globalshutdown)
    else: ievent.reply("you are not the owner of the bot")
    
cmnds.add("admin-stop", handle_adminstop, "OPER")
examples.add("admin-stop", "stop the bot.", "stop")
setalias("qq", "admin-stop")

## admin-upgrade command

def handle_adminupgrade(bot, event):
    """ no arguments - upgrade from 0.5 to 0.6. """
    if not bot.isgae: event.reply("this command only works in GAE") ; return
    else: import google
    from jsb.lib.persist import JSONindb
    teller = 0
    props = JSONindb.properties()
    for d in JSONindb.all():
        try:
            dd = d.filename
            if not "gozerdata" in dd: continue
            if 'run' in dd: continue
Ejemplo n.º 2
0
def init():
    global db
    if not db: db = getmaindb()
    setalias('d', 't-done')
    setalias('tt', 't-time')
Ejemplo n.º 3
0
allowset = ["timesleep", "dbenable", "memcached"]

## cfg-set command

def handle_cfgset(bot, event):
    if len(event.args) != 3: event.missing("<configname> <variable> <value>") ; return
    name, var, value = event.args
    if not var in allowset: event.reply("setting %s is not allowed" % var) ; return
    if name == "main":
        if not getusers().allowed(event.userhost, "OPER"): event.reply("you need to have OPER permissions to edit the mainconfig.") ; return
        mcfg = getmainconfig()
        logging.info("using %s" % mcfg.cfile)
        try: mcfg[var] = int(value)
        except ValueError: mcfg[var] = value
        mcfg.save()
        event.done()
    else: event.reply('we current only support editing the "main" config.') ; return

cmnds.add("cfg-set", handle_cfgset, ["OPER", "USER"])
setalias("mcfg-set", "cfg-set main")

def handle_cfg(bot, event):
    if len(event.args) != 1: event.missing("<configname>") ; return
    name = event.args[0]
    if name == "main":
        if not getusers().allowed(event.userhost, "OPER"): event.reply("you need to have OPER permissions to edit the mainconfig.") ; return
        event.reply(getmainconfig().fordisplay())

cmnds.add("cfg", handle_cfg, ["OPER", "USER"])
setalias("mcfg", "cfg main")
Ejemplo n.º 4
0
    cfg = getmainconfig()
    if cfg.dbenable: version += " " + cfg.dbtype.upper()
    if ievent.rest and ievent.rest == "repo":
        try: 
            from mercurial import context, hg, node, repo, ui
            repository = hg.repository(ui.ui(), '.')
            ctx = context.changectx(repository)
            tip = str(ctx.rev())
        except: tip = None
        if tip: version2 = version + " HG " + tip
    else: version2 = version
    ievent.reply(version2)

cmnds.add('version', handle_version, ['USER', 'GUEST'])
examples.add('version', 'show version of the bot', 'version')
setalias('v', "version")

## short command

def handle_short(bot, ievent):
    """ arguments: <cmnd> - give short possibilities for a command. """
    try: cmnd = ievent.args[0]
    except IndexError: ievent.missing('<cmnd>') ; return
    try: ievent.reply("short commands for %s" % cmnd, getshorttable()[cmnd])
    except KeyError: ievent.reply("no commands found for %s" % cmnd)

cmnds.add('short', handle_short, ['USER', 'GUEST'])
examples.add('short', 'find full comamands', 'short admin-exceptions')

## whereis command
Ejemplo n.º 5
0
def init():
    global db
    from jsb.db import getmaindb
    db = getmaindb()
    setalias('k', 'karma2-get')
    setalias('k-del', 'karma2-del')
    setalias('whyup', 'karma2-whyup')
    setalias('whydown', 'karma2-whydown')
    setalias('good', 'karma2-good')
    setalias('bad', 'karma2-bad')
    setalias('whoup', 'karma2-whoup')
    setalias('whodown', 'karma2-whodown')
    setalias('k-search', 'karma2-search')
    setalias('whatup', 'karma2-whatup')
    setalias('whatdown', 'karma2-whatdown')
Ejemplo n.º 6
0
def init():
    global db
    from jsb.db import getmaindb
    db = getmaindb()
    setalias('aq', 'quote2-add')
    setalias('wq', 'quote2-who')
    setalias('dq', 'quote2-del')
    setalias('lq', 'quote2-last')
    setalias('2q', 'quote2-2')
    setalias('iq', 'quote2-id')
    setalias('q', 'quote2')
    setalias('sq', 'quote2-search')
    setalias('cq', 'quote2-count')
    setalias('q-good', 'quote2-good')
    setalias('q-bad', 'quote2-bad')
Ejemplo n.º 7
0
def init():
    global db
    if not db: db = getmaindb()
    setalias('d', 't-done')
    setalias('tt', 't-time')
Ejemplo n.º 8
0
## admin-stop command


def handle_adminstop(bot, ievent):
    """ no arguments - stop the bot. """
    ievent.untildone = True
    if bot.ownercheck(ievent.userhost): mainhandler.put(0, globalshutdown)
    else:
        ievent.reply("you are not the owner of the bot")
        return
    ievent.done(silent=True)


cmnds.add("admin-stop", handle_adminstop, "OPER")
examples.add("admin-stop", "stop the bot.", "stop")
setalias("qq", "admin-stop")

## admin-setstatus command


def handle_adminsetstatus(bot, event):
    """ arguments: <status> [<statustxt>] - set the status of the bot (xmpp). """
    if bot.type != "sxmpp":
        event.reply("this command only works on sxmpp bots (for now)")
        return
    if not event.rest:
        event.missing("<status> [<show>]")
        return
    status = event.args[0]
    try:
        show = event.args[1]
Ejemplo n.º 9
0
def init():
    global db
    from jsb.db import getmaindb
    db = getmaindb()
    setalias('k', 'karma2-get')
    setalias('k-del', 'karma2-del')
    setalias('whyup', 'karma2-whyup')
    setalias('whydown', 'karma2-whydown')
    setalias('good', 'karma2-good')
    setalias('bad', 'karma2-bad')
    setalias('whoup', 'karma2-whoup')
    setalias('whodown', 'karma2-whodown')
    setalias('k-search', 'karma2-search')
    setalias('whatup', 'karma2-whatup')
    setalias('whatdown', 'karma2-whatdown')
Ejemplo n.º 10
0
    if ievent.rest and ievent.rest == "repo":
        try:
            from mercurial import context, hg, node, repo, ui
            repository = hg.repository(ui.ui(), '.')
            ctx = context.changectx(repository)
            tip = str(ctx.rev())
        except:
            tip = None
        if tip: version2 = version + " HG " + tip
    else: version2 = version
    ievent.reply(version2)


cmnds.add('version', handle_version, ['USER', 'GUEST'])
examples.add('version', 'show version of the bot', 'version')
setalias('v', "version")

## short command


def handle_short(bot, ievent):
    """ arguments: <cmnd> - give short possibilities for a command. """
    try:
        cmnd = ievent.args[0]
    except IndexError:
        ievent.missing('<cmnd>')
        return
    try:
        ievent.reply("short commands for %s" % cmnd, getshorttable()[cmnd])
    except KeyError:
        ievent.reply("no commands found for %s" % cmnd)
Ejemplo n.º 11
0
def init():
    global db
    from jsb.db import getmaindb
    db = getmaindb()
    setalias('aq', 'quote2-add')
    setalias('wq', 'quote2-who')
    setalias('dq', 'quote2-del')
    setalias('lq', 'quote2-last')
    setalias('2q', 'quote2-2')
    setalias('iq', 'quote2-id')
    setalias('q', 'quote2')
    setalias('sq', 'quote2-search')
    setalias('cq', 'quote2-count')
    setalias('q-good', 'quote2-good')
    setalias('q-bad', 'quote2-bad')