Beispiel #1
0
import threading
import os.path

save_ignores_lock = threading.Lock()


def save_ignores():
    print 'Saving the ignore list...'
    with save_ignores_lock:
        with open('bot_ignore.txt', 'w') as f:
            f.writelines(utils.newlines(bot.config.setdefault('IGNORE', [])))

if os.path.exists('bot_ignore.txt'):
    with open('bot_ignore.txt', 'r') as f:
        bot.config['IGNORE'] = utils.stripnewlines(f.readlines())


@bot.command('help')
@bot.command
def usage(context):
    '''.usage <plugin>'''
    plugin = context.args
    if plugin:
        for p in bot.config['PLUGINS']:
            if plugin == p['hook']:
                bot.reply(p['funcs'][0].__doc__, context=context, recipient=context.line['user'], notice=True)
    else:
        p = [(p['hook'], p['funcs']) for p in bot.config['PLUGINS']]
        p.sort(key=lambda t: t[1])
        result = []
Beispiel #2
0
import threading

badwords = []

save_badwords_lock = threading.Lock()

def save_badwords():
    global badwords
    print 'Saving the badword list...'
    with save_badwords_lock:
        with open('bot_badword.txt', 'w') as f:
            f.writelines(utils.newlines(badwords))

if os.path.exists('bot_badword.txt'):
    with open('bot_badword.txt', 'r') as f:
        badwords = utils.stripnewlines(f.readlines())

def reply_hook(message):
    bad_re = list(imap(lambda x: re.compile(re.escape(x), re.I), badwords))
    for word in bad_re:
        message = word.sub('[BADWORD]', message)
    return message

bot.set_reply_hook(reply_hook)

@bot.command
def addbadword(context):
    '''.addbadword <word>'''
    global badwords
    if not utils.isadmin(context.line['prefix'], bot):
        return
Beispiel #3
0
import threading
import os.path

save_ignores_lock = threading.Lock()


def save_ignores():
    print "Saving the ignore list..."
    with save_ignores_lock:
        with open("bot_ignore.txt", "w") as f:
            f.writelines(utils.newlines(bot.config.setdefault("IGNORE", [])))


if os.path.exists("bot_ignore.txt"):
    with open("bot_ignore.txt", "r") as f:
        bot.config["IGNORE"] = utils.stripnewlines(f.readlines())


@bot.command("help")
@bot.command
def usage(context):
    """.usage <plugin>"""
    plugin = context.args
    if plugin:
        for p in bot.config["PLUGINS"]:
            if plugin == p["hook"]:
                bot.reply(p["funcs"][0].__doc__, context=context, recipient=context.line["user"])
    else:
        p = [(p["hook"], p["funcs"]) for p in bot.config["PLUGINS"]]
        p.sort(key=lambda t: t[1])
        result = []