示例#1
0
def chansettingsStopword(bot, user, command, channel, elements):
    """
    Ban the usage of a certain word in a channel. If Craybot has moderation 
    privilages, he can levy punishments against abusers.
    """
    if bot.isop(user, 1, channel):
        if command.startswith('stopword.add'):
            for element in elements:
                if element.lower() not in data.channelsettings[
                        channel.lower()]['stopword']:
                    data.channelsettings[channel.lower()]['stopword'].append(
                        element.lower())
                    bot.respond(
                        user,
                        "Added %s to my forbidden word list for channel %s." %
                        (element, channel))
                else:
                    bot.respond(
                        user, "%s is already a forbidden word in channel %s!" %
                        (element, channel))
        elif command.startswith('stopword.del'):
            for element in elements:
                if element.lower() in data.channelsettings[
                        channel.lower()]['stopword']:
                    data.channelsettings[channel.lower()]['stopword'].remove(
                        element.lower())
                    bot.respond(
                        user,
                        "Removed %s from my forbidden word list for channel %s."
                        % (element, channel))
                else:
                    bot.respond(
                        user, "%s is not a forbidden word in channel %s!" %
                        (element, channel))
        data.saveFile('channelsettings')
示例#2
0
def karmaAddMinus(bot, user, channel, msg):
    """
    Automatically track karma addition and subtraction. Syntax:
    
    Karma addition:   "Crayboff++"
    Karma subtraction:   "Crayboff--"
    
    User cannot add or deduct karma from himself.
    """
    msg = list(msg.split())
    for part in msg:
        if part[-2:] == '++':
            if user.lower() != part[:-2].lower():
                bot.setusersettings(part[:-2])
                data.usersettings[part[:-2].lower()]['karma'] += 1
            else:
                bot.say(channel, user + ": Don't be greedy!")
        elif part[-2:] == '--':
            if user.lower() != part[:-2].lower():
                bot.setusersettings(part[:-2])
                data.usersettings[part[:-2].lower()]['karma'] -= 1
            else:
                bot.say(
                    channel, user +
                    ": You know, there's medicine for this sort of stuff...")
        data.saveFile('usersettings')
示例#3
0
文件: opcmds.py 项目: mwaboff/Craybot
def opDel(bot, user, command):
    """
    Remove bot operator status for all channels.
    """
    if bot.isop(user, 10, '***'):
        if len(command.split()) == 3:
            tobedel = command.split()[1]
            chanstodel = command.lower().split()[2].split(',')
            if tobedel.lower() in data.authlevels.keys():
                if '*' in chanstodel:
                    del data.authlevels[tobedel.lower()]
                    bot.respond(user, "%s has been stripped of botop status" % (tobedel))
                    bot.respond(tobedel, "%s has removed all of your botop privilages in all channels. If you think this may be a mistake, please talk to %s." % (user, user))
                    bot.printer("!!! OP DEL: %s removed from op status by %s." % (tobedel, user))
                    data.saveFile('authlevels')
                else:
                    for chan in chanstodel:
                        if chan.lower() in data.authlevels[tobedel.lower()]['channels']:
                            del data.authlevels[tobedel.lower()]['channels'][chan.lower()]
                            bot.printer("!!! OP DEL: %s removed from op status in %s by %s." % (tobedel, chan, user))
                        else:
                            bot.respond(user, "%s is not a botop in %s! Passing..." % (tobedel,chan))
                            chanstodel.remove(chan)
                    bot.respond(tobedel, "%s has removed your botop privilages from: %s . If you think this may be a mistake, please talk to %s." % (user, ','.join(chanstodel), user))
                    data.saveFile('authlevels')
            else:
                bot.printer("!!! OP DEL: -FAILED- %s is not a botop" % (tobedel))
                bot.respond(user, "%s is not one of my registered botops!" % (tobedel))
示例#4
0
文件: opcmds.py 项目: mwaboff/Craybot
def specignore(bot, user, command):
    """
    This special ignore will prevent the bot from even registering the 
    user's chat messages when dealing with channel protection (i.e. spam)
    """
    if command.startswith("specignore.add"):
        if bot.isop(user, 10, '***'):
            if len(command.split()) == 2:
                toignore = command.split()[1]
                bot.setusersettings(toignore)
                if not data.usersettings[toignore.lower()]['specignore']:
                    data.usersettings[toignore.lower()]['specignore'] = True
                    bot.respond(user, "%s will now be excluded from my spam checking."%toignore)
                    bot.respond(toignore, "%s has granted you immunity from my spam checker." % (user))
                    bot.printer("!!! SPECIGNORE ADD: No longer checking %s for spam" % toignore)
                else:
                    bot.printer("!!! SPECIGNORE ADD: -FAILED- Already excluding %s from spam checking" % toignore)
                    bot.respond(user, "I was already not checking %s's spam!" % (toignore))
                data.saveFile('usersettings')
    elif command.startswith("specignore.del"):
        if bot.isop(user, 10, '***'):
            if len(command.split()) == 2:
                tounignore = command.split()[1]
                bot.setusersettings(tounignore)
                if data.usersettings[tounignore.lower()]['specignore']:
                    data.usersettings[tounignore.lower()]['specignore'] = False
                    bot.respond(user, "%s will now stop being specially ignored."%tounignore)
                    bot.respond(tounignore, "Your immunity to my spam checking has been removed by %s." % (user))
                    bot.printer("!!! SPECIGNORE DEL: No longer excluding %s from spam checking" % tounignore)
                else:
                    bot.respond(user, "I was never checking %s's spam!" % (tounignore))
                    bot.printer("!!! SPECIGNORE DEL: -FAILED- Was never excluding %s from spam checking" % toignore)
                data.saveFile('usersettings')
