Wolfram Research

RandomFortune

Contributed by: Rick Hennigan

Source Notebook

Get a random fortune

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" Automatic a 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

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

DataSource

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]=

Resource History

Source Metadata

See Also