NAME

Bot::Backbone::Service::OFun::CodeName - Assign code names to words and phrases for fun and profit

VERSION

version 0.142230

SYNOPSIS

    # in your bot config
    service code_name => (
        service         => 'OFun::CodeName',
        nouns_file      => 'nouns.txt',
        adjectives_file => adjectives.txt',
        db_dsn          => 'dbi:SQLite:codename.db',
    );

    dispatcher chatroom => as {
        redispatch_to 'code_name';
    };

    # in chat
    alice> !codename bob
    bot> exploding chariot
    alice> !codename exploding chariot
    bot> bob

DESCRIPTION

Have you ever wanted to assign really horrible code names to your projects? Your clients? Your coworkers? Well, now is your chance. Just put this little baby into your bot config and let it assign code names to your heart's content.

To work, you must supply it with your own list of nouns and adjectives (not included) and a database, which is used to store the code names that have been assigned. The code names are assigned in a standard-ish way so they will be reassigned the same way every time, so long as you continue using the same noun and adjective list. The database is used to remember the code name's reversal and also to keep the code names the same if you do choose to modify your word lists for some reason (say to remove some NSFW word or to add an NSFW word you forgot to add in the first place).

DISPATCHER

!codename

    !codename phrase
    !codename code name

This command is used to generate a new codename or to tell you what a code name refers to. You don't need to quote your words or anything, just give it as short or as long a phrase as you want named and it will respond.

ATTRIBUTES

adjectives_file

nouns_file

These are files that provide adjectives and nouns to the service. The words should be listed one-per-line in the file with no blanks. Extra whitespace on either side of each word will be trimmed.

adjectives

nouns

These are arrays of the loaded word lists.

METHODS

load_schema

Creates the codenames file. It uses DDL SQL that should be compatible with SQLite and MySQL databases.

assign_codename

This implements the !codename command.

generate_code_name

  my $codename = $self->generate_code_name($phrase);

Given a string, it returns a new code name for that string.

find_key

  my $alias = $self->find_key($key);

Given a code name or a phrase that has been assigned a code name, it returns the alias (i.e., the original phrase for code names and the code name assigned for phrases). If that's not a stored alias, it returns undef.

store_key

  $self->find_key($key, $alias, $is_code_name);

Stores a key/alias pair. When a code name is generated, it will be stored twice, once to point the code name to the phrase and once to point the phrase back to the code name. The $is_code_name flag is used to indicate whether the $key is a code name or a phrase in this call. This flag is not used for anything right now, but might be used for something in the future and is used to at least allow you to discern which is the code name and which is not.

initialize

No op.

AUTHOR

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Qubling Software LLC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.