示例#5
0
def settingsPassword(bot, user, command):
    """
    Bot operators may change their password.
    """
    if bot.isop(user, 0, '***'):
        data.authlevels[user.lower()]['password'] = hashlib.sha1(command[1]).hexdigest()
        bot.respond(user, "You have changed your password to %s. Please remember this password as I will not be able to tell you what it is later." % (command[1]))
        data.saveFile('authlevels')
示例#6
0
def messageNotify(bot, user):
    """
    Notify a user that he has unread messages.
    """
    if not data.usersettings[user.lower()]['toldofmessages'] and len(data.usersettings[user.lower()]['messages']) > 0:
        bot.respond(user, "You have %d unread messages! Use the message.print function to read them." % (len(data.usersettings[user.lower()]['messages'])))
        data.usersettings[user.lower()]['toldofmessages'] = True
        data.saveFile('usersettings')
示例#7
0
def settingsIgnore(bot, user, command):
    """
    Users may block other users from sending them PMs via Craybot's 
    messaging system.
    """
    data.usersettings[user.lower()]['messageblock'].append(command[1].lower())
    bot.respond(user, "I will not allow for %s to send you any more messages." % (command[1]))
    data.saveFile('usersettings')
示例#8
0
def chansettingsOptoutable(bot, user, command, channel):
    onoff = command.split('.')[1].split()[0].lower()
    if bot.isop(user, 1, channel):
        if onoff == 'on':
            data.channelsettings[channel.lower()]['optoutable'] = True
            data.saveFile('channelsettings')
        elif onoff == 'off':
            data.channelsettings[channel.lower()]['optoutable'] = False
            data.saveFile('channelsettings')
        bot.respond(user, '%s optoutable status: %s' % (channel, data.channelsettings[channel.lower()]['optoutable']))
示例#9
0
def settingsIgnore(bot, user, command):
    """
    Users may block other users from sending them PMs via Craybot's 
    messaging system.
    """
    data.usersettings[user.lower()]['messageblock'].append(command[1].lower())
    bot.respond(
        user, "I will not allow for %s to send you any more messages." %
        (command[1]))
    data.saveFile('usersettings')
示例#10
0
def messagePrinter(bot, user, command):
    """
    Respond to a user any unread messages he may have.
    """
    if len(data.usersettings[user.lower()]['messages']) > 0:
        bot.respond(user, 'You have messages: '+' | '.join(data.usersettings[user.lower()]['messages']))
        data.usersettings[user.lower()]['messages'] = []
        data.saveFile('usersettings')
    else:
        bot.respond(user, "You don't appear to have any messages!")
示例#11
0
文件: opcmds.py 项目: mwaboff/Craybot
def specignore(bot, user, command):
    """
    This special ignore will prevent the bot from even registering the 
    user's chat messages when dealing with channel protection (i.e. spam)
    """
    if command.startswith("specignore.add"):
        if bot.isop(user, 10, '***'):
            if len(command.split()) == 2:
                toignore = command.split()[1]
                bot.setusersettings(toignore)
                if not data.usersettings[toignore.lower()]['specignore']:
                    data.usersettings[toignore.lower()]['specignore'] = True
                    bot.respond(
                        user,
                        "%s will now be excluded from my spam checking." %
                        toignore)
                    bot.respond(
                        toignore,
                        "%s has granted you immunity from my spam checker." %
                        (user))
                    bot.printer(
                        "!!! SPECIGNORE ADD: No longer checking %s for spam" %
                        toignore)
                else:
                    bot.printer(
                        "!!! SPECIGNORE ADD: -FAILED- Already excluding %s from spam checking"
                        % toignore)
                    bot.respond(
                        user,
                        "I was already not checking %s's spam!" % (toignore))
                data.saveFile('usersettings')
    elif command.startswith("specignore.del"):
        if bot.isop(user, 10, '***'):
            if len(command.split()) == 2:
                tounignore = command.split()[1]
                bot.setusersettings(tounignore)
                if data.usersettings[tounignore.lower()]['specignore']:
                    data.usersettings[tounignore.lower()]['specignore'] = False
                    bot.respond(
                        user, "%s will now stop being specially ignored." %
                        tounignore)
                    bot.respond(
                        tounignore,
                        "Your immunity to my spam checking has been removed by %s."
                        % (user))
                    bot.printer(
                        "!!! SPECIGNORE DEL: No longer excluding %s from spam checking"
                        % tounignore)
                else:
                    bot.respond(
                        user, "I was never checking %s's spam!" % (tounignore))
                    bot.printer(
                        "!!! SPECIGNORE DEL: -FAILED- Was never excluding %s from spam checking"
                        % toignore)
                data.saveFile('usersettings')
