예제 #1
0
    global aliases
    log.debug("Loading aliases.")
    try:
        aliases = pickle.load(file(storeFile))
        print "Aliases 1:",aliases
        return True
    except:
        log.exception("Failed to load aliases.")
        return False

if not loadAliases():
    saveAliases()
    if not loadAliases():
        log.error("Couldn't load aliases.")

log.dict(aliases,"Loaded Aliases")
print "Aliases 2:",aliases

@requires("IRCArgs")
class Alias:
    @bindFunction(message="^!alias (?P<shorthand>[^ ]+) (?P<expanded>.*)")
    def bindAlias(self, nick, response, shorthand, expanded, target):
        log.debug("Bind",nick, response, shorthand, expanded, target)
        if nick not in aliases:
            aliases[nick]={}
        aliases[nick][shorthand]=expanded
        saveAliases()
   
    @bindFunction(message="^!alias --help")
    def iHelp(self, nick, response, shorthand, target):
        return response.msg(target, "!alias to list your current aliases\n!alias <foo> <bar> to set bar to foo\n!alias -remove <foo> to remove foo\n@foo to use the foo alias")
예제 #2
0
        else:
            return 0
        if len(gifts[owner]) == 0:
            del gifts[owner]
        save(gifts, gifts_file)
        return amount
    return 0


def owner_items(owner):
    if owner in gifts:
        for item in gifts[owner]:
            yield pluralize(item, gifts[owner][item]), gifts[owner][item]


log.dict(gifts, "Loaded Gifts")


@requires("IRCArgs")
class Gifts:
    @bindFunction(
        message=r"^!items? give (?P<to>[^ ]*) (?P<amount>\d+) (?P<item>.*)")
    def giveGift(self, nick, response, target, to, amount, item):
        log.debug("Giving", to, amount, item)
        if give(to, amount, item):
            return response.say(target, "giving %s %s %s" % (to, amount, item))
        return response.say(target,
                            "error giving %s %s to %s" % (amount, item, to))

    @bindFunction(message=r"^!items? list (?P<owner>[^ ]*)")
    def showGifts(self, nick, response, target, owner):
예제 #3
0
            if gifts[owner][item] <= 0:
                del gifts[owner][item]
        else:
            return 0
        if len(gifts[owner]) == 0:
            del gifts[owner]
        save(gifts, gifts_file)
        return amount
    return 0

def owner_items(owner):
    if owner in gifts:
        for item in gifts[owner]:
            yield pluralize(item, gifts[owner][item]), gifts[owner][item]

log.dict(gifts,"Loaded Gifts")

@requires("IRCArgs")
class Gifts:
    @bindFunction(message=r"^!items? give (?P<to>[^ ]*) (?P<amount>\d+) (?P<item>.*)")
    def giveGift(self, nick, response, target, to, amount, item):
        log.debug("Giving", to, amount, item)
        if give(to, amount, item):
            return response.say(target, "giving %s %s %s" % (to, amount, item))
        return response.say(target, "error giving %s %s to %s" % (amount, item, to))

    @bindFunction(message=r"^!items? list (?P<owner>[^ ]*)")
    def showGifts(self, nick, response, target, owner):
        log.debug("Showing items belonging to", owner)
        items = ", ".join("%s %s" % (n, g) for g, n in owner_items(owner))
        if items: