App-SpreadRevolutionaryDate
view release on metacpan or search on metacpan
NAME
spread-revolutionary-date - Spread date and time from Revolutionary
(Republican) Calendar
VERSION
version 0.54
DESCRIPTION
spread-revolutionary-date is a Free Software
<https://www.gnu.org/philosophy/free-sw.html> that spreads the current
date, expressed in the French Revolutionary calendar
<https://en.wikipedia.org/wiki/French_Republican_calendar>, to various
social networks: Mastodon <https://mastodon.social/>, Bluesky
<https://bsky.app/>, Twitter <https://twitter.com/>, the Liberachat
<https://libera.chat/> and Freenode <https://freenode.net/> Internet
Relay Chat networks.
Moreover, you can easily extend these defaults targets with any desired
one, see "EXTENDING TO NEW TARGETS", and even spread something else
than the revolutionary date, see "msgmaker" option and "EXTENDING TO
NEW MESSAGE MAKERS".
The French Revolutionary calendar, also called Republican calendar, was
introduced during the French Revolution
<https://en.wikipedia.org/wiki/French_Revolution>, and used from late
1793 to 1805, and also during the Paris Commune
<https://en.wikipedia.org/wiki/Paris_Commune> in 1871. This was an
attempt to get rid of religious and royalist references found in
Gregorian calendar when naming measures of Time. Months were given new
names based on nature, each day of the year, instead of being named
after an associated saint, had a unique name associated with the rural
economy: agricultural tools, common animals, grains, pastures, trees,
roots, flowers, fruits, plants, and minerals. But this was also an
attempt to give more rational in measuring Time, basing measures on
decimal system. Instead of weeks, each month was divided into exactly 3
décades, that is ten days; days were divided into ten hours; hours into
100 minutes; and minutes into 100 seconds.
You must have a registered account on each of the targets you want to
spread the revolutionary date. And you must get credentials for
spread-revolutionary-date to post on Mastodon, Bluesky and Twitter, and
also for IA generated messages with Gemini message maker. Finally, you
have to configure spread-revolutionary-date to use these credentials,
see "CONFIGURATION" and "COMMAND LINE PARAMETERS" below.
The revolutionary date and time is computed thanks to the
DateTime::Calendar::FrenchRevolutionary Perl module, by Jean Forget.
USAGE
# Just execute the script in your shell
# to spread current date to configured accounts
# to Bluesky, Twitter, Mastodon, Freenode and Liberachat:
$ spread-revolutionary-date
# Or, since this script does nothing but calling
# the L<App::SpreadRevolutionaryDate> Perl module,
# use this one-liner:
$ perl -MApp::SpreadRevolutionaryDate \
-e 'App::SpreadRevolutionaryDate->new->spread;'
# Test spreading to Mastodon only:
$ spread-revolutionary-date \
--targets=Mastodon --test
# Test spreading to Twitter only in English:
$ spread-revolutionary-date \
--targets=Twitter \
--test \
--locale en
# 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 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
This option can be specified multiple times, with values as strings. It
explicitly defines targets where the revolutionary date should be
spread to. Any value set for this option should be a valid target: any
of the five default targets (Mastodon, Bluesky, Twitter, Liberachat, or
Freenode) or some new target if you have extended this application (see
"EXTENDING TO NEW TARGETS"). If this option is not defined, the
revolutionary date is spread on all five default targets: Mastodon,
Bluesky, Twitter, Liberachat, or Freenode.
msgmaker
This option can only be specified once, with a value as string. Spreads
a message computed by the class defined by the value of this option,
defaults to RevolutionaryDate. The Value (case sensitive) of this
option should correspond to an existing
App::SpreadRevolutionaryDate::MsgMaker::Value class consuming
App::SpreadRevolutionaryDate::MsgMaker role. Message makers values
pre-defined in this distribution are RevolutionaryDate, which spreads
the revolutionary date; PromptUser, which prompts the user for the
message to be spread (with confirmation); Telechat, which spreads the
date of the day similar to the Belgian-French TV show 'Téléchat" on the
1980's; and Gemini which prompts Gemini AI to generate a message. See
"EXTENDING TO NEW MESSAGE MAKERS" for details on using a new value for
this option.
locale
This option can only be specified once, with a value as string. Spreads
with chosen language. As of App::SpreadRevolutionaryDate 0.11 locale is
limited to 'fr', 'en', 'it' or 'es' for RevolutionaryDate and 'fr',
'en', 'it', 'es' or 'de' otherwise. Defaults to 'fr' for
RevolutionaryDate and Gemini, and to 'en' for <PromptUser>. Locale is
forced to 'fr' for Telechat since only french-spokers can understand
the TV show. To add more languages see "INTERNATIONALIZATION AND
LOCALIZATION".
test
This boolean option takes no value, either it is defined or not. If
defined, do not actually spread the revolutionary date, just print it
on standard output for Mastodon, Bluesky and Twitter, and send it on
configured test channels for Liberachat and Freenode (see
"test_channels" below).
Mastodon options
These options are credentials for spread-revolutionary-date to spread
on a Mastodon account. You have to get them from your Mastodon instance
API account <https://mstdn.fr/settings/applications> with write scope.
Note that Mastodon is a decentralized network with multiple instances,
the previous link is for mstdn.fr instance, please replace url with
your preferred instance. They should be defined in the [mastodon]
section of the configuration file.
instance
This option can only be specified once, with a value as string: the
domain name of your instance, eg: mastodon.social, mstdn.fr, etc.
client_id
This option can only be specified once, with a value as string: your
Mastodon Client key for this application.
client_secret
This option can only be specified once, with a value as string: your
Mastodon Client secret for this application.
access_token
This option can only be specified once, with a value as string: your
Mastodon Access token for this application.
Bluesky options
These options are credentials for spread-revolutionary-date to spread
on a Bluesky account. You have to get them from your Bluesky account
<https://bsky.app/>. They should be defined in the [bluesky] section of
the configuration file.
identifier
This option can only be specified once, with a value as string: your
Bluesky identifier (ending with .bsky.social by default).
password
This option can only be specified once, with a value as string: your
Bluesky password. You can define a special password for this
application, in order to not use your main Bluesky password in your
Bluesky account settings <https://bsky.app/settings/app-passwords>.
Twitter options
These options are credentials for spread-revolutionary-date to spread
on a Twitter account. You have to get them from your Twitter API
account <https://apps.twitter.com/> with write access level. They
should be defined in the [twitter] section of the configuration file.
consumer_key
This option can only be specified once, with a value as string: your
Twitter Consumer API key for this application.
consumer_secret
This option can only be specified once, with a value as string: your
Twitter Consumer API secret key for this application.
access_token
This option can only be specified once, with a value as string: your
Twitter Access token for this application.
access_token_secret
This option can only be specified once, with a value as string: your
Twitter Access token secret for this application.
Liberachat options
The first two options are credentials for spread-revolutionary-date to
spread on a Liberachat account. See
https://libera.chat/guides/registration to find out how to register an
account on Liberachat. They should be defined in the [liberachat]
section of the configuration file.
nickname
This option can only be specified once, with a value as string: your
Liberachat nickname.
password
This option can only be specified once, with a value as string: your
Liberachat password.
channels
This option can be specified multiple times, with values as strings.
spread-revolutionary-date will spread on every channel specified with
this option. This option should be specified at least one time if
"test" option is not set. It is ignored if "test" option is set.
test_channels
This option can be specified multiple times, with values as strings.
spread-revolutionary-date will spread on every channel specified with
this option. This option should be specified at least one time if
"test" option is set. It is ignored if "test" option is not set.
Freenode options
The first two options are credentials for spread-revolutionary-date to
spread on a Freenode account. See
https://freenode.net/kb/answer/registration to find out how to register
an account on Freenode. They should be defined in the [freenode]
section of the configuration file.
nickname
This option can only be specified once, with a value as string: your
Freenode nickname.
password
This option can only be specified once, with a value as string: your
Freenode password.
channels
This option can be specified multiple times, with values as strings.
spread-revolutionary-date will spread on every channel specified with
this option. This option should be specified at least one time if
"test" option is not set. It is ignored if "test" option is set.
test_channels
This option can be specified multiple times, with values as strings.
spread-revolutionary-date will spread on every channel specified with
this option. This option should be specified at least one time if
"test" option is set. It is ignored if "test" option is not set.
RevolutionaryDate options
These options change the way revolutionary date is computed when
"msgmaker" option is RevolutionaryDate. They should be defined in the
[revolutionarydate] section of the configuration file.
acab
This boolean option takes no value, either it is defined or not,
defaults to false. If defined, instead of spreading the current date
and time, pretend that decimal time is 1:31:20 (which corresponds to
03:08:56 UTC, 04:08:56 Paris winter time, or 05:08:56 Paris summer
time, in sexagesimal scale used by common Anglo-Babylonian Time).
wikipedia_link
This boolean option takes no value, either it is defined or not,
defaults to true. If defined, a link to the wikipedia page, in language
defined by the locale option, corresponding to the feast of the day, is
added to the date to be spread.
PromptUser options
If "msgmaker" option is PromptUser, instead of spreading the
revolutionary date, prompts the user (with confirmation) for the
message to be spread, with a default value (if user enters nothing when
prompted).
default
This option can only be specified once, with a value as string. If
the configuration file. It is only used if "msgmaker" option is Gemini.
img_alt (for Gemini)
This option can be specified for several prompts, each one with a key
as a string, valued by the string configured for "process" options
above, and a value as string valued by an alternative text to an image
file specified by img_path or img_url options. The img_alt option
should be defined in the [Gemini] section of the configuration file. It
is only used if "msgmaker" option is Gemini.
img_url (for Gemini)
This option can be specified for several prompts, each one with a key
as a string, valued by the string configured for "process" options
above, and a value as string valued by an external url to a remote
image. The img_url option should be defined in the [Gemini] section of
the configuration file. It is only used if "msgmaker" option is Gemini.
COMMAND LINE PARAMETERS
Any command line parameter, other than the first three ones below,
takes precedence on the corresponding option specified on the
confiuration file, see "CONFIGURATION" above.
Command line only parameters
--conf=<file> | -c <file>
Use <file> path as configuration file, instead of the default ones, see
"CONFIGURATION" above.
--version | -v
Prints out the version of spread-revolutionary-date.
--help | -h | -?
Prints out help with command line parameters.
General parameters
--targets=<target> | -tg <target>
Same as "targets" configuration option above.
--msgmaker=<MsgMakerClass> | -mm <MsgMakerClass>
Same as "msgmaker" configuration option above.
--locale=<fr|en|it|es> | -l <fr|en|it|es>
Same as "locale" configuration option above.
--test | --no | -n
Same as "test" configuration option above.
Mastodon parameters
These parameters specify credentials for spread-revolutionary-date to
spread on a Mastodon account. You have to get them from your Mastodon
instance API account <https://mstdn.fr/settings/applications> with
write scope. Note that Mastodon is a decentralized network with
multiple instances, the previous link is for mstdn.fr instance, please
replace url with your preferred instance.
--mastodon_instance=<instance> | -mi <instance>
Same as "instance" configuration option above.
--mastodon_client_id=<id> | -mci <id>
Same as "client_id" configuration option above.
--mastodon_client_secret)<secret> | -mcs <secret>
Same as "client_secret" configuration option above.
--mastodon_access_token=<token> | -mat <token>
Same as "access_token" configuration option above.
Bluesky parameters
These parameters specify credentials for spread-revolutionary-date to
spread on a Bluesky account. You have to get them from your Bluesky
account <https://bsky.app/>.
--bluesky_identifier=<identifier> | -bi <identifier>
Same as "identifier" configuration option above.
--bluesky_password=<password> | -bp <password>
Same as "password" configuration option above.
Twitter parameters
These parameters specify credentials for spread-revolutionary-date to
spread on a Twitter account. You have to get them from your Twitter API
account <https://apps.twitter.com/> with write access level.
--twitter_consumer_key=<key> | -tck <key>
Same as "consumer_key" configuration option above.
--twitter_consumer_secret=<secret> | -tcs <secret>
Same as "consumer_secret" configuration option above.
--twitter_access_token=<token> | -tat <token>
Same as "access_token" configuration option above.
--twitter_access_token_secret=<token secret> | -tats <token secret>
Same as "access_token_secret" configuration option above.
Liberachat parameters
The first two parameters are credentials for spread-revolutionary-date
to spread on a Liberachat account. See
https://libera.chat/guides/registration to find out how to register an
account on Liberachat.
--liberachat_nickname=<nick> | -ln <nick>
Same as "nickname" configuration option above.
--liberachat_password=<passwd> | -lp <passwd>
Same as "password" configuration option above.
--liberachat_channels=<channel> | -lc <channel>
Same as "channels" configuration option above.
--liberachat_test_channels=<channel> | -ltc <channel>
Same as "test_channels" configuration option above.
Freenode parameters
The first two parameters are credentials for spread-revolutionary-date
to spread on a Freenode account. See
https://freenode.net/kb/answer/registration to find out how to register
an account on Freenode.
--freenode_nickname=<nick> | -fn <nick>
Same as "nickname" configuration option above.
--freenode_password=<passwd> | -fp <passwd>
Same as "password" configuration option above.
--freenode_channels=<channel> | -fc <channel>
Same as "channels" configuration option above.
--freenode_test_channels=<channel> | -ftc <channel>
Same as "test_channels" configuration option above.
RevolutionaryDate parameters
--revolutionarydate_acab | -ra
Same as "acab" configuration option above.
--revolutionarydate_wikipedia_link
Same as "wikipedia_link" configuration option above.
PromptUser parameters
--promptuser_default <msg> | -pud <msg>
Same as "default" configuration option above.
--promptuser_img_path <path/to/image/file> | -pui </path/to/image/file>
Same as "img_path (for PromptUser)" configuration option above.
--promptuser_img_alt <alternative text> | -pua <alternative text>
Same as "img_alt (for PromptUser)" configuration option above.
--promptuser_img_url <img_url> | -puu <img_url>
Same as "img_url" (for PromptUser) configuration option above.
Gemini parameters
--gemini_api_key <api key> | -ga <api key>
Same as "api_key" configuration option above.
--gemini_process <SomePrompt> | -g <SomePrompt>
Same as "process" configuration option above.
--gemini_prompt "<SomePrompt>=<my prompt string>" | -gp "<SomePrompt>=<my
prompt string>"
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
( run in 0.958 second using v1.01-cache-2.11-cpan-f56aa216473 )