示例#12
0
def settingsUnignore(bot, user, command):
    """
    Users may use this command to unblock other users from sending them 
    PMs via Craybot's messaging system.
    """
    if command[1].lower() in data.usersettings[user.lower()]['messageblock']:
        data.usersettings[user.lower()]['messageblock'].remove(command[1].lower())
        bot.respond(user, "I will allow for %s to send you messages again." % (command[1]))
        data.saveFile('usersettings')
    else:
        bot.respond(user, "You don't seem to be ignoring %s's messages!" % command[1])
示例#13
0
def settingsPassword(bot, user, command):
    """
    Bot operators may change their password.
    """
    if bot.isop(user, 0, '***'):
        data.authlevels[user.lower()]['password'] = hashlib.sha1(
            command[1]).hexdigest()
        bot.respond(
            user,
            "You have changed your password to %s. Please remember this password as I will not be able to tell you what it is later."
            % (command[1]))
        data.saveFile('authlevels')
示例#14
0
def chansettingsOptoutable(bot, user, command, channel):
    onoff = command.split('.')[1].split()[0].lower()
    if bot.isop(user, 1, channel):
        if onoff == 'on':
            data.channelsettings[channel.lower()]['optoutable'] = True
            data.saveFile('channelsettings')
        elif onoff == 'off':
            data.channelsettings[channel.lower()]['optoutable'] = False
            data.saveFile('channelsettings')
        bot.respond(
            user, '%s optoutable status: %s' %
            (channel, data.channelsettings[channel.lower()]['optoutable']))
示例#15
0
def messagePrinter(bot, user, command):
    """
    Respond to a user any unread messages he may have.
    """
    if len(data.usersettings[user.lower()]['messages']) > 0:
        bot.respond(
            user, 'You have messages: ' +
            ' | '.join(data.usersettings[user.lower()]['messages']))
        data.usersettings[user.lower()]['messages'] = []
        data.saveFile('usersettings')
    else:
        bot.respond(user, "You don't appear to have any messages!")
示例#16
0
def messageNotify(bot, user):
    """
    Notify a user that he has unread messages.
    """
    if not data.usersettings[user.lower()]['toldofmessages'] and len(
            data.usersettings[user.lower()]['messages']) > 0:
        bot.respond(
            user,
            "You have %d unread messages! Use the message.print function to read them."
            % (len(data.usersettings[user.lower()]['messages'])))
        data.usersettings[user.lower()]['toldofmessages'] = True
        data.saveFile('usersettings')
示例#17
0
def chansettingsHilightable(bot, user, command, channel):
    """
    Toggle whether or not a mass highlight can be called in the channel.
    """
    onoff = command.split('.')[1].split()[0].lower()
    if bot.isop(user, 1, channel):
        if onoff == 'on':
            data.channelsettings[channel.lower()]['hilightable'] = True
            data.saveFile('channelsettings')
        elif onoff == 'off':
            data.channelsettings[channel.lower()]['hilightable'] = False
            data.saveFile('channelsettings')
        bot.respond(user, '%s hilightable status: %s' % (channel, data.channelsettings[channel.lower()]['hilightable']))
示例#18
0
def chansettingsShutup(bot, user, command, channel):
    """
    Prevent the bot from speaking at all in a channel.
    """    
    onoff = command.split('.')[1].split()[0].lower()
    if bot.isop(user, 1, channel):
        if onoff == 'on':
            data.channelsettings[channel.lower()]['shutup'] = True
            data.saveFile('channelsettings')
        elif onoff == 'off':
            data.channelsettings[channel.lower()]['shutup'] = False
            data.saveFile('channelsettings')
        bot.respond(user, '%s shutup status: %s' % (channel, data.channelsettings[channel.lower()]['shutup']))
示例#19
0
文件: opcmds.py 项目: mwaboff/Craybot
def ignore(bot, user, command):
    """
    Ignore a user who is trying to spam bot commands.
    """
    if command.startswith("ignore.add"):
        if bot.isop(user, 2, '***'):
            if len(command.split()) == 2:
                toignore = command.split()[1]
                if toignore.lower() == bot.Owner.lower():
                    bot.printer(
                        "!!! IGNORE: -FAILED- %s attempted to put the bot owner on the ignore list"
                        % (user))
                    bot.respond(user, "I will not ignore my Owner!")
                else:
                    bot.setusersettings(toignore)
                    if not data.usersettings[toignore.lower()]['ignore']:
                        data.usersettings[toignore.lower()]['ignore'] = True
                        bot.respond(user, "%s will now be ignored." % toignore)
                        bot.respond(
                            toignore,
                            "You have been placed on my ignore list by %s. If you wish to have this ignore lifted, please talk to one of my botops."
                            % (user))
                        bot.printer("!!! IGNORE: Now ignoring %s" % toignore)
                    else:
                        bot.printer(
                            "!!! IGNORE: -FAILED- Already ignoring %s" %
                            toignore)
                        bot.respond(user,
                                    "I was already ignoring %s!" % (toignore))
                data.saveFile('usersettings')
    elif command.startswith("ignore.del"):
        if bot.isop(user, 2, '***'):
            if len(command.split()) == 2:
                tounignore = command.split()[1]
                bot.setusersettings(tounignore)
                if data.usersettings[tounignore.lower()]['ignore']:
                    data.usersettings[tounignore.lower()]['ignore'] = False
                    bot.respond(user,
                                "%s will no longer be ignored." % tounignore)
                    bot.respond(
                        tounignore,
                        "You have been removed from my ignore list by %s." %
                        (user))
                    bot.printer("!!! UNIGNORE: No longer ignoring %s" %
                                tounignore)
                else:
                    bot.printer("!!! UNIGNORE: -FAILED- Never ignoring %s" %
                                toignore)
                    bot.respond(user,
                                "I was never ignoring %s!" % (tounignore))
                data.saveFile('usersettings')
