(bot, user, args)
return True
Ignores a specific alert for a user for some period of time.
Ignores a specific alert for a user for some period of time.
Ignores a specific alert for a user for some period of time .
def ignore(bot, user, args):
    '''Ignores a specific alert for a user for some period of time.'''
    if len(args) != 2:
        return False

    which, time = args

    # Find correct task in user object
    task = None
    if which == 'last' and user.tasks:
        task = user.tasks[-1]
    elif which == 'current' and user.pending_task:
        task = user.pending_task
    if task is None:
        return False

    # Parse given time using above regex
    match = TIME_REGEX.match(time)
    if not (match or match.group(0)):
        return False
    # Parse time returned by regex, snipping off the trailing letter
    hours = int(match.group(1)[:-1]) if match.group(1) else 0
    minutes = int(match.group(2)[:-1]) if match.group(2) else 0
    # Build and cap time if needed
    ignoretime = timedelta(hours=hours, minutes=minutes)
    if ignoretime > TIME_LIMIT:
        bot.chat.message_user(user, bot.messages['ignore_time'])
        ignoretime = TIME_LIMIT
    elif ignoretime <= OUTATIME:
        bot.chat.message_user(user, bot.messages['ignore_no_time'])
        return False

    ignored_alerts.ignore_task(user['name'], task.title, 'ignored', ignoretime)
    return True
def ignore ( bot , user , args ) : if len ( args ) != 2 : return False which , time = args # Find correct task in user object task = None if which == 'last' and user . tasks : task = user . tasks [ - 1 ] elif which == 'current' and user . pending_task : task = user . pending_task if task is None : return False # Parse given time using above regex match = TIME_REGEX . match ( time ) if not ( match or match . group ( 0 ) ) : return False # Parse time returned by regex, snipping off the trailing letter hours = int ( match . group ( 1 ) [ : - 1 ] ) if match . group ( 1 ) else 0 minutes = int ( match . group ( 2 ) [ : - 1 ] ) if match . group ( 2 ) else 0 # Build and cap time if needed ignoretime = timedelta ( hours = hours , minutes = minutes ) if ignoretime > TIME_LIMIT : bot . chat . message_user ( user , bot . messages [ 'ignore_time' ] ) ignoretime = TIME_LIMIT elif ignoretime <= OUTATIME : bot . chat . message_user ( user , bot . messages [ 'ignore_no_time' ] ) return False ignored_alerts . ignore_task ( user [ 'name' ] , task . title , 'ignored' , ignoretime ) return True