App-SpreadRevolutionaryDate

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    
      # Spread acab time to Twitter and Liberachat
      # explicit channels
      $ spread-revolutionary-date \
          --targets=Twitter \
          --targets=Liberachat \
          --liberachat_channels='#revolution' \
          --liberachat_channels='#acab' \
          --revolutionarydate_acab
    
      # Prompt user for a message to spread to Mastodon
      $ spread-revolutionary-date \
          --targets=Mastodon \
          --msgmaker=UserPrompt
    
      # Spread message as command line parameter to
      # Mastodon, Bluesky, Twitter, Liberachat and Freenode
      $ spread-revolutionary-date \
          --msgmaker=UserPrompt \
          --promptuser_default
    
      # Spread message and image as command line parameter to
      # Mastodon and Bluesky
      $ spread-revolutionary-date \
          --msgmaker=UserPrompt \
          --targets=Mastodon \
          --targets=Bluesky \
          --promptuser_default \
            'This is my message to the world'
          --promptuser_img_path= \
            /my/path/to/image.png
          --promptuser_img_alt= \
            'Alternative text for image'
    
      # Spread message and image form web as command line parameter to
      # Mastodon and Bluesky
      $ spread-revolutionary-date \
          --msgmaker=UserPrompt \
          --targets=Mastodon \
          --targets=Bluesky \
          --promptuser_default \
            'This is my message to the world'
          --promptuser_img_url= \
            'https://example.com/imgs/my_image.jgp'
          --promptuser_img_alt
    
      # Spread Téléchat date of the day on Mastodon and BlueSky
      $ spread-revolutionary-date \
          --msgmaker=Telechat \
          --targets=Mastodon \
          --targets=Bluesky
    
      # Spread Gemini generating an illustrated joke on Mastodon
      # NB: usually prompts are defined in configuration file along
      # with api_key, while --gemini-process is passed on command line
      # to choose which prompt to process
      $ spread-revolutionary-date \
          --targets=Mastodon \
          --msgmaker=Gemini \
          --gemini_api_key=ApiKey \
          --gemini_process=MacronJokeColuche \
          --gemini_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.' \
          --gemini_img_path "MacronJokeColuche='/my/path/to/image.png'" \
          --gemini_img_alt "MacronJokeColuche='Caricature de Coluche \
            disant : « C’est l’histoire d’un mec… » avec une caricature \
            de macron'" \
    
      # Spread Gemini searching for real time weather on Mastodon
      # NB: usually prompts are defined in configuration file along
      # with api_key, while --gemini-process is passed on command line
      # to choose which prompt to process
      $ spread-revolutionary-date \
          --targets=Mastodon \
          --msgmaker=Gemini \
          --gemini_api_key=ApiKey \
          --gemini_process=MeteoParis \
          --gemini_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.' \
          --gemini_search "MeteoParis=1"
    
      # Spread Gemini generating a list of celebrities with an url
      # prepended by an introdution on Mastodon
      # NB: usually prompts are defined in configuration file along
      # with api_key, while --gemini-process is passed on command line
      # to choose which prompt to process
      $ spread-revolutionary-date \
          --targets=Mastodon \
          --msgmaker=Gemini \
          --gemini_api_key=ApiKey \
          --gemini_process=FamousBirthday \
          --gemini_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 introduction like "Here are some famous people".' \
          --gemini_intro 'FamousBirthday=Famous people born on $month_name \
            $day for better or for worse:'

CONFIGURATION

    Once again: you have to configure spread-revolutionary-date with
    credentials for registered account on each of the desired targets and
    also for Gemini message maker, so it can spread the revolutionary date
    or an IA generated message on behalf of these accounts.

    Configuration options may also be specified as command line parameters,
    see "COMMAND LINE PARAMETERS" below, which take precedence on options
    of the configuration file.

    The configuration file should lie on
    ~/.config/spread-revolutionary-date/spread-revolutionary-date.conf or
    ~/.spread-revolutionary-date.conf. In case a file is found on both
    paths, the second one is ignored. The configuration file should use the
    popular INI file format <https://en.wikipedia.org/wiki/INI_file>. A
    sample configuration file can be found in this distribution at
    etc/sample-spread-revolutionary-date.conf.

 General options

    These options should appear outside of any section of the configuration
    file.

  targets

README  view on Meta::CPAN

    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...
      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 Gemini API, by
    defining the "api_key" option. For this you need to get a Gemini API
    key, by following instructions on
    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 FamousBirthday, MacronJokeColuche,
    BlanquiRevival or MeteoParis. This prompt identifier should be the
    value of the --gemini_process <ThisPrompt> command line parameter.

    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:

    "prompt"

      This is the option where you can define your prompt. It is advised to
      test this prompt to have Gemini answer as you wish. For instance,
      Gemini often start its answers to your prompt by: “Sure, here is
      ‘what you've asked for’, and you wouldn't want to spread this
      introduction in your message. In this case, you should write your
      prompt instructing Gemini to not include any introduction.

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

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

      Prompts often need to mention informations relative to today, such as
      the FamousBirthday example below, or it could be that you wanna ask
      Gemni for today's weather, or traffic jams occuring the same day of
      the week as today, etc. As a syntactic sugar, you can insert in
      "prompt" option, any variable prefixed with a dollar sign ($) which
      correspond to a method of DateTime module applied to DateTime-now()>
      object, and it will be replaced by the result of this method in the
      prompt sent to Gemini. For example, in the FamousBirthday example
      below, if run on June 21st, the prompt sent to Gemini would be:

        'Which famous people have their birthday on June 21? 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 introduction like "Here are some famous...

      You should be careful that such variables are not interpreted by the
      Shell before calling spread-revolutionary-date, specially if
      specified as command line parameters. You can prevent such
      intepretation by the Shell by enclosing the option in single quotes,
      like the examples above.

    "intro"

      You may want that the spread message to start with your own
      introducing words before displaying Gemini answer. You can specify
      this with the "intro" option.

      Likewise, this option use the same syntactic sugar relative to
      methods of DateTime module. For example, the message spread on June
      21st by the FamousBirthday example bellow, would be something like

        Famous people born on June 21 for better or for worse:
        First Name
        Second Name
        Third Name
        Fourth Name
        Fifth Name
        Sixth Name
      



( run in 1.836 second using v1.01-cache-2.11-cpan-5735350b133 )