示例#20
0
def settingsRespond(bot, user, command):
    """
    Sets the preference of how the user would like for Craybot to respond.
    
    Options include via NOTICE (in compliance with RFC 1459) or PRIVMSG 
    (something many users prefer).
    """
    if command[1].lower() in ['notice','notify']:
        data.usersettings[user.lower()]['reply'] = 'NOTICE'
        bot.respond(user, "I will respond to your commands with notices from now on.")
    elif command[1].lower() in ['pm','privmsg','msg']:
        data.usersettings[user.lower()]['reply'] = 'PRIVMSG'
        bot.respond(user, "I will respond to your commands with PMs from now on.")
    data.saveFile('usersettings')
示例#21
0
def settingsUnignore(bot, user, command):
    """
    Users may use this command to unblock other users from sending them 
    PMs via Craybot's messaging system.
    """
    if command[1].lower() in data.usersettings[user.lower()]['messageblock']:
        data.usersettings[user.lower()]['messageblock'].remove(
            command[1].lower())
        bot.respond(
            user,
            "I will allow for %s to send you messages again." % (command[1]))
        data.saveFile('usersettings')
    else:
        bot.respond(
            user, "You don't seem to be ignoring %s's messages!" % command[1])
示例#22
0
def settingsWelcomewagon(bot, user, command):
    """
    Users can define how frequently they would like to be welcomed into 
    a channel containing Craybot.
    """
    try:
        percent = int(command[1])
        if percent < 101 and percent >= 0:
            data.usersettings[user.lower()]['welcomewagonpercentage'] = percent
            bot.respond(user, "You will now be welcomed when you join one of my channels %d%% of the time" % (percent))
            data.saveFile('usersettings')
        else:
            bot.respond(user, "Please only choose an integer between 0 and 100!")
    except:
        pass
示例#23
0
def chansettingsShutup(bot, user, command, channel):
    """
    Prevent the bot from speaking at all in a channel.
    """
    onoff = command.split('.')[1].split()[0].lower()
    if bot.isop(user, 1, channel):
        if onoff == 'on':
            data.channelsettings[channel.lower()]['shutup'] = True
            data.saveFile('channelsettings')
        elif onoff == 'off':
            data.channelsettings[channel.lower()]['shutup'] = False
            data.saveFile('channelsettings')
        bot.respond(
            user, '%s shutup status: %s' %
            (channel, data.channelsettings[channel.lower()]['shutup']))
示例#24
0
def chansettingsGuard(bot, user, command, channel):
    """
    Toggle whether or not Craybot shall attempt to protect the channel 
    from spammers/other threats. Only useful if Craybot has moderation 
    privilages.
    """
    onoff = command.split('.')[1].split()[0].lower()
    if bot.isop(user, 1, channel):
        if onoff == 'on':
            data.channelsettings[channel.lower()]['guard'] = True
            data.saveFile('channelsettings')
        elif onoff == 'off':
            data.channelsettings[channel.lower()]['guard'] = False
            data.saveFile('channelsettings')
        bot.respond(user, '%s guard status: %s' % (channel, data.channelsettings[channel.lower()]['guard']))
示例#25
0
def chansettingsHilightable(bot, user, command, channel):
    """
    Toggle whether or not a mass highlight can be called in the channel.
    """
    onoff = command.split('.')[1].split()[0].lower()
    if bot.isop(user, 1, channel):
        if onoff == 'on':
            data.channelsettings[channel.lower()]['hilightable'] = True
            data.saveFile('channelsettings')
        elif onoff == 'off':
            data.channelsettings[channel.lower()]['hilightable'] = False
            data.saveFile('channelsettings')
        bot.respond(
            user, '%s hilightable status: %s' %
            (channel, data.channelsettings[channel.lower()]['hilightable']))
示例#26
0
def chansettingsWelcomewagon(bot, user, command, channel):
    """
    Toggle whether or not Craybot will randomly welcome users to the channel.
    
    This overrides a user's personal settings.
    """
    onoff = command.split('.')[1].split()[0].lower()
    if bot.isop(user, 1, channel):
        if onoff == 'on':
            data.channelsettings[channel.lower()]['welcomewagon'] = True
            data.saveFile('channelsettings')
        elif onoff == 'off':
            data.channelsettings[channel.lower()]['welcomewagon'] = False
            data.saveFile('channelsettings')
        bot.respond(user, '%s welcomewagon status: %s' % (channel, data.channelsettings[channel.lower()]['welcomewagon']))
