예제 #1
0
파일: convert.py 프로젝트: camconn/probot
def whatis_command(arg: tuple, packet: ircp.Packet, shared: dict):
    if len(arg) < 2:
        return ircp.make_notice('You must specify a type of currency!', packet.sender)

    orig_currency = (' '.join(arg[1:]))
    currency = str(orig_currency).upper()

    if currency in ALIASES:
        currency = ALIASES[currency]

    if currency not in CURRENCIES:
        return ircp.make_notice('I don\'t know what "{}" is!'.format(currency), packet.sender)
    else:
        return packet.reply('{} is {}'.format(orig_currency, CURRENCIES[currency]))
예제 #2
0
파일: rekt.py 프로젝트: camconn/probot
def rekt_command(arg, packet, shared, is_rekt=True):
    """
    Tells a user that they got rekt

    is_rekt - if True: user is rekt, else: user is not rekt
    """
    person = ''
    if len(arg) < 2:
        return ircp.make_notice('You need to specify who got rekt', packet.sender)
    else:
        person = ' '.join(arg[1:])

    logging.info('reking %s', person)

    rekt_tuple = shared['rekt.tuple']

    checked = '[X] '
    unchecked = '[ ] '

    random_rekt = sorted(sample(rekt_tuple[2:], 3), key=len)

    if is_rekt:  # Use appropriate checkboxes if using `rekt` or `notrekt`
        rekts = [unchecked + rekt_tuple[0], checked + rekt_tuple[1],
                 checked + random_rekt[0], checked + random_rekt[1], checked + random_rekt[2]]
    else:
        rekts = [checked + rekt_tuple[0], unchecked + rekt_tuple[1],
                 unchecked + random_rekt[0], unchecked + random_rekt[1], unchecked + random_rekt[2]]
    rekts = [phrase for phrase in rekts]

    # throttler.add_message()

    return ircp.make_message(('{0}{1}{2} just got: {3[0]} {3[1]} {3[2]} '
                              '{3[3]} {3[4]}').format(CLR_NICK, person, CLR_RESET, rekts), packet.target)
예제 #3
0
파일: wikipedia.py 프로젝트: camconn/probot
def wiki_command(arg, packet, shared):
    '''
    The wiki command

    Usage
    :w George Washington
    :wiki Monty Python
    '''
    if len(arg) < 2:
        return ircp.make_notice('You need to list something to search', packet.sender)

    query = ' '.join(arg[1:])
    print('search query: "{}"'.format(query))

    summary = get_summary(query)

    if summary == '...' or summary is None:
        return None
    elif isinstance(summary, tuple) or isinstance(summary, list):
        output = []
        for line in summary:
            output.append(ircp.make_message(line.strip(), packet.target))
        return output
    else:
        print('summary: ')
        print(summary)
        print('that was the last time!')
        return ircp.make_message(summary, packet.target)
예제 #4
0
def told_command(arg, packet, shared, is_told=True):
    """
    Tells a user that they got told

    is_told - if True: user is told, else: user is not told
    """
    person = ''
    if len(arg) < 2:
        return ircp.make_notice('You need to specify who got told', packet.sender)
    else:
        person = ' '.join(arg[1:])

    logging.info('telling %s', person)

    told_tuple = shared['told.tuple']

    checked = '[X] '
    unchecked = '[ ] '

    random_told = sorted(sample(told_tuple[2:], 3), key=len)

    if is_told:  # Use appropriate checkboxes if using `told` or `nottold`
        tolds = [unchecked + told_tuple[0], checked + told_tuple[1],
                 checked + random_told[0], checked + random_told[1], checked + random_told[2]]
    else:
        tolds = [checked + told_tuple[0], unchecked + told_tuple[1],
                 unchecked + random_told[0], unchecked + random_told[1], unchecked + random_told[2]]
    tolds = [phrase for phrase in tolds]

    # throttler.add_message()

    return ircp.make_message(('{0}{1}{2} just got: {3[0]} {3[1]} {3[2]} '
                              '{3[3]} {3[4]}').format(CLR_NICK, person, CLR_RESET, tolds), packet.target)
예제 #5
0
def rekt_command(arg, packet, shared, is_rekt=True):
    """
    Tells a user that they got rekt

    is_rekt - if True: user is rekt, else: user is not rekt
    """
    person = ''
    if len(arg) < 2:
        return ircp.make_notice('You need to specify who got rekt',
                                packet.sender)
    else:
        person = ' '.join(arg[1:])

    logging.info('reking %s', person)

    rekt_tuple = shared['rekt.tuple']

    checked = '[X] '
    unchecked = '[ ] '

    random_rekt = sorted(sample(rekt_tuple[2:], 3), key=len)

    if is_rekt:  # Use appropriate checkboxes if using `rekt` or `notrekt`
        rekts = [
            unchecked + rekt_tuple[0], checked + rekt_tuple[1],
            checked + random_rekt[0], checked + random_rekt[1],
            checked + random_rekt[2]
        ]
    else:
        rekts = [
            checked + rekt_tuple[0], unchecked + rekt_tuple[1],
            unchecked + random_rekt[0], unchecked + random_rekt[1],
            unchecked + random_rekt[2]
        ]
    rekts = [phrase for phrase in rekts]

    # throttler.add_message()

    return ircp.make_message(('{0}{1}{2} just got: {3[0]} {3[1]} {3[2]} '
                              '{3[3]} {3[4]}').format(CLR_NICK, person,
                                                      CLR_RESET, rekts),
                             packet.target)
예제 #6
0
파일: responses.py 프로젝트: camconn/probot
def respond_help(matched, packet: ircp.Packet, shared: dict) -> str:
    ''' Respond to general help regex '''
    return (ircp.make_notice('For a list of my commands, type {0}:commands{1}'.format(CLR_HGLT,
                                                                        CLR_RESET), packet.sender),
            ircp.make_notice('For help with a particular command, '  \
                         'type {0}:help commandname{1}'.format(CLR_HGLT, CLR_RESET), packet.sender))
예제 #7
0
파일: responses.py 프로젝트: camconn/probot
def respond_help(matched, packet: ircp.Packet, shared: dict) -> str:
    ''' Respond to general help regex '''
    return (ircp.make_notice('For a list of my commands, type {0}:commands{1}'.format(CLR_HGLT,
                                                                        CLR_RESET), packet.sender),
            ircp.make_notice('For help with a particular command, '  \
                         'type {0}:help commandname{1}'.format(CLR_HGLT, CLR_RESET), packet.sender))