# myplugs/lart.py
#
#

from gozerbot.commands import cmnds
from gozerbot.persistconfig import PersistConfig
from gozerbot.aliases import aliasset
import random

cfg = PersistConfig()
cfg.define('lartlist', [])

def handle_lart(bot, ievent):
    try:
        who = ievent.args[0]
    except IndexError:
        ievent.missing('<who>')
        return
    try:
        txt = random.choice(cfg.get('lartlist'))
    except IndexError:
        ievent.reply('lart list is empty .. use lart-add to add entries .. use "<who>" as a nick holder')
        return
    txt = txt.replace('<who>', who)
    ievent.reply(txt)

cmnds.add('lart', handle_lart, 'USER')

aliasset('lart-add', 'lart-cfg lartlist add')
aliasset('lart-del', 'lart-cfg lartlist remove')