示例#27
0
def settingsRespond(bot, user, command):
    """
    Sets the preference of how the user would like for Craybot to respond.
    
    Options include via NOTICE (in compliance with RFC 1459) or PRIVMSG 
    (something many users prefer).
    """
    if command[1].lower() in ['notice', 'notify']:
        data.usersettings[user.lower()]['reply'] = 'NOTICE'
        bot.respond(
            user, "I will respond to your commands with notices from now on.")
    elif command[1].lower() in ['pm', 'privmsg', 'msg']:
        data.usersettings[user.lower()]['reply'] = 'PRIVMSG'
        bot.respond(user,
                    "I will respond to your commands with PMs from now on.")
    data.saveFile('usersettings')
示例#28
0
def settingsGender(bot, user, command):
    """
    Users may set their own gender record. Other users may ask Craybot 
    what gender the original user is, and if it is defined, Craybot will 
    respond.
    """
    if data.usersettings[user.lower()]['gender'] == '':
        if command[1].lower() in ['male','boy','guy','man','masc','masculine']:
            data.usersettings[user.lower()]['gender'] = 'male'
            bot.respond(user, "I will now know you as a male")
        elif command[1].lower() in ['female','girl','gal','woman','fem','feminine']:
            data.usersettings[user.lower()]['gender'] = 'female'
            bot.respond(user, "I will now know you as a female")
        data.saveFile('usersettings')
    else:
        bot.respond(user, "Your gender is already set! If you must change this, please contact one of my botops.")
示例#29
0
def chansettingsWelcomewagon(bot, user, command, channel):
    """
    Toggle whether or not Craybot will randomly welcome users to the channel.
    
    This overrides a user's personal settings.
    """
    onoff = command.split('.')[1].split()[0].lower()
    if bot.isop(user, 1, channel):
        if onoff == 'on':
            data.channelsettings[channel.lower()]['welcomewagon'] = True
            data.saveFile('channelsettings')
        elif onoff == 'off':
            data.channelsettings[channel.lower()]['welcomewagon'] = False
            data.saveFile('channelsettings')
        bot.respond(
            user, '%s welcomewagon status: %s' %
            (channel, data.channelsettings[channel.lower()]['welcomewagon']))
示例#30
0
def chansettingsGuard(bot, user, command, channel):
    """
    Toggle whether or not Craybot shall attempt to protect the channel 
    from spammers/other threats. Only useful if Craybot has moderation 
    privilages.
    """
    onoff = command.split('.')[1].split()[0].lower()
    if bot.isop(user, 1, channel):
        if onoff == 'on':
            data.channelsettings[channel.lower()]['guard'] = True
            data.saveFile('channelsettings')
        elif onoff == 'off':
            data.channelsettings[channel.lower()]['guard'] = False
            data.saveFile('channelsettings')
        bot.respond(
            user, '%s guard status: %s' %
            (channel, data.channelsettings[channel.lower()]['guard']))
示例#31
0
文件: opcmds.py 项目: mwaboff/Craybot
def opDel(bot, user, command):
    """
    Remove bot operator status for all channels.
    """
    if bot.isop(user, 10, '***'):
        if len(command.split()) == 3:
            tobedel = command.split()[1]
            chanstodel = command.lower().split()[2].split(',')
            if tobedel.lower() in data.authlevels.keys():
                if '*' in chanstodel:
                    del data.authlevels[tobedel.lower()]
                    bot.respond(
                        user,
                        "%s has been stripped of botop status" % (tobedel))
                    bot.respond(
                        tobedel,
                        "%s has removed all of your botop privilages in all channels. If you think this may be a mistake, please talk to %s."
                        % (user, user))
                    bot.printer(
                        "!!! OP DEL: %s removed from op status by %s." %
                        (tobedel, user))
                    data.saveFile('authlevels')
                else:
                    for chan in chanstodel:
                        if chan.lower() in data.authlevels[
                                tobedel.lower()]['channels']:
                            del data.authlevels[tobedel.lower()]['channels'][
                                chan.lower()]
                            bot.printer(
                                "!!! OP DEL: %s removed from op status in %s by %s."
                                % (tobedel, chan, user))
                        else:
                            bot.respond(
                                user, "%s is not a botop in %s! Passing..." %
                                (tobedel, chan))
                            chanstodel.remove(chan)
                    bot.respond(
                        tobedel,
                        "%s has removed your botop privilages from: %s . If you think this may be a mistake, please talk to %s."
                        % (user, ','.join(chanstodel), user))
                    data.saveFile('authlevels')
            else:
                bot.printer("!!! OP DEL: -FAILED- %s is not a botop" %
                            (tobedel))
                bot.respond(
                    user, "%s is not one of my registered botops!" % (tobedel))
