Building Telegram Bots: Develop Bots in 12 Programming Languages Using The Telegram Bot API 1st Edition Nicolas Modrzyk
Building Telegram Bots: Develop Bots in 12 Programming Languages Using The Telegram Bot API 1st Edition Nicolas Modrzyk
com
https://textbookfull.com/product/building-
telegram-bots-develop-bots-in-12-programming-
languages-using-the-telegram-bot-api-1st-edition-
nicolas-modrzyk/
https://textbookfull.com/product/introducing-azure-bot-service-
building-bots-for-business-waghmare/
textbookfull.com
https://textbookfull.com/product/practical-bot-development-designing-
and-building-bots-with-node-js-and-microsoft-bot-framework-szymon-
rozga/
textbookfull.com
https://textbookfull.com/product/management-16e-stephen-p-robbins/
textbookfull.com
Bodyweight Strength Training 12 Weeks to Build Muscle and
Burn Fat 1st Edition Jay Cardiello
https://textbookfull.com/product/bodyweight-strength-
training-12-weeks-to-build-muscle-and-burn-fat-1st-edition-jay-
cardiello/
textbookfull.com
https://textbookfull.com/product/contemporary-empirical-methods-in-
software-engineering-michael-felderer/
textbookfull.com
https://textbookfull.com/product/the-shias-of-pakistan-an-assertive-
and-beleaguered-minority-1st-edition-andreas-rieck/
textbookfull.com
https://textbookfull.com/product/only-fear-mindhunters-1-1st-edition-
anne-marie-becker/
textbookfull.com
Endophytes Mineral Nutrient Management 1st Edition Dinesh
Kumar Maheshwari (Editor)
https://textbookfull.com/product/endophytes-mineral-nutrient-
management-1st-edition-dinesh-kumar-maheshwari-editor/
textbookfull.com
Building
Telegram Bots
Develop Bots in 12 Programming
Languages using the Telegram
Bot API
—
Nicolas Modrzyk
Building Telegram
Bots
Develop Bots in
12 Programming Languages
using the Telegram Bot API
Nicolas Modrzyk
Building Telegram Bots: Develop Bots in 12 Programming Languages using
the Telegram Bot API
Nicolas Modrzyk
Tokyo, Tokyo, Japan
iii
Table of Contents
iv
Table of Contents
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
Index�������������������������������������������������������������������������������������������������271
viii
About the Author
Nicolas Modrzyk has more than 15 years of
IT experience in Asia, Europe, and the United
States and is currently CTO of an international
consulting company in Tokyo, Japan. He is
the author of four other published books,
mostly focused on the Clojure language and
expressive code. When not bringing new
ideas to customers, he spends time with his
two fantastic daughters, Mei and Manon, and
playing live music internationally.
ix
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
About the Technical Reviewers
Dushyant Rathore is currently working as
a firmware engineer with Western Digital.
His experience includes full-stack web
development, machine learning, decentralized
applications, and others. Dushyant has worked
on several kinds of projects related to IoT,
chatbots, web sites, scrapers, command-
line tools, and machine learning projects,
among others, at various startups. He has participated in national and
international hackathons and has won a few of them. He is a big cloud
computing enthusiast.
xi
Acknowledgments
It’s been yet another typing race to get this book out on time and beat the
odds. Divya and Nikhil, thank you so much for teaming up again. I’m really
looking forward to our next collaboration!
I received support from so many people that it would take another
book just to write the list of names. Nevertheless…
Thank you to my sister, Emily, my brother, Gregor, Mum and Dad,
family, cousins, uncles, aunts, friends, Abe-san, Sawada-san, Gucci,
Marshall, Momo, my soulmate Sachiko, soccer friends (I would break a
knee for you), the Irish crew still enjoying Guinness (one more for me!),
the awesome people in America (who always find the LPs I’m missing),
Chris and the Biners, the French team that’s always there to support
me, even without being asked, and the people deep in my heart, for
your never-ending support. I could not have finished this without you.
I appreciate you all so much.
And, of course, thank you to my two wonderful daughters, Mei and
Manon, for keeping up and always doing your best, even during hard
times. You rock! I love you.
xiii
Introduction
With a hundred ways to do a dozen things, why not try it all?
—Julian Casablancas
Have you ever wondered how you could accomplish more by doing less,
how you could have a sort of double who does all the work while you enjoy
some cool beachside or spend more outdoor time with your beautiful
children? I always have.
I am a big fan of the Telegram chat platform. Let’s call it a platform,
because it is more than a simple chat service with which you can stay in
touch with people who matter to you most. It also enables you to think in
ways you haven’t before.
For example, living in Tokyo, you always care about what time the last
train home is going to depart. I guess most people in big cities around the
globe probably have that same concern. Checking the clock only every so
often can result in a terrible and/or expensive taxi ride, so I started wanting
something that automatically offered me a bunch of options to get home.
The first bot I wrote was to tell me the schedule of the last few trains
home and some different options, from the easiest to reach before the last
few departures to the very latest, which I would have to dash to catch. That
saved me quite a bit of money.
The second bot I wrote was slightly more IoT-oriented. It used a
webcam to send me via Telegram pictures of people who rang my doorbell.
The third one, I also remember, was kind of stupid. It was to use a mini
projector to display the most recent message coming through a Telegram
chat room. (It’s very entertaining to view random messages during a small
party at home.)
xv
Introduction
But there are so many things for which to try to build a bot—search
for a plane ticket, check your fridge, etc. Having a bot is a simple way
to facilitate all the things you do daily, using the same kind of simple
Telegram chat rooms to get answers to questions related to daily life or to
issue commands and conquer the world.
This relatively short book is about learning how to write Telegram
bots in several different programming languages. Why not use one
and stick to it? you might ask. Well, because there’s not one answer to
all questions, and what’s right for others might not be suitable for you.
Exploring different programming languages is also a fun way to examine
the strengths of each language while performing the same tasks. Each of
the Telegram concepts can be introduced one after the other, in a simple
fashion.
Or, you could just jump in and choose the language you want to try and
get started in no time. Some people want it to happen; some wish it would
happen; others make it happen. So, enjoy reading this book, and make it
happen.
xvi
CHAPTER 1
Week 1: Ruby
Mindful Monday Humans, may your coffee kick in before
reality does.
—Napz Cherub Pellazo
Ruby took the world by storm a while ago, owing to the ease and concision
of the code you can write with it. Most programmers have a sweet spot for
Ruby, and when their shell scripts and day-to-day lives get too messy, they
are usually very quick to switch to Ruby.
This first chapter is a bit special, because on top of creating a client
for our bot, I must also introduce you to how to create the bot itself.
Throughout the book, this first bot will be reused at will, although, of
course, the same steps used to make it could be used to create a bot army
and conquer the world!
C
hatting with the BotFather
To register your own Telegram bot, you must talk to the father of all bots.
This bot father has a name, BotFather; Brad or Vladimir just doesn’t cut it.
He can be reached via Telegram as @BotFather.
BotFather does not sleep and can be reached at any time of day.
BotFather does take showers and always looks fresh. Here is the last profile
picture we have of this handsome bot (Figure 1-1).
Finding BotFather is not so difficult; you just have to type his name,
“@BotFather,” in the Telegram list of people in the search box of your
Telegram client (Figure 1-2).
2
Chapter 1 Week 1: Ruby
In the preceding list, the name is the one at the bottom. Next, start a
new chat with BotFather by clicking it.
Once the chat is started, you will also be welcomed by our handsome
bot, with a cordial message about APIs, free help, and an invitation to start
the chat (Figure 1-3).
Once the chat has begun (by pressing the Start button that you can see
at the bottom), you are welcomed by BotFather with a bunch of options on
how to create or edit your list of bots (Figure 1-4).
3
Chapter 1 Week 1: Ruby
4
Chapter 1 Week 1: Ruby
Great! I won’t review the full list of options now but will start just by
creating our new bot. This is done here by typing in the /newbot command
and then following a simple conversation, such as the one in Figure 1-5.
Your bot is now ready to use. Can you see in red something like a
secret code? This is the bot token, which is a chain of characters that
will be used to uniquely identify and authenticate your bot against
the Telegram platform. Do not give away this token. Don’t write it in
a book or allow it to hang somewhere on GitHub, especially now that
Microsoft owns it.
5
Chapter 1 Week 1: Ruby
In our case, in the preceding chat, the token that was generated and
given to use is the one following:
624028896:AAFGfIXp3FEPtX1_S2zmHodHRNpu_wD1acA
If your token, like this one, ever becomes compromised, you can use
the /token command with the bot father, to generate a new token, as
shown in the conversation in Figure 1-6.
Alright, the registration of our Telegram bot is all done. So, let’s switch
to a little bit of coding in Ruby.
6
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Chapter 1 Week 1: Ruby
S
etting Up Ruby
Ruby, on most Unix-like platforms, including OS X, is already installed,
or it can be installed using a package manager. For those running lesser
operating systems, like Windows, you can download and install the Ruby
installer (Figure 1-7) from the Ruby download page at www.ruby-lang.
org/en/downloads/. Download the most recent version.
ruby -v
gem -v
7
Chapter 1 Week 1: Ruby
If you have never used Ruby before, you may be wondering what the
gem executable is? It’s simply a Ruby-specific installer for libraries (just like
npm is for Node and pip is for Python), so when you require some open
source library that has been written by someone else, you would use gem to
get it on your machine and the ruby executable to run it.
Apart from Ruby, to have some coding fun outside Notepad, you also
need a text editor, so I propose to use Microsoft’s Visual Studio Code
(https://code.visualstudio.com/), but, of course, any of your favorite
text editors will do.
Alright, let’s get started and code our first bot.
8
Chapter 1 Week 1: Ruby
mkdir chapter-01
cd chapter-01
gem install telegram_bot
9
Chapter 1 Week 1: Ruby
require 'telegram_bot'
10
Chapter 1 Week 1: Ruby
To run the preceding written program on your machine, you pass the
name of the program file, step0.rb, to the ruby executable. Let’s do it.
At the terminal, execute the following command:
ruby step0.rb
Oops! That did not go so well. We forgot to pass the Telegram token to
our program.
This can be done on Linux or OS X with the following:
export BOT_TOKEN='585672177:AAHswpmdA2zP52ZWoJMdteGa0xQ8KeynWvE'
set BOT_TOKEN=585672177:AAHswpmdA2zP52ZWoJMdteGa0xQ8KeynWvE
Let’s run the program again. This time, it looks like the command
is not finishing… This is expected, as the bot is now actually waiting for
messages.
Let’s be the one to start the conversation, so let’s send a greeting
message.
In the Telegram window, search for the bot and start chatting
(Figure 1-11).
11
Random documents with unrelated
content Scribd suggests to you:
of their country. The “Url-Ja,” a Chinese dictionary of that date, says
“they are very precious.”
Solomon’s pearls came from the Persian Gulf, India, and Ceylon,
and the queen of Sheba’s too. Rivers of Britain gave the author of
the “Commentaries” pearls to dedicate to Venus Genetrix, and to
present to that lovely assassin who melted two, costing ten million
sesterces, for a love philter, and seduced two Cæsars. Who can
forget the salad Philip II of Spain, the uxorious inquisitor, set upon
the royal table for his wife, Elizabeth of Valois, the leaves of which
were of emeralds, the vinegar of rubies, the oil of topazes, and the
salt of pearls? What more appetizing dish for a royal bride? The
Orientals make medicine of them to-day, and I myself have seen a
sultan burn pearls to make lime for chewing with the betel-nut.
The New World offered fresh preserves to pearl-hunters; primeval
grounds drew a horde of lusty blades to harry the red men’s
treasure-house. South and Central America fed the pearl hunger that
grew with the more even distribution of wealth through commerce,
and the rise of stout merchants on the Continent and the British
Islands. The Spanish king who gave his name to the Philippines got
from Venezuela a pearl that balanced an eighth of a pound. I saw it
in Madrid. These Paumotus and Australasia were the last to answer
yes to man’s ceaseless demand that the earth and the waters
thereof yield him more than bread for the sweat of his brow. On
many maps these atolls are yet inscribed as the Pearl Islands. About
their glorious lagoons was a mist of obscurity and of wonder for
centuries. Besides dangers to vessels, the cannibalism of savages,
the lack of any food except cocoanuts and fish, and stories of
strange happenings, there were accounts of divers who sank deeper
in the sea than science said was possible, and of priceless pearls
plundered or bought for a drinking-song.
Custom-houses and organized commerce had rung down the
curtain on the extravaganza of the past, but the romance of man
wrestling with the forces of nature in the element from which he
originally came, now so deadly to him, was yet a supreme attraction.
The day of the opening of the rahui came none too soon for me.
Nohea, my host, was to dive, and we had arranged that I was to be
in his canoe. I was assured by Mapuhi, and by Captain Nimau and
Kopcke, that despite the fact that his youth was gone, Nohea was
the best diver in Takaroa, and especially the shrewdest judge of the
worth of a piece of diving ground.
All the village went to the scene of the diving in a fleet of cutters
and canoes, sailing or paddling according to the goal and craft.
Nohea and I had a largish canoe, which, though with a small sail
woven of pandanus straw, could easily be paddled by us. He had
staked out a spot upon the lagoon that had no recognizable bearings
for me, but which he had long ago selected as his arena of action.
He identified it by its distance from certain points, and its association
with the sun’s position at a fixed hour.
We had risen before dawn to attend the Mormon church service
initiating the rahui. The rude coral temple was crowded when the
young elders from Utah began the service. Mapuhi, Nohea, and
leaders of the village sat on the forward benches. The prayer of
elder Overton was for the physical safety of the elected in the
pursuit they were about to engage in.
“Thou knowest, O God,” he supplicated, “that in the midst of life
we are in death.”
“E! E! Parau mau!” echoed the old divers, which is, “Yea, Verily!”
“These, thy children, O God, are about to go under the sea, but
not like the Chosen People in Israel, for whom the waters divided
and let them go dry-shod. But grant, O God, who didst send an
angel to Joseph Smith to show him the path to Thee through the
Book of Mormon, who didst lead thy new Chosen People through the
deserts and over the mountains, among wild beasts and the savages
who knew Thee not, to Thy capital on earth, Salt Lake City, that thy
loving worshipers here assembled shall come safely through this day,
and that Thy sustaining hand shall support them in those dark
places where other wild beasts lie in wait for them!”
“Parau mau!” said all, and the eyes of some of the women were
wet, for they thought of sons and lovers, fathers and brothers,
mothers and sisters, who had gone out upon the lagoon, and who
had died there among the coral rocks, or of whom only pieces had
been brought back. They sang a song of parting, and of
commending their bodies to the Master of the universe, and then
with many greetings and hearty laughter and a hundred jests about
expected good fortune, we parted to put the final touches on the
equipment for la pêche des huitres nacrières. Forgetting the quarter
of an hour of serious prayer and song in the temple, the natives
were now bubbling with eagerness for the hunt. Mapuhi himself was
like a child on the first day of vacation. These Paumotuans had an
almost perfect community spirit, for, while a man like Mapuhi
became rich, actually he made and conserved what the duller
natives would have failed to create from the resources about them,
or to save from the clutches of the acquisitive white, and he was
ready to share with his fellows at any time. He, as all other chiefs,
was the choice of the men of the atoll at a quadrennial election, and
held office and power by their sufferance and his own merits. None
might go hungry or unhoused when others had plenty. Civilization
had not yet inflicted on them its worst concomitants. They were too
near to nature.
After a light breakfast of bread and savory fried fish, to which I
added jam and coffee for myself, Nohea and I pushed off for our
wonder-fishing. In the canoe we had, besides paddles, two titea
mata, the glass-bottomed boxes for seeing under the surface of the
water, a long rope, an iron-hooped net, a smaller net or bag of coir,
twenty inches deep and a foot across, with three-inch meshes, a
bucket, a pair of plain-glass spectacles for under-water use, a jar of
drinking-water, and food for later in the day.
The sun was already high in the unclouded sky when we lifted the
mat sail, and glided through the pale-blue pond, the shores of which
were a melting contrast of alabaster and viridescence. All about us
were our friends in their own craft, and the single motor-boat of the
island, Mapuhi’s, towed a score of cutters and canoes to their
appointed places. A slender breeze sufficed to set us, with a few
tacks, at our exact spot. We furled our sail, stowed it along the
outrigger, and were ready for the plunge. We did not anchor the
canoe because of the profundity of the water and because it is not
the custom to do so. I sat with a paddle in my hand for a few
minutes but laid it down when Nohea picked up the looking-glass.
He put the unlidded box into the water and his head into it and
gazed intently for a few moments, moving the frame about to sweep
the bottom of the lagoon with his wise eyes.
The water was as smooth as a mirror. I saw the bed of the inland
sea as plainly as one does the floor of an aquarium a few feet deep.
No streams poured débris into it, nor did any alluvium cloud its
crystal purity. Coral and gravel alone were the base of its floor and
sides, and the result was a surpassing transparency of the water not
believable by comparison with any other lake.
“How far is that toa aau?” I asked, and pointed to a bank of coral.
Nohea sized up the object, took his head from the titea mata, and
replied, “Sixty feet.”
At that distance I could, unaided, see plainly a piece of coral as
big as my hand. The view was as variegated as the richest landscape
—a wilderness of vegetation, of magnificent marine verdure, sloping
hills and high towers with irregular windows, in which the sunshine
streamed in a rainbow of gorgeous colors; and the shells and bodies
of scores of zoöphytes dwelling upon the structures gleamed and
glistened like jewels in the flood of light. About these were patches
of snow-white sand, blinding in refracted brilliancy, and beside them
green bushes or trees of herbage-covered coral, all beautiful as a
dream-garden of the Nereids and as imaginary. Even when I
withdrew my eyes from this fantastic scene, the lagoon and shore
were hardy less fabulous. The palms waved along the beach as
banners of seduction to a sense of sheer animism, of investiture of
their trunks and leaves with the spirits of the atoll. Not seldom I had
heard them call my name in the darkness, sometimes in invitation to
enchantment and again in warning against temptation. The cutters
or canoes of the village were like lily-pads upon the placid water, far
apart, white or brown, the voices of the people whispers in the calm
air. I wished I were a boy to know to the full the feeling of adventure
among such divine toys which had brought glad tears to my eyes in
my early wanderings.
The canoe had drifted, and Nohea slipped over its side and again
spied with the glass. I, too, looked through mine and saw where he
indicated a ridge or bank of coral upon which were several oyster-
shells. Nohea immediately climbed into the canoe and, resting upon
the side prayed a few moments, bowing his head and nodding as if
in the temple. Then he began to breathe heavily. For several minutes
he made a great noise, drawing in the air and expelling it forcibly, so
that he seemed to be wasting energy. I was almost convinced that
he exaggerated the value of his emotions and explosive sounds, but
his impassive face and remembrance of his race’s freedom from our
exhibition conceit, drove the foolish thought away. His chest, very
capacious normally, was bursting with stored air, a storage beyond
that of our best trained athletes; and without a word he went over
the side and allowed his body to descend through the water. He
made no splash at all but sank as quietly as a stone. I fastened my
head in the titea mata and watched his every movement. He had
about his waist a pareu of calico, blue with large white flowers,—the
design of William Morris,—and a sharp sailor’s sheath-knife at the
belt. Around his neck was a sack of cocoanut-fiber, and on his right
hand a glove of common denim. Almost all his robust brown body
was naked for his return to the sea-slime whence his first ancestor
had once crawled.
Down he went through the pellucid liquid until at about ten feet
the resistance of the water stopped his course and, animated bubble
as he was, would have pushed him to the air again. But Nohea
turned in a flash, and with his feet uppermost struck out vigorously.
He forced himself down with astonishing speed and in twenty
seconds was at his goal. He caught hold of a gigantic goblet of coral
and rested himself an instant as he marked his object, the ledge of
darker rocks on which grew the shells. There were sharp-edged
shapes and branching plant-like forms, which, appearing soft as silk
from above would wound him did he graze them with his bare skin.
He moved carefully about and finally reached the shells. One he
gripped with the gloved hand, for the shell, too, had serrated edges,
and, working it to and fro, he broke it loose from its probable
birthplace and thrust it into his sack. Immediately he attacked the
other, and as quickly detached it. He stooped down and looked
closely all about him. He then sprang up, put his arms over his head,
his palms pressed one on the other, and shot toward the surface. I
could see him coming toward me like a bolt from a catapult. I held a
paddle to move the canoe from his path if he should strike it, and to
meet him the trice he flashed into the ether.
The diver put his right arm over the outrigger boom, and opening
his mouth gulped the air as does the bonito when first hauled from
the ocean. I was as still as death. In a séance once I was cautioned
not to speak during the materializations, as the disturbance might
kill the medium. I recalled that unearthly silence, for the moment of
emergence was the most fatal to the diver. His senses after the
terrible pressure of such a weight upon his body were as abnormal
and acute as a man’s whose nerves have been stripped by flaying.
The change in a few seconds from being laden and hemmed in by
many tons of water to the lightness of the atmosphere was ravaging.
Slowly the air was respired, and gradually his system,—heart,
glands, lungs, and blood,—resumed its ordinary rhythm, and his
organs functioned as before his descent. Several minutes passed
before he raised his head from the outrigger, opened his eyes, which
were suffused with blood, and said in a low tone of the deaf person,
“E tau Atua e!” He was thanking his God for the gift of life and
health. He had been tried with Meshach, Shadrach, and Abednego,
though not by fire.
Nohea lifted himself into the canoe, and took the sack of coir from
his neck. I removed the two pairs of shells with the reverence one
might assume in taking the new-born babe from its first cradle. They
were Holy Grails to me who had witnessed their wringing from the
tie-ribs of earth. They were shaped like a stemless palm-leaf fan,
about eight inches tall and ten wide, rough and black; and still
adhering to their base was a tangle of dark-green silky threads, the
byssus or strong filament which attaches them to their fulcrum, the
ledge. It was the byssus which Nohea had to wrench from the rock.
I laid down the shells and restored the sack to Nohea, who sat
immobile, perhaps thoughtless. Another brief space of time, and he
smiled and clapped his hands.
“That was ten fathoms,” he said. “Paddle toward that clump of
trees” (they were a mile away), “and we will seek deeper water.”
A few score strokes and we were nearer the center of the lagoon.
With my bare eyes I could not make out the quality of the bottom
but only its general configuration. Nohea said the distance was
twenty fathoms. The looking-glass disclosed a long ledge with a flat
shelf for a score of feet, and he said he made out a number of large
shells. It took the acutest concentration on my part to find them,
with his direction, for his eyes were twice as keen as mine from a
lifetime’s usage upon his natural surroundings. We sacrificed our
birthright of vivid senses to artificial habits, lights, and the printed
page. Nohea made ready to go down, but changed slightly his
method and equipment. He dropped the iron-hooped net into the
water by its line and allowed it to sink to the ledge. Then he raised it
a few feet so that it would swing clear of the bottom.
“It will hold my shells and indicate to me exactly where the canoe
is,” he explained. “At this depth, 120 feet, I want to rest immediately
on reaching the surface, and not to have to swim to the canoe. I
have not dived for many months, and I am no longer young.”
He attached the line to the outrigger, and then, after a fervent
prayer to which I echoed a nervous amen, he began his breathing
exercises. Louder than before and more actively he expanded his
lungs until they held a maximum of stored oxygen, and then with a
smile he slid through the water until he reversed his body and
swam. In his left hand now he had a shell, a single side of a bivalve;
and this he moved like an oar or paddle, catching the water with
greater force, and pulling himself down with it and the stroke of the
other arm, as well as a slight motion of the feet. The entire
movement was perfectly suited to his purpose, and he made such
rapid progress that he was beside the hoop-net in less than a
minute. He had a number of pairs of shells stripped from the shelf
and in the swinging net in a few seconds more, and then, drawn by
others he discerned further along the ledge, he swam, and dragged
himself by seizing the coral forms, and reached another bank. I
paddled the canoe gently behind him. I lost sight of him then
completely. Either he was hidden behind a huge stone obelisk or he
had gone beyond my power of sight.
A gigantic black shape swam into view near the oscillating hoop,
and a horror swept over me. It disappeared, but Nohea was still
missing. The time beat in my veins like a pendulum. Every throb
seemed a second, and they began to count themselves in my brain.
How long was it since Nohea had left me? A minute and a half? Two
minutes? That is an age without breathing. Something must have
injured him. Slowly the moments struck against my heart. I could
not look through the titea mata any longer. Another sixty seconds
and despair had chilled me so I shook in the hot sunshine as with
ague. I was cold and weak. Suddenly I felt a pull at the rope, the
canoe moved slightly, and hope grew warm in me. I perceived an
agitation of the water gradually ascending, and in a few instants the
diver sprang out of the lagoon to his waist. He threw his arm over
the outrigger, and bent down in agony. His suffering was written in
the contortion of his face, the blood in his eyes, and a writhing of his
whole body. He gasped madly at his first emergence, and then his
bosom rose and fell in lessening spasms. The cramp which had
convulsed his form relaxed, and, as minute after minute elapsed, his
face lost its rigidity, his pulse slackened to normal, and he said
feebly, “E tau Atua e!” With my assistance he hauled himself into the
canoe and lay half prone.
“You saw no shark?” I asked.
“I saw his shadow, but it was not he that detained me. I saw a
bank which might hold shells and I explored it. We will see what I
have.”
We pulled up the hoop-net, and in it were thirteen pairs of shells.
These were larger than the others, older, and, as he said, from a
more advantageous place for feeding, so that their residents, being
better nourished had made larger and finer houses for themselves.
Some of the thirteen were eighteen inches across. He said that he
had roamed seventy feet on the bottom, and he had been down two
and a half minutes. He had made observation of the ledges all about
and intended going a little deeper. I had but to look at the rope of
the net to gage the distance for it was marked with knots and bits of
colored cotton to give the lengths like the marks on a lead-line on
shipboard. I wanted to demur to his more dangerous venture, but I
did not. This was his avocation and adventure, his war with the
elements, and he must follow it and conquer or fail.
Again he dived, and this time at 148 feet. This was almost the
limit of men in suits with air pumps or oxygen-tanks, and they were
always let down and brought up gradually, to accustom their blood
to the altering pressure. Half an hour or an hour was often
consumed in hauling a diver up from the depth from which Nohea
sprang in a few seconds. His transcendent courage and consummate
skill were matched by his body’s trained resistance to the effect of
such extreme pressure of water and the remaining without breathing
for so long a time. I could appreciate his achievements more than
most people, for I had seen the divers of many races at work in
many waters. Ninety feet was the boundary of all except the
Paumotuans and those who used machines. But here was Nohea
exceeding that by sixty feet in my view, and I knew that greater
depths must be attained. Impelled by an instantaneous urge to
contrast my own capabilities with Nohea’s, I measured off thirty feet
on the line, and, putting it in his hands to hold, I breathed to my
fullest and leaped overboard. At three lengths of my figure, less than
eighteen feet, I experienced alarm and pain. I unloosed the hoop
and it swayed down to the end of the five fathoms of rope, while I
kicked and pulled, and after an interminable period I had barely
touched it again before I became convinced that if I did not breathe
in another second I would open my mouth. Nohea knew my plight,
for he yanked at the rope, and with his effort and my own frantic
exertion I made the air, and humbly hugged the outrigger until I was
myself. Thirty feet! And Nohea had brought up the shells from 148.
He paid dearly. Several times of the score that he probed the
deeper retreats of the oysters, he was prostrated for minutes upon
his egress and in throes of severe pain during the readjustment of
pressure; but he continued to pursue his fascinating and near-fatal
employment until by afternoon a heap of heavy, darkish bivalves lay
in the canoe. My curiosity had been heated since I had lifted the first
shell, and it was with increasing impatience that I waited for the
milder but not less interesting phase of his labor, the scrutiny of the
interior of the shells for pearls.
There are two moments in a divers life;
One, when, a beggar, he prepares to plunge;
Then, when, a prince, he rises with his pearl.
“That means ten years in Noumea for him,” said the commissaire,
savagely. But after dinner, which I got, when he had meditated upon
Flag’s willingness as a cook and his ability to collect taxes, he
lessened the sentence to a year at hard labor. I was not surprised to
meet Flag at noon the next day with his accustomed white jacket
with its red stripe upon the arm. Man cannot live without cooks, and
perhaps I had aided leniency by burning a bird.
Flag explained to me, though sheepishly, that, overcome by the
litre of absinthe as he was, he would not have injured a hair of
Bauda’s head.
“Bauda is tapu. I would meet an evil fate did I touch him,” said
Flag, when sober and sorry.
I stumbled on tapus daily. Vai Etienne, my neighbor, gave me a
feast one day, and half a dozen of us, all men, sat at table. Vai
Etienne, having lived several years in Tahiti had Frenchified ways.
His mother, the magnificent Titihuti, who was splendidly tattooed
from toe to waist, and who was my adopted mother, waited upon us.
Offering her a glass of wine, and begging her to sit with us, I
discovered that the glass her son drank from and the chair a man
sat in were tapu to her. She took her wine from a shell, but would
not sit at table with us. Of course, she never sat in chairs, anyhow,
nor did Vai Etienne, but he had provided these for the whites.
The subject of the tapus of the South Seas was endless. The
custom, tabu or kapu in Hawaiian, and tambu in Fijian, was ill
expressed in our “taboo,” which means the pressure of public
sentiment, or family or group feeling. Tapus here were the
conventions of primitive people made awe-inspiring for enforcement
because of the very willfulness of these primitives. The custom here
and throughout society dated from the beginning of legend. Laws
began with the rules laid down by the old man of the family and
made dread in the tribe or sept by the hocus-pocus of the medicine
man. Tapus may have been the foundation of all penal laws and
etiquette. The Jews had a hundred niceties of religious, sanitary, and
social tapus. Warriors were tapu in Homer’s day, and land and fish
were tapu to Grecian warriors, according to Plato. Confucius in the
“Li Ki,” ordained men and women not to sit on the same mat, nor
have the same clothes-rack, towel, or comb, nor to let their hands
touch in giving and receiving, nor to do a score of other trivial
things. The old Irish had many tapus and totems, and many legends
of harm wrought by their breaking, a famous one being “The
Destruction of Da Derga’s Hostel.”
In the Marquesas tapus were the most important part of life, as
ceremony was at the court of the kings of France. They governed
almost every action of the people, as the rules of a prison do
convicts, or the precepts of a monastery monks. Death followed the
disobedience of many, and others preserved one from the hands of
enemies. There being no organized government in Polynesia, tapus
took the place of laws and edicts. They were, in fact, spiritual laws,
superstition being the force instead of a penal code. They imposed
honesty, for if a man had any dear possession, he had the priest
tapu it and felt secure. Tapus protected betrothed girls and married
women from rakes.
A young woman who worked at the convent in Atuona, near me,
was made tapu against all work. She was never allowed to touch
food until it had been prepared for her. If she broke the tapu the
food was thrown away. From infancy, when a taua had laid the
prohibition upon her, she lived in disagreeable idleness, afraid to
break the law of the priest. Only in recent years did the nuns laugh
away her fears, and set her to helping in their kitchen. She told me
that she could not explain the reason for her having been tapu from
effort, as the taua had died who chained her, without informing her.
If a child crawled under a house in the building, the house was
burned. If I were building a boat, and, for dislike of me, some one
named aloud the boat after my father, I destroyed the boat. Blue
was tapu to women in Nuku-Hiva, and red, too. They could not eat
bonito, squid, popii, and koehi. They might not eat bananas,
cocoanuts, fresh breadfruit, pigs of brown color, goats, fowls and
other edibles.
Females were forbidden to climb upon the sacred paepaes, to
enter the men’s club-houses (this tapu was enforced in America until
the last few years), to eat with men, to smoke inside the house, to
carry mats on their heads, and, saddest of all, to weep. Children
might not carry one another pickaback. The kuavena fish was tapu
to fishermen, as also peata, a kind of shark.
To throw human hair upon the ground was strictly prohibited. It
might be trodden on, and bring mischief upon the former wearer. So
the chiefs would never walk under anything that might be trodden
on, and aboard ships never went below deck, for that reason.
Perhaps our superstition as to walking under ladders is derived from
such a tapu. To stretch one’s hand or an object over the head of any
one was tapu. There were a hundred things tapu to one sex. Men
had the advantage in these rules, for they were made by men.
The earthly punishments for breaking tapus ran from a small fine
to death, and from spoliation to ostracism and banishment. Though
there were many arbitrary tapus, the whims and fantasies of chiefs,
or the wiles of priests, the majority of them had their beginning in
some real or fancied necessity or desirability. Doubtless they were
distorted, but, like circumcision and the Mosaic barring of pork to the
Jews, here was health or safety of soul or body concerned. One
might cite the Ten Commandments as very old tapus.
The utter disregard for the tapus of the Marquesans shown by the
whites eventually had caused them to fall into general disrepute.
They degenerated as manners decayed under the influx of
barbarians into Rome, as Greek art fell before the corruption of the
people. The Catholic, who bowed his head and struck his breast at
the exaltation of the host, could understand the veneration the
Marquesans had for their chief tapus, and their horror at the conduct
of the rude sailors and soldiers who contemned them. But when
they saw that no gods revenged themselves upon the whites, that
no devil devoured their vitals when they ate tapu breadfruit or fish
or kicked the high priest from the temple, the gentle savages made
up their minds that the magic had lost its potency. So, gradually,
though to some people tapus were yet very sacred, the fabric built
up by thousands of years of an increasingly elaborate system of laws
and rites, melted away under the breath of scorn. The god of the
white man was evidently greater than theirs. Titihuti, a constant
attendent of the Catholic church, yet treasured a score of tapus, and
associated with them these others, the dipping of holy water from
the bénitier, the crossing herself, the kneeling and standing at mass,
the telling of her beads, and the kissing of the cross.
The abandonment of tapus under the ridicule and profanation of
the whites relaxed the whole intricate but sustaining Marquesan
economy. Combined with the ending of the power of chiefs of
hereditary caste, the doing away with tapus as laws set the natives
hopelessly adrift on an uncharted sea. Right and wrong were no
longer right or wrong.
This fetish system was very aptly called a plague of sacredness.
“Whoever was sacred infested everything he touched with
consecration to the gods, and whatever had thus the microbe of
divinity communicated to it could communicate it to other things and
persons, and render them incapable of common use or approach.
Not till the priest had removed the divine element by ceremonies
and incantations could the thing or person become common or fit for
human use or approach again.”
The Marquesan priests strove with might and main to extend the
tapus, for they meant power and gain. Wise and strong chiefs
generally had private conferences with the priests and looked to it
that tapus did not injure them.
Allied with tapuism was what is called in Hawaii kahunaism, that is
the witchcraft of the priests, the old wizards, who combined with the
imposing and lifting of the bans, the curing or killing of people by
enchantment. Sorcery or spells were at the basis of most primitive
medicine. At its best it was hypnotism, mesmerism, or mind power.
After coming through thousands of years of groping in physic and
surgery, we are adopting to a considerable degree the methods of
the ancient priests, the theurgy, laying on of hands, or invoking the
force of mind over matter, or stated Christly methods of curing the
sick. In Africa witchcraft or voodooism attains more powers than
ever here, but even in Polynesia the test of a priest’s powers was his
ability to kill by willing it. In the New Zealand witchcraft schools no
man was graduated until he could make some one die who was
pointed out as his subject. A belief in this murderous magic is shared
by many whites who have lived long in Polynesia or New Zealand. It
was still practised here, and held many in deadly fear. The victims
died under it as if their strength ran out like water.
The most resented exclusion against women in the Marquesas,
and one of the last to be broken, was from canoes. Lying Bill, as the
first seaman who sailed their ships here, had met shoals of women
swimming out miles to the vessel as it made for port. In his youth
they did not dare enter a canoe in Hiva-Oa. They tied their pareus
on their heads and swam out, clambered aboard the ships miles
from land with the pareus still dry.
“They’d jump up on the bulwarks,” said Lying Bill, “an’ make their
twilight before touchin’ the deck. The men would come out in
canoes an’ find the women had all the bloomin’ plunder.”
This tapu, most important to the men, was maintained until a
Pankhurst sprang from the ranks of complaining but inactive women.
There being many more men, women had always had a singular sex
liberty, but, as I have said, the artful men had invoked rigid tapus to
keep them from all water-craft. The females might have three or
four husbands, might outshine an Aspasia in spell of pulchritude and
collected tribute, and the portioned men must submit for passion’s
sake, but when economics had concern, the pagan priests brought
orders directly from deity.
The dread gods of the High Place, the demons of the Paepae
Tapu, had centuries before sealed canoes against women. In canoes
women might wander; they might visit other bays and valleys, even
other islands, and learn of the men of other tribes. They might go
about and fall victims to the enemies of the race. They might
assume to enter the Fae Enata, the House of Council, which was on
a detached islet.
And they certainly would catch other fish than those they now
snared from rocks or hooked, as both swam in the sea. Fish are
much the diet of the Marquesans, and were propitiations to maid
and wife—the current coin of the food market. To withhold fish was
to cause hunger. The men alone assumed the hazard of the tossing
canoe, the storms, the hot eye of the vertical sun, and the devils of
the deep who grappled with the fisher; and theirs was the reward,
and theirs the weapons of control.
But there were always women who grumbled, women who even
laughed at such sacred things, and women who persisted. Finally the
very altar of the Forbidden Height was shaken by their madness.
How and what came of it were told me by an old priest or sorcerer,
as we sat in the shade of the great banyan on the beach and waited
for canoes to come from the fishing.
The sorcerer and I passed the ceremonial pipe, and his words
were slow, as becoming age and a severe outlook on life.
“There were willful women who would destroy the tapu against
entering canoes?” I asked, to urge his speech.
“E, it was so!” he said.
“Me imui? What happened?” I queried further.
“A long time this went on. My grandfather told me of a woman
who talked against that tapu when he was a boy.”
“And she—?”
“She enraged the gods. She corrupted even men. A council was
held of the wise old men, and the words went forth from it. She was
made to keep within her house, and a tapu against her made it
forbidden to listen to her wildness. In each period another woman
arose to do the same, and more were corrupted. Some women stole
canoes and were drowned. The sharks even hated them for their
wickedness. We pointed out what fate had befallen them, but other
women returned boasting. We slew some of these. But still it went
on. You know, foreigner, how the pokoko enters a valley. One coughs
and then another, and from the sea to the peak of Temetiu, many
are made sick by the evil. It was so with us, and that revolt against
religion.”
He sighed and rubbed his stomach.
“Is it not time they came?” he asked.
“Epo, by and by,” I answered. “Why did you men not yield? After
all, what did it really matter?”
“O te Etua e! The gods of the High Place forbade, for the women’s
own sake!” he said indignantly, and muttered further.
To break down every sacred relation of centuries! To shatter the
tradition of ages! To unsex their beloved mothers, wives, and sisters