App-SpreadRevolutionaryDate

 view release on metacpan or  search on metacpan

bin/spread-revolutionary-date  view on Meta::CPAN


=head3 --gemini_prompt "<SomePrompt>=<my prompt string>" | -gp "<SomePrompt>=<my prompt string>"

Same as L</process> configuration option above.

=head3 --gemini_intro "<SomePrompt>=<intro msg>" | -gi "<SomePrompt>=<intro msg>"

Same as L</process> configuration option above.

=head3 --gemini_search "<SomePrompt>=1" | -gs "<SomePrompt>=1"

Same as L</process> configuration option above.

=head3 --gemini_img_path "<SomePrompt>=<path/to/image/file>" | -gip "<SomePrompt>=</path/to/image/file>"

Same as L</img_path (for Gemini)> configuration option above.

=head3 --gemini_img_alt "<SomePrompt>=<alternative text>" | -gia "<SomePrompt>=<alternative text>"

Same as L</img_alt (for Gemini)> configuration option above.

=head3 --gemini_img_url "<SomePrompt>=<img_url>" | -giu "<SomePrompt>=<img_url>"

Same as L</img_url (for Gemini)> configuration option above.

=head1 EXTENDING TO NEW TARGETS

Starting from version 0.07, this distribution takes advantage of L<Moose>, the postmodern object system for Perl 5, allowing to easily extend C<spread-revolutionary-date> to other targets than the default ones (C<Mastondon>, C<Bluesky>, C<Twitter>, C...

To add a new target, you should write a new class in the C<App::SpreadRevolutionaryDate::Target::> namespace (that is: the class should be C<App::SpreadRevolutionaryDate::Target::Mytarget> for a new C<Mytarget> target), that consumes the L<App::Sprea...

The name of the target should be added as a value of the L</targets> option.

Such a target class is actually just a wrapper. Usually a target has to use an existing specific  C<worker> module (which can be a C<Moose> class or not) to perform the actual work of posting a message according the specific target protocol, after ha...

To perform authentication and to post a message, there is a strong likelihood that the new target requires specific parameters (e.g.: tokens, keys, account name, password, channels, etc.). These parameters should be defined as required attributes of ...

Should you extend C<spread-revolutionary-date> to a new target, we advise you to have a look on how default targets are implemented: L<App::SpreadRevolutionaryDate::Target::Bluesky> with L<App::SpreadRevolutionaryDate::Target::Mastodon> with L<Mastod...

Your new C<App::SpreadRevolutionaryDate::Target::Mytarget> target class should consumes the L<App::SpreadRevolutionaryDate::Target> role, by specifying the C<worker> class:

  use Moose;
  with 'App::SpreadRevolutionaryDate::Target'
    => {worker => 'My::Worker::Class'};

Then, you have to add a hook, being called before C<Moose> constructor, so to pass as an additional argument to C<Moose> constructor, an instance of your C<worker> class as C<obj> attribute of your new target class. You may need some configuration pa...

  around BUILDARGS => sub {
    my ($orig, $class) = @_;
    my $args = $class->$orig(@_);
    my $args->{obj} = My::Worker::Class->new(worker_param => $args->{worker_param});
    return $args;
  }

Starting from version 0.39, you may have noticed that C<Mastodon> and C<Bluesky> targets can now spread not only a text message, but also an image, with an alternative text for accessibily purpose. If the alternative text is not provided, it is set w...

This feature is not available now for I<IRC> targets, C<Liberachat> and C<Freenode>, since theses targets are mostly for text messages.

Also, we do not plan to extend this feature to C<Twitter> target, since we recommand to not use this social network for political reasons.

Starting from version 0.45, C<Mastodon> and C<Bluesky> classes have a C<max_lenght> attribute (set to 300 for C<Mastodon> and set to 250 for C<Bluesky>), which is used to split a longer message into a thread of multiple posts. Again, we do not plan t...

=head1 EXTENDING TO NEW MESSAGE MAKERS

It is even easier to spread whatever you want instead of the revolutionary date. You should write a new class in the C<App::SpreadRevolutionaryDate::MsgMaker::> namespace (that is: the class should be C<App::SpreadRevolutionaryDate::MsgMaker::MyMsgMa...

The name of the message maker should be set as a value of the L</msgmaker> option.

Such a message maker class is actually just a wrapper. Usually a message maker has to use an existing specific module (which can be a C<Moose> class or not) to craft the message. L<App::SpreadRevolutionaryDate::MsgMaker::RevolutionaryDate> uses L<Dat...

If your new message maker class needs specific parameters (other than C<locale>, which comes with  L<App::SpreadRevolutionaryDate::MsgMaker> role), they should be defined as attributes of this class. Values for such attributes should be set in the L<...

Have a look to L<App::SpreadRevolutionaryDate::MsgMaker::PromptUser> or L<App::SpreadRevolutionaryDate::MsgMaker::Telechat> classes, they show simple examples on how to extend C<spread-revolutionary-date> to a new message maker.

=head2 Gemini message maker

From version 0.45, a new message maker is included which requests I<Gemini> AI. This allows to extend C<spread-revolutionary-date> just by configuring a few options. The most practical way to configure these options is to prepare everything by settin...

This way, you can setup different prompts in your configuration file. Here is an example with 4 different prompts configured:

  [Gemini]
  # See https://ai.google.dev/gemini-api/docs/api-key
  api_key                      = 'GEMINI_API_KEY'
  prompt   FamousBirthday      = 'Which famous people have their birthday on $month_name $day? Give a list of up to 6 people, then after the list give the unformatted URL of the Wikipedia page of only one of them, no comments and no need for an intro...
  intro    FamousBirthday      = 'FamousBirthday=Famous people born on $month_name $day for better or for worse:'

  prompt   MacronJokeColuche   = 'Invente-moi une blague dans le style de Coluche sur Emmanuel Macron. Pas besoin de dire "D\'accord, voici une blague" ou "Bien sûr, voici une blague dans le style de Coluche sur Emmanuel Macron" avant la blague.'
  img_path MacronJokeColuche   = '/usr/local/share/perl/5.32.1/auto/share/dist/App-SpreadRevolutionaryDate/images/coluche_macron.png'
  img_alt  MacronJokeColuche   = 'Caricature de Coluche disant : « C’est l’histoire d’un mec… » avec une caricature de macron'

  prompt   BlanquiRevival      = 'Invente-moi un dicton révolutionnaire dans le style d\'Auguste Blanqui. Ne fais pas d\'introduction.'
  img_url  BlanquiRevival      = 'https://example.com/imgs/my_image.jgp'

  prompt   MeteoParis          = 'Quelle est la météo aujourd\'hui à Paris, avec la température, selon meteo-paris.com, ne devine pas, va chercher l\'information.'
  search   MeteoParis          =  1

and, then choose the prompt to use at execution time, like:

  $ spread-revolutionary-date --msgmaker=Gemini --gemini_process=FamousBirthday --locale=en
  $ spread-revolutionary-date --msgmaker=Gemini --gemini_process=MacronJokeColuche
  $ spread-revolutionary-date --msgmaker=Gemini --gemini_process=BlanquiRevival
  $ spread-revolutionary-date --msgmaker=Gemini --gemini_process=MeteoParis

These examples show how you can tweak your message to be spread. Let's review all these options:

First, you have to define credentials to use the I<Gemini API>, by defining the L</api_key> option. For this you need to get a I<Gemini API key>, by following instructions on L<https://ai.google.dev/gemini-api/docs/api-key>.

Then for each prompt, you have to choose an identifier, which is one word in camel case, like C<FamousBirthday>, C<MacronJokeColuche>, C<BlanquiRevival> or C<MeteoParis>. This prompt identifier should be the value of the C<< --gemini_process <ThisPro...

All other options are relative to one particular prompt, and therefore prefixed with the corresponding identifier. Under the hood, these options are hashes keyed with prompt identifiers:

=over

=item L</prompt>

This is the option where you can define your prompt. It is advised to test this prompt to have I<Gemini> answer as you wish. For instance, I<Gemini> often start its answers to your prompt by: “Sure, here is ‘what you've asked for’, and you woul...

You can test your prompt with interactive form to I<Gemini> at L<https://gemini.google.com/app> or with C<spread-revolutionary-date> with options C<--test> and C<--targets=Mastodon> for example.

The spread message will be I<Gemini> answer, optionally prepended with a configured introduction (see bellow), and ending with hashtags C<#IAGenerated> C<#PromptIdentifier>.



( run in 1.993 second using v1.01-cache-2.11-cpan-d8267643d1d )