示例#32
0
def messageSender(bot, user, command):
    """
    Send another user a PM (just storing it until the other user gets it 
    with timestamp data).
    """
    to = command[1]
    bot.setusersettings(to)
    if user.lower() not in data.usersettings[to.lower()]['messageblock']:
        message = command[2]
        newmessagetime = datetime.utcnow().timetuple()
        newmonth = str(newmessagetime[1])
        monthabbrev = {
            '1': 'JAN',
            '2': 'FEB',
            '3': 'MAR',
            '4': 'APR',
            '5': 'MAY',
            '6': 'JUN',
            '7': 'JUL',
            '8': 'AUG',
            '9': 'SEP',
            '10': 'OCT',
            '11': 'NOV',
            '12': 'DEC'
        }
        newday = str(newmessagetime[2])
        newhour = str(newmessagetime[3])
        newminute = str(newmessagetime[4])
        newyear = str(newmessagetime[0])
        msgtime = '[%s %s %s  %s:%s] ' % (monthabbrev[newmonth], newday,
                                          newyear, newhour, newminute)
        newmessage = '<%s> %s' % (user, message)
        data.usersettings[to.lower()]['messages'].append('%s%s' %
                                                         (msgtime, newmessage))
        data.usersettings[to.lower()]['toldofmessages'] = False
        data.saveFile('usersettings')
        bot.respond(
            user, "Message sent. [To: %s  Time Sent: %s %s %s  %s:%s]" %
            (to, monthabbrev[newmonth], newday, newyear, newhour, newminute))
    else:
        bot.respond(
            user,
            "I'm sorry, but you have been blacklisted from sending messages to %s"
            % (to))
示例#33
0
def settingsWelcomewagon(bot, user, command):
    """
    Users can define how frequently they would like to be welcomed into 
    a channel containing Craybot.
    """
    try:
        percent = int(command[1])
        if percent < 101 and percent >= 0:
            data.usersettings[user.lower()]['welcomewagonpercentage'] = percent
            bot.respond(
                user,
                "You will now be welcomed when you join one of my channels %d%% of the time"
                % (percent))
            data.saveFile('usersettings')
        else:
            bot.respond(user,
                        "Please only choose an integer between 0 and 100!")
    except:
        pass
示例#34
0
文件: opcmds.py 项目: mwaboff/Craybot
def opAdd(bot, user, command):
    """
    Grant bot operator status to a user for a specified channel.
    """
    if bot.isop(user, 10, '***'):
        elements = command.split()
        if len(elements) >= 3:
            authlevel = int(elements[2])
            if 0 < authlevel <= 3:
                chanstobe = elements[3].lower().split(',')
                if elements[1].lower() not in data.authlevels:
                    data.authlevels[elements[1].lower()] = {
                        'password': bot.defaultpass,
                        'logged in': False,
                        'channels': {}
                    }
                    bot.respond(
                        elements[1],
                        "Congratulations, you have been granted botop status by %s. You may check your authorization levels with  settings.print  command. The default password is 'pass', however you must change it as soon as possible. To change your password use the 'settings.password' function. Thanks and good luck!"
                        % (user))
                for chan in chanstobe:
                    data.authlevels[elements[1].lower()]['channels'][
                        chan.lower()] = authlevel
                bot.respond(
                    elements[1],
                    "You have just been made a botop of authlevel %d in the following channels: %s"
                    % (authlevel, ','.join(chanstobe)))
                bot.respond(
                    user,
                    "You have successfully given %s bot op status in %s! %s's authorization level is %d."
                    %
                    (elements[1], ','.join(chanstobe), elements[1], authlevel))
                bot.printer(
                    "!!! OP ADD: %s granted op status (%d in %s) by %s." %
                    (elements[1], authlevel, ','.join(chanstobe), user))
                data.saveFile('authlevels')
            else:
                bot.respond(
                    user,
                    "You may only add botops with an authlevel of either 1, 2, or 3!"
                )
                return False
示例#35
0
def settingsHilightOpt(bot, user, command):
    """
    Users may opt-in or opt-out of mass hilighting on a channel-to-channel 
    basis.
    """
    if len(command) == 2:
        channel = command[1]
        bot.setchansettings(channel)
        if command[0] == 'hilight.optout':
            if user.lower() not in data.channelsettings[channel.lower()]['hilightoptout']:
                data.channelsettings[channel.lower()]['hilightoptout'].append(user.lower())
                bot.respond(user, "You will not be hilighted in my mass hilighting for %s" % channel)
            else:
                bot.respond(user, "You are already opted out of %s channel hilights!" % channel)
        elif command[0] == 'hilight.optin':
            if user.lower() in data.channelsettings[channel.lower()]['hilightoptout']:
                data.channelsettings[channel.lower()]['hilightoptout'].remove(user.lower())
                bot.respond(user, "You will now be included in my mass hilighting for %s." % channel)
            else:
                bot.respond(user, "You do not seem to be opted out of %s channel hilights!" % channel)
        data.saveFile('channelsettings')
