Function Repository Resource:

RandomFortune

Source Notebook

Get a random fortune

Contributed by: Rick Hennigan

ResourceFunction["RandomFortune"][]

gets a random, hopefully interesting, adage.

ResourceFunction["RandomFortune"][n]

gets n random fortunes.

Details and Options

RandomFortune is based on the Unix program fortune.
RandomFortune has the following option:
"DataSource"Automatica file containing fortunes to use
The value for "DataSource" should be a file, URL, CloudObject or LocalObject containing plaintext fortunes delimited by "%".

Examples

Basic Examples (5) 

Get a random fortune:

In[1]:=
ResourceFunction["RandomFortune"][]
Out[1]=

Get another fortune:

In[2]:=
ResourceFunction["RandomFortune"][]
Out[2]=

Have a bird say your fortune:

In[3]:=
ResourceFunction["RandomFortune"][] // ResourceFunction["BirdSay"]
Out[3]=

Get multiple fortunes (some might consider this cheating):

In[4]:=
ResourceFunction["RandomFortune"][3]
Out[4]=

Get your fortune in a dialog window:

In[5]:=
MessageDialog[ResourceFunction["RandomFortune"][]]
Out[5]=

Options (2) 

DataSource (2) 

A source file containing fortunes (delimited by "%") can be specified:

In[6]:=
data = "Today's lucky numbers are 1, 2, 3, 4.\n%\nDon't forget to file your taxes.\n%\nHave a nice day."
Out[6]=
In[7]:=
file = Export[CreateFile[], data, "Text"]
Out[7]=
In[8]:=
ResourceFunction["RandomFortune"]["DataSource" -> file]
Out[8]=

Specify a URL as the data source:

In[9]:=
ResourceFunction["RandomFortune"][3, "DataSource" -> "https://raw.githubusercontent.com/bmc/fortunes/master/fortunes"]
Out[9]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 13 February 2019

Related Resources

Author Notes

Data is provided under the Creative Commons Attribution 4.0 International License. For details, please see http://creativecommons.org/licenses/by/4.0/legalcode.

License Information