App-SpreadRevolutionaryDate

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    section named after the target in lower case ([mytarget]), or as
    command line parameters prefixed with the name of the target in lower
    case, followed by an underscore (--mytarget_myparam).

    Should you extend spread-revolutionary-date to a new target, we advise
    you to have a look on how default targets are implemented:
    App::SpreadRevolutionaryDate::Target::Bluesky with
    App::SpreadRevolutionaryDate::Target::Mastodon with Mastodon::Client
    worker, App::SpreadRevolutionaryDate::BlueskyLite worker, and
    App::SpreadRevolutionaryDate::Target::Twitter with Twitter::API worker.
    Mastodon and Twitter are using OAuth2 protocol <https://oauth.net/2/>
    to perform authentication. The other default targets,
    <App::SpreadRevolutionaryDate::Target::Liberachat> and
    App::SpreadRevolutionaryDate::Target::Freenode, use a chatbot
    <https://en.wikipedia.org/wiki/Chatbot>:
    App::SpreadRevolutionaryDate::Target::Liberachat::Bot and
    App::SpreadRevolutionaryDate::Target::Freenode::Bot, subclassing
    Bot::BasicBot worker. You can also see a very simple example with a
    test file provided in this distribution at t/new_target.t, which just
    prints out the revolutionary date on the standard output using core
    module IO::Handle.

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

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

    Then, you have to add a hook, being called before Moose constructor, so
    to pass as an additional argument to Moose constructor, an instance of
    your worker class as obj attribute of your new target class. You may
    need some configuration parameters, like worker_param in the example
    below, to create an instance of your worker class:

      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 Mastodon and
    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 with the name of the image
    file. This is used by Telechat message maker, to post an image of
    Groucha, the presenter of Téléchat, and by PromptUser and Gemini to
    send either an image file on local disk or an external image on the
    web.

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

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

    Starting from version 0.45, Mastodon and Bluesky classes have a
    max_lenght attribute (set to 300 for Mastodon and set to 250 for
    Bluesky), which is used to split a longer message into a thread of
    multiple posts. Again, we do not plan to extend this feature to Twitter
    target, since we recommand to not use this social network for political
    reasons.

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
    App::SpreadRevolutionaryDate::MsgMaker:: namespace (that is: the class
    should be App::SpreadRevolutionaryDate::MsgMaker::MyMsgMaker for a new
    MyMsgMaker message maker), that consumes the
    App::SpreadRevolutionaryDate::MsgMaker role. See "DESCRIPTION" in
    App::SpreadRevolutionaryDate::MsgMaker for a comprehensive description
    of this role.

    The name of the message maker should be set as a value of the
    "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
    Moose class or not) to craft the message.
    App::SpreadRevolutionaryDate::MsgMaker::RevolutionaryDate uses
    DateTime::Calendar::FrenchRevolutionary, while
    App::SpreadRevolutionaryDate::MsgMaker::PromptUser is based on
    IO::Prompt::Hooked and App::SpreadRevolutionaryDate::MsgMaker::Gemini
    just uses LWP to request Gemini server. You may need for example LWP to
    extract the message from a fetched web page or service, or XML::Feed to
    build it from a RSS <https://en.wikipedia.org/wiki/RSS> feed, or DBI to
    retrieve it from a database, or nothing at all to spread a fixed
    message, etc.

    If your new message maker class needs specific parameters (other than
    locale, which comes with App::SpreadRevolutionaryDate::MsgMaker role),
    they should be defined as attributes of this class. Values for such
    attributes should be set in the configuration file, inside a section
    named after the message maker in lower case ([mymsgmaker]), or as
    command line parameters prefixed with the name of the message maker in
    lower case, followed by an underscore (--mymsgmaker_myparam).

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

 Gemini message maker

    From version 0.45, a new message maker is included which requests
    Gemini AI. This allows to extend spread-revolutionary-date just by
    configuring a few options. The most practical way to configure these
    options is to prepare everything by setting all "Gemini options" in the
    configuration file, except "process" to pickup the prompt at execution
    time by using the --gemini_process <ThisPrompt> command line parameter.

    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 i...



( run in 3.427 seconds using v1.01-cache-2.11-cpan-f0ff5d10edf )