示例#36
0
def chansettingsStopword(bot, user, command, channel, elements):
    """
    Ban the usage of a certain word in a channel. If Craybot has moderation 
    privilages, he can levy punishments against abusers.
    """
    if bot.isop(user, 1, channel):
        if command.startswith('stopword.add'):
            for element in elements:
                if element.lower() not in data.channelsettings[channel.lower()]['stopword']:
                    data.channelsettings[channel.lower()]['stopword'].append(element.lower())
                    bot.respond(user, "Added %s to my forbidden word list for channel %s." % (element, channel))
                else:
                    bot.respond(user, "%s is already a forbidden word in channel %s!" % (element, channel))
        elif command.startswith('stopword.del'):
            for element in elements:
                if element.lower() in data.channelsettings[channel.lower()]['stopword']:
                    data.channelsettings[channel.lower()]['stopword'].remove(element.lower())
                    bot.respond(user, "Removed %s from my forbidden word list for channel %s." % (element, channel))
                else:
                    bot.respond(user, "%s is not a forbidden word in channel %s!" % (element, channel))
        data.saveFile('channelsettings')
示例#37
0
文件: opcmds.py 项目: mwaboff/Craybot
def opAdd(bot, user, command):
    """
    Grant bot operator status to a user for a specified channel.
    """
    if bot.isop(user, 10, '***'):
        elements = command.split()
        if len(elements) >= 3:
            authlevel = int(elements[2])
            if 0 < authlevel <= 3:
                chanstobe = elements[3].lower().split(',')
                if elements[1].lower() not in data.authlevels:
                    data.authlevels[elements[1].lower()] = {'password':bot.defaultpass,'logged in':False,'channels':{}}
                    bot.respond(elements[1], "Congratulations, you have been granted botop status by %s. You may check your authorization levels with  settings.print  command. The default password is 'pass', however you must change it as soon as possible. To change your password use the 'settings.password' function. Thanks and good luck!" % (user))
                for chan in chanstobe:
                    data.authlevels[elements[1].lower()]['channels'][chan.lower()] = authlevel
                bot.respond(elements[1], "You have just been made a botop of authlevel %d in the following channels: %s" % (authlevel, ','.join(chanstobe)))
                bot.respond(user, "You have successfully given %s bot op status in %s! %s's authorization level is %d." % (elements[1], ','.join(chanstobe), elements[1], authlevel))
                bot.printer("!!! OP ADD: %s granted op status (%d in %s) by %s." % (elements[1],authlevel,','.join(chanstobe),user))
                data.saveFile('authlevels')
            else:
                bot.respond(user, "You may only add botops with an authlevel of either 1, 2, or 3!")
                return False
示例#38
0
def settingsGender(bot, user, command):
    """
    Users may set their own gender record. Other users may ask Craybot 
    what gender the original user is, and if it is defined, Craybot will 
    respond.
    """
    if data.usersettings[user.lower()]['gender'] == '':
        if command[1].lower() in [
                'male', 'boy', 'guy', 'man', 'masc', 'masculine'
        ]:
            data.usersettings[user.lower()]['gender'] = 'male'
            bot.respond(user, "I will now know you as a male")
        elif command[1].lower() in [
                'female', 'girl', 'gal', 'woman', 'fem', 'feminine'
        ]:
            data.usersettings[user.lower()]['gender'] = 'female'
            bot.respond(user, "I will now know you as a female")
        data.saveFile('usersettings')
    else:
        bot.respond(
            user,
            "Your gender is already set! If you must change this, please contact one of my botops."
        )
示例#39
0
def messageSender(bot, user, command):
    """
    Send another user a PM (just storing it until the other user gets it 
    with timestamp data).
    """
    to = command[1]
    bot.setusersettings(to)
    if user.lower() not in data.usersettings[to.lower()]['messageblock']:
        message = command[2]
        newmessagetime = datetime.utcnow().timetuple()
        newmonth = str(newmessagetime[1])
        monthabbrev = {'1':'JAN', '2':'FEB', '3':'MAR', '4':'APR', '5':'MAY', '6':'JUN', '7':'JUL', '8':'AUG', '9':'SEP', '10':'OCT', '11':'NOV', '12':'DEC'}
        newday = str(newmessagetime[2])
        newhour = str(newmessagetime[3])
        newminute = str(newmessagetime[4])
        newyear = str(newmessagetime[0])
        msgtime = '[%s %s %s  %s:%s] ' % (monthabbrev[newmonth], newday, newyear, newhour, newminute)
        newmessage = '<%s> %s' % (user, message)
        data.usersettings[to.lower()]['messages'].append('%s%s' % (msgtime,newmessage))
        data.usersettings[to.lower()]['toldofmessages'] = False
        data.saveFile('usersettings')
        bot.respond(user, "Message sent. [To: %s  Time Sent: %s %s %s  %s:%s]" % (to, monthabbrev[newmonth], newday, newyear, newhour, newminute))
    else:
        bot.respond(user, "I'm sorry, but you have been blacklisted from sending messages to %s" % (to))
示例#40
0
def karmaAddMinus(bot, user, channel, msg):
    """
    Automatically track karma addition and subtraction. Syntax:
    
    Karma addition:   "Crayboff++"
    Karma subtraction:   "Crayboff--"
    
    User cannot add or deduct karma from himself.
    """
    msg = list(msg.split())
    for part in msg:
        if part[-2:] == '++':
            if user.lower() != part[:-2].lower():
                bot.setusersettings(part[:-2])
                data.usersettings[part[:-2].lower()]['karma'] += 1
            else:
                bot.say(channel, user+": Don't be greedy!")
        elif part[-2:] == '--':
            if user.lower() != part[:-2].lower():
                bot.setusersettings(part[:-2])
                data.usersettings[part[:-2].lower()]['karma'] -= 1
            else:
                bot.say(channel, user+": You know, there's medicine for this sort of stuff...")
        data.saveFile('usersettings')
示例#41
0
文件: opcmds.py 项目: mwaboff/Craybot
def ignore(bot, user, command):
    """
    Ignore a user who is trying to spam bot commands.
    """
    if command.startswith("ignore.add"):
        if bot.isop(user, 2, '***'):
            if len(command.split()) == 2:
                toignore = command.split()[1]
                if toignore.lower() == bot.Owner.lower():
                    bot.printer("!!! IGNORE: -FAILED- %s attempted to put the bot owner on the ignore list" % (user))
                    bot.respond(user, "I will not ignore my Owner!")
                else:
                    bot.setusersettings(toignore)
                    if not data.usersettings[toignore.lower()]['ignore']:
                        data.usersettings[toignore.lower()]['ignore'] = True
                        bot.respond(user, "%s will now be ignored."%toignore)
                        bot.respond(toignore, "You have been placed on my ignore list by %s. If you wish to have this ignore lifted, please talk to one of my botops." % (user))
                        bot.printer("!!! IGNORE: Now ignoring %s" % toignore)
                    else:
                        bot.printer("!!! IGNORE: -FAILED- Already ignoring %s" % toignore)
                        bot.respond(user, "I was already ignoring %s!" % (toignore))
                data.saveFile('usersettings')
    elif command.startswith("ignore.del"):
        if bot.isop(user, 2, '***'):
            if len(command.split()) == 2:
                tounignore = command.split()[1]
                bot.setusersettings(tounignore)
                if data.usersettings[tounignore.lower()]['ignore']:
                    data.usersettings[tounignore.lower()]['ignore'] = False
                    bot.respond(user, "%s will no longer be ignored."%tounignore)
                    bot.respond(tounignore, "You have been removed from my ignore list by %s." % (user))
                    bot.printer("!!! UNIGNORE: No longer ignoring %s" % tounignore)
                else:
                    bot.printer("!!! UNIGNORE: -FAILED- Never ignoring %s" % toignore)
                    bot.respond(user, "I was never ignoring %s!" % (tounignore))
                data.saveFile('usersettings')
示例#42
0
def settingsHilightOpt(bot, user, command):
    """
    Users may opt-in or opt-out of mass hilighting on a channel-to-channel 
    basis.
    """
    if len(command) == 2:
        channel = command[1]
        bot.setchansettings(channel)
        if command[0] == 'hilight.optout':
            if user.lower() not in data.channelsettings[
                    channel.lower()]['hilightoptout']:
                data.channelsettings[channel.lower()]['hilightoptout'].append(
                    user.lower())
                bot.respond(
                    user,
                    "You will not be hilighted in my mass hilighting for %s" %
                    channel)
            else:
                bot.respond(
                    user, "You are already opted out of %s channel hilights!" %
                    channel)
        elif command[0] == 'hilight.optin':
            if user.lower() in data.channelsettings[
                    channel.lower()]['hilightoptout']:
                data.channelsettings[channel.lower()]['hilightoptout'].remove(
                    user.lower())
                bot.respond(
                    user,
                    "You will now be included in my mass hilighting for %s." %
                    channel)
            else:
                bot.respond(
                    user,
                    "You do not seem to be opted out of %s channel hilights!" %
                    channel)
        data.saveFile('channelsettings')
示例#43
0
 def setchansettings(self, channel):
     if channel.lower() not in data.channelsettings:
         data.channelsettings[channel.lower()] = {'welcomewagon':True, 'guard':False, 'shutup':False, 'listen':True, 'hilightoptout':[], 'optoutable':True, 'userlist':[], 'hilightable':False, 'hilighted':False, 'floodwatcher':{}, 'stopword':[],'chanops':[],'strikes':{},'chanops':{}}
         data.saveFile('channelsettings')
         self.printer("!!! CREATE: channel settings for %s" % (channel))
示例#44
0
 def setusersettings(self, user):
     if user.lower() not in data.usersettings:
         data.usersettings[user.lower()] = {'reply':'PRIVMSG', 'welcomewagonpercentage': 50, 'messageblock':[], 'ignore':False, 'specignore':False, 'bot':False, 'messages':[], 'toldofmessages':True, 'karma':0, 'gender':''}
         data.saveFile('usersettings')
         self.printer("!!! CREATE: user settings for %s" % (user))
示例#45
0
def assignStrikes(user, channel, punishment):
    data.channelsettings[channel.lower()]['strikes'][user.lower()] += punishment
    reactor.callLater(604800, deductStrikes, user)
    #reactor.callLater(120, deductStrikes, user, channel)
    data.saveFile('channelsettings')
示例#46
0
def assignStrikes(user, channel, punishment):
    data.channelsettings[channel.lower()]['strikes'][
        user.lower()] += punishment
    reactor.callLater(604800, deductStrikes, user)
    #reactor.callLater(120, deductStrikes, user, channel)
    data.saveFile('channelsettings')