Building Telegram Bots: Develop Bots in 12 Programming Languages using the Telegram Bot API 1st Edition Nicolas Modrzyk pdf download
Building Telegram Bots: Develop Bots in 12 Programming Languages using the Telegram Bot API 1st Edition Nicolas Modrzyk pdf download
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/developing-bots-with-microsoft-
bots-framework-create-intelligent-bots-using-ms-bot-framework-
and-azure-cognitive-services-1st-edition-srikanth-machiraju/
https://textbookfull.com/product/introducing-azure-bot-service-
building-bots-for-business-waghmare/
https://textbookfull.com/product/practical-bot-development-
designing-and-building-bots-with-node-js-and-microsoft-bot-
framework-szymon-rozga/
https://textbookfull.com/product/building-bots-with-microsoft-
bot-framework-creating-intelligent-conversational-interfaces-1st-
edition-kishore-gaddam/
Designing Bots Creating Conversational Experiences 1st
Edition Amir Shevat
https://textbookfull.com/product/designing-bots-creating-
conversational-experiences-1st-edition-amir-shevat/
https://textbookfull.com/product/practical-artificial-
intelligence-machine-learning-bots-and-agent-solutions-
using-c-1st-edition-arnaldo-perez-castano/
https://textbookfull.com/product/java-image-processing-recipes-
with-opencv-and-jvm-1st-edition-nicolas-modrzyk/
https://textbookfull.com/product/building-intelligent-cloud-
applications-develop-scalable-models-using-serverless-
architectures-with-azure-1st-edition-vicente-herrera-garcia/
https://textbookfull.com/product/introduction-to-deep-learning-
business-applications-for-developers-from-conversational-bots-in-
customer-service-to-medical-image-processing-armando-vieira/
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
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
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
Chapter 1 Week 1: Ruby
Hmmm, that was not very readable. With Ruby, you can display a more
legible version of any object, by using the to_yaml function. Let’s update
the code and see what happens.
We call require 'yaml', to import it into the Ruby namespace, and
now we can call the to_yaml on the message the bot has received.
require 'telegram_bot'
require 'yaml'
bot = TelegramBot.new(token: ENV['BOT_TOKEN'])
12
Chapter 1 Week 1: Ruby
bot.get_updates() do |message|
# puts message.to_s
puts message.to_yaml
end
You would have to type Ctrl-C to terminate the running version of the
bot first and then start the new bot, by executing the ruby command again.
Figure 1-13 shows the outcome.
In the console, or in the terminal where the bot was started, you now
can see a more detailed version of the received message.
13
Chapter 1 Week 1: Ruby
For standard messages, there is not much beyond what you would
expect from a chat message object. You will probably use the date, text,
and from fields most of the time.
14
Chapter 1 Week 1: Ruby
F irst Reply
Again, Ruby’s concision makes it quite easy to create strings from objects.
With the following, you can use blocks of executable code directly within a
string: #{}.
This makes it very powerful for templated messages, and in our case,
for bot programming. Within the get_updates() call block, let’s now write
and send a reply.
message.reply do |reply|
reply.text = "Hello, #{message.from.first_name}!"
reply.send_with(bot)
end
After restarting the bot (Ctrl-C, ruby step0.rb), we can start a more
talkative version of this Ruby bot (Figure 1-14).
15
Other documents randomly have
different content
The night of the attack was rainy, but not completely dark, since
the moon was above the horizon during nearly the whole of the
expedition.
The force left Brailoff at one o'clock on the morning of the 26th,
and advanced in two columns up the river, finding great difficulty in
stemming the strong current.
A boat from the Duba Saife, rowing guard some 500 yards in
advance of the squadron, observed the approach of the Russian
boats, but allowed them to pass on their voyage of destruction
without attempting to stop them, or alarm the vessels. On reaching
within 150 yards of the Duba Saife, Dubasoff in the Czarowitch was
challenged, and failing to give the correct answer was immediately
fired at; but, nothing daunted by the hail of shot and bullets, he
dashed on, and succeeded in exploding one of his spar torpedoes on
the port side of the Duba Saife, just under her quarter, a column of
water and débris being thrown up to a height of 120 feet, which
partly filled his boat, but notwithstanding managed to get safely
away. The monitor not sinking as soon as expected, Chestakoff in
the Xénie dashed in, and completed the work of destruction, the
unfortunate ship sinking in a very few minutes after this last
explosion. The Djiquite was struck in the stern, and had to be run
ashore for repairs, but eventually all four boats reached Brailoff in
safety. The Russians allowed to neither killed nor wounded, which,
when the time they were exposed to the fire of the three Turkish
ships (about twenty minutes), the number of men (forty-six)
engaged, and their very close quarters, seems miraculous.
The Duba Saife, thus lost to the Turks, carried two 12 cm. Krupp
guns, and a crew of some sixty officers and men, few of whom were
saved. Lieutenants Dubasoff and Chestakoff were decorated with the
4th Class of the Cross of Saint George, and three seamen received
the insignia of the Order of Military Merit.
This attack was conducted in a most gallant manner, and far more
systematically than the Batoum affair. If instead of holding one of
the boats in reserve, which was part of Dubasoff's plan, and the
remaining three attacking one vessel, the force had divided itself
into two parties, and had made a simultaneous attack on both the
monitors, the probability is that the Fettu Islam would have shared
the fate of her consort.
The officer of the Turkish guard boat was tried by court-martial,
but what his ultimate fate was is not generally known. He certainly
deserved nothing less than death.
3rd Affair.
The Soulina Attack.—The third attempt took place on the 9th-10th
of June, 1877, on a Turkish squadron lying at anchor off Soulina.[T]
This squadron consisted of the three ironclads Feteh Bulend,
Moocardemikhair, and Idglalieh, and a tug, Kartal.
The Russian attacking force consisted of six torpedo boats, viz.
the No. 1, Lieutenant Poutschin; the No. 2, Lieutenant
Rojdestvenski; the Tchesme, Lieutenant Zatzarennyi; the Sinope, the
Navarino, and the Soukoum Kalé. The No. 2 was a specially
constructed torpedo boat, 68 feet long, and very fast. All were
armed with spar torpedoes, with the exception of the Tchesme,
which carried a towing torpedo. The boats were convoyed from
Odessa by the Constantine, some being carried, and some being
towed; another steamer, the Vladimir, supported her. The Turkish
squadron were anchored in quarter line, about one mile from the
harbour; the Kartal, under weigh, being used as an advance guard,
and a few boats rowing guard close to the ships being the only
means of protection adopted by the Turks. Passive obstructions,
such as booms, nets, crinolines, &c., were not thought of, much less
used.
On arriving about five miles from Soulina, the boats were formed
into two groups, the first consisting of the No. 1, the No. 2, and the
Tchesme, and despatched on their way. The working of their engines
was scarcely heard, and all lights were carefully hidden by
tarpaulins.
The first casualty that happened was the disabling of the
Tchesme, by the electric wire of her towing torpedo fouling the
screw, this obliging her to return to the Constantine. Aided by good
fortune, and by the darkness of the night, the No. 1 and the No. 2
succeeded in getting close to (30 yards) one of the Turkish vessels,
the Idglalieh, before being discovered, when they were at once
hailed, and, not answering, a tremendous fire of big guns and rifles
was directed on them from the Idglalieh, which was promptly
followed by that of the whole squadron, though from the other ships
nothing of the boats could be seen.
According to the Russians, the No. 2 succeeded in exploding her
torpedo close to, if not in contact with, a Turkish vessel, but from
eyewitnesses on board the squadron only one explosion was heard,
viz. that of Lieutenant Poutschin's torpedo. Any way, no damage
whatever was experienced by the Ottoman squadron. The No. 1
came down on the Idglalieh's starboard bow, fouled her cable, and
swung alongside, exploding one of her torpedoes in so doing, but
with no other result than a wetting to those of the ironclad's crew,
who were on the forecastle. Alongside Poutschin remained for some
minutes, but at last managed to get clear, and then was either sunk
by the Idglalieh's fire, or, as he avers, on finding his screw foul, he
sunk his boat, rather than let her fall into the hands of the Turks.
Poutschin and four of his crew were picked up, after being some
hours in the water, by the squadron's boats.
The No. 2 seems to have suffered severely, her funnel being bent,
the axle of the steering wheel damaged, sixteen rivets were started,
and the iron keel plate had dropped some 18 inches, and finally the
lower part of her rudder broken, and one of the blades of her screw
bent aft; part of this damage was no doubt the effect of the
explosion of her torpedo, which was probably not in position, but
unless she ran over some loose stones of the Soulina breakwater,
the damage to her keel and rudder cannot be accounted for.
The second group of boats had followed up the first, but on
hearing the noise of the explosions and roar of the guns and rifles
they returned to the Constantine.
That ship, on observing the firing, endeavoured to close the land,
but she grounded, and remained until daylight in a difficult position,
but at last got afloat, and returned to Odessa with five out of her six
torpedo boats.
Lieutenant Rojdestvenski, the Commander of the No. 2, received
the 4th Class of the Cross of Saint George, and three seamen the
insignia of the Order of Military Merit.
On the part of the No. 1 and No. 2, this was a most gallant affair,
though unsuccessful, but as regards the remainder of the boats the
less said the better.
Had the Turkish squadron slipped the instant the alarm was given,
and steamed full speed in the direction of Odessa, the Constantine
and her convoy might have been cut off. Both the Moorcademikhair
and Feteh Bulend were 13 knot ships, and therefore considerably
faster than the enemy. But, as usual, the Turks were far too dilatory
to take advantage of the occasion.
4th Affair.
The Rustchuk Attack.—The fourth torpedo attack was made on
the afternoon of the 20th of June, 1877, on a Turkish monitor off
Rustchuk.
The only Russian torpedo boat sent to the attack on this occasion
was a Thornycroft named the Choutka, commanded by Lieutenant
Skrydloff, and accompanied by a celebrated Russian artist,
Verechtckaguine by name. The instant the torpedo boat was
observed, so well directed and steady a fire was kept up by the
monitor that both the lieutenant and the artist were badly wounded,
and the electric wires of the torpedo severed, thus obliging the
Choutka to beat a retreat. According to the Russian account, the
monitor was struck by the boat's torpedo spar, but the above seems
the more likely version. This was certainly a most audacious attack,
and had the Turks only succeeded in hitting the Choutka with her big
gun, it would have ended fatally for the Russians; as it was, the boat
was struck by several bullets, but none of the crew were wounded.
5th Affair.
The Aluta Attack.—The fifth attack was made on the 30th of June,
1877, on a Turkish monitor off the mouth of the Aluta, in the river
Danube. This attempt, like the last, took place in broad daylight.
Four Russian boats were sent forward, but in spite of the captain of
the Turkish vessel doing all he could to run the boats down, none of
them succeeded in getting sufficiently near the vessel to enable a
torpedo to be placed in contact. The captain of the monitor took the
precaution to rig his lower booms out, and so managed to keep the
enemy's boats at a respectful distance, they imagining that mines
were fixed to the ends of the booms. After two hours of this dodging
about, the Russians, finding the case hopeless, abandoned the
attack.
The Russian account states—1st, that the captain of the monitor
was an Englishman; 2nd, that the vessel was protected by nets and
torpedoes lashed to the extremities of her booms—both of which
statements are radically wrong.
The torpedo boats forming the attack were the Choutka,
Midshipman Niloff, and the Mina, Sub-Lieutenant Arens, both armed
with the spar torpedo.
Unless indeed the Russians acted up to the old proverb which
says "Discretion is the best part of valour," it is difficult to
understand how four small easily handled boats could have been for
one hour endeavouring to strike a ship (which ship was at the same
time being manœuvred with a view of running them down) without
either effecting their object or being sunk or damaged in the
attempt.
The Russians, though unsuccessful, behaved gallantly.
Midshipman Niloff was severely wounded, but no mention is made
as to the number of the crew that were killed and wounded, or of
the damage received by the boats. Niloff received the 4th Class of
the Cross of St. George, and Arens the Order of Military Merit.
The Turkish captain, Ali Bey, behaved most pluckily and skilfully.
The only wonder is that both the boats were not sunk by the
monitor's fire.
6th Affair.
The Soukoum Kaleh Attack.—The sixth attempt was made on the
23rd-24th of August, 1877, on a Turkish ironclad, the Assari Shefket,
at the time lying at anchor off Soukoum Kaleh.[U] Four torpedo boats
composed the attacking force, viz. the Sinope, Lieutenant Pisarefski;
the Torpedoist, Midshipman Nelson Hirst; the Navarino, Lieutenant
Vichnevetski; and the Tchesme, Lieutenant Zatzarennyi, the latter
officer being in command. These boats had been brought to the
entrance of the harbour by the Constantine, and were despatched
on their mission of destruction about half past ten.
An eclipse of the moon occurred on this night, and, taking
advantage of this fact, the four Russian torpedo boats dashed into
the harbour at full speed and made for the Turkish vessel.
Fortunately for the safety of his ship and lives of his crew, the
captain of the Turkish ironclad had several boats rowing guard round
his ship, and otherwise everything on board in readiness for
immediate action. On the attacking flotilla nearing the guard boats,
blue lights were burnt, rifles fired, &c., and the alarm given to those
on the look-out in the Assari Shefket. The moment the enemy were
within range, such a well-directed and heavy fire was poured on
them that the attack was completely foiled. One of the Russian
torpedoes was exploded, but failed to do more than throw a quantity
of water up. The next morning a pole with torpedo fixed on it was
found by the Turks, and on the strength of this and the numerous
fragments of wood similarly found, one if not more of the enemy's
boats it was supposed must have been sunk, or much knocked
about.
This was a much better planned and executed attack, but was
unsuccessful owing to the extreme vigilance of the Turks.
This attempt will always be remembered by the Turks, on account
of the general order that appeared in the papers on the part of the
Russians, in which "the brilliant exploit and successful destruction of
the Turkish ironclad Assari Shefket" was set forth at great length;
she at the time that this appeared being quietly at anchor off the
dockyard at Stamboul, not having received any damage whatever.
7th Affair.
The Second Batoum Attack.—The seventh attempt was made on
the night of the 27th-28th of December, 1877, on several Turkish
men-of-war anchored in the harbour of Batoum (the scene of the
first Russian torpedo attempt and failure). Four boats composed the
attacking force, viz. the Tchesme, Lieutenant Zatzarennyi, in
command, armed with a Whitehead fish torpedo, containing 32
kilog. of gun-cotton, fitted to fire from a tube under the boat's keel;
the Sinope, Lieutenant Stchelinski, armed with a similarly charged
fish torpedo, fitted to fire from a raft, which was towed by the boat,
and two other boats, armed with spar and towing torpedoes.
The means employed at Batoum for the safeguard of the
Ottoman fleet there against such an attack was that of guard boats
and a barrier formed of logs of wood, with planks secured to them,
so arranged by means of weights that the planks remained
perpendicular to the surface of the water when in position.
Owing to the extreme darkness of the night, the Russians
managed to evade the guard boats, and when, as they imagined,
some 60 to 65 yards from a Turkish ironclad, the Tchesme and
Sinope's Whitehead fish torpedoes were started on their deadly
mission; but, owing most probably to the want of practice of
manipulating these somewhat delicate instruments, also to the
darkness, and the slight swell there was on at the time, both missed
their mark, and were landed high and dry on the beach astern of the
ship.
One of these weapons was perfect, the other minus her fore
compartment, this having been knocked off by the torpedo colliding
with some hard object. No explosion was heard or seen by the
Turks.
This was the second time that the fish torpedo had been
employed on actual service, and, as in the previous instance, failed.
The guard boats and barrier of the Turks seem to have been of
little avail.
8th Affair.
The Final Attack.—The eighth and last attempt was made on the
night of the 25th-26th of January, 1878.
This was originally intended to be an attack on the Turkish fleet at
Batoum, but on entering that harbour the two Russian torpedo
boats, the Tchesme, Lieutenant Zatzarennyi, and the Sinope,
Lieutenant Stchelinski, were met by a Turkish revenue steamer,
against which the boats discharged their Whitehead torpedoes,
resulting in her complete destruction, at the same time arousing the
squadron, and causing the boats to beat a retreat.
Though the vessel destroyed was not a frigate, yet the expedition
was successful in so far as proving that it is possible to project
Whitehead fish torpedoes from boats at a distance of 70 to 90 yards
from an enemy's ship, on a dark night, and strike her with them.
This concludes the whole of the offensive torpedo operations that
were carried out during the war, of which two out of eight attempts
were successful, which is without doubt a fair percentage.
There seems every probability that the present struggle between
Chili and Peru, in the Pacific, will afford torpedoists further
experience of the various offensive torpedoes, when subjected to
the test of active service.
FOOTNOTES:
[Q] See page 185.
[R] A Turkish port, situated on the east coast of the Black Sea,
capable of holding several large ships when anchored head and
stern, but otherwise only a few.
[S] A town situated on the south bank of the Danube, about
eight miles from Brailoff.
[T] One of the principal mouths of the Danube.
[U] A place taken from the Russians in the early part of the
war, situated on the east coast of the Black Sea.
CHAPTER VIII.
ON EXPLOSIVES.
Explosive Effect.
2nd Order. 1st Order.
Gunpowder 1·00 4·34
Gun-cotton 3·00 6·46
Nitro-glycerine 4·80 10·13
1.—Nitro-glycerine.
2.—Dynamite (No. 1).
3.—Gun-cotton.
4.—Fulminate of mercury.
A.—Explosive Mixtures.
Gunpowder.—This explosive mixture is composed of seventy-five
parts of nitre (saltpetre), fifteen parts of charcoal, and ten parts of
sulphur.
On being ignited, the oxygen which is feebly held by the nitrogen
combines with the carbon, forming carbonic oxide gas, whilst the
sulphur unites with the potassium of the nitre, the whole
combination being accompanied by a great evolution of heat and
expansion of gas, and the nitrogen is set free.
Properties, &c.—A spark, friction between hard bodies, or a
temperature of 572° F., are any of them sufficient to cause an
explosion of gunpowder.
Slight moisture, due to damp air, &c., produces caking and
deterioration.
Wetting causes permanent destruction.
Frost does not injure it.
It can be fired by ordinary methods.
It can be transported and handled with safety and great ease.
It is not a suitable explosive agent for torpedoes, on account of
its liability to be injured by damp, as well as its not being sufficiently
violent, though for the sake of convenience, &c., it is often employed
for such work.
The effect produced by the explosion of a charge of gunpowder,
ignited by the ordinary method, is that of an uplifting rather than a
shattering effect.
This evil may be greatly remedied, when gunpowder is used as
the charge of a torpedo, by firing it with a detonator, by which
means its fullest explosive effect is developed.
Picric Powder.—The picrates are salts of picric acid.
Picric acid is formed by the action of nitric acid on carbolic acid.
The picrate employed by Professor Abel is prepared from picric
acid and ammonium. This preparation, or salt mixed with nitre
(saltpetre), forms Abel's picric powder.
Properties, &c.—It is prepared for use in a similar manner to
gunpowder, and it can be handled in the same way.
It is less violent than dynamite or gun-cotton, though much more
so than gunpowder.
It is difficult to explode it by blows or friction.
If flame be applied to it, the part touched burns, but the
combustion does not become general.
This explosive agent will probably be used for spar torpedoes,
when gun-cotton or dynamite are not employed.
B.—Explosive Compounds.
Nitro-glycerine.—Nitro-glycerine is formed by the action of nitric
acid upon glycerine at a low temperature.
The manufacture of this compound consists, first, in the slow
mixture of the glycerine with the acid, at a low temperature;
secondly, in washing the nitro-glycerine from the excess of acid with
water.
The nitric acid before use is mixed with a certain proportion of
strong sulphuric acid, so that the water formed during the reaction
may be taken up, and thus any dilution of the nitric acid is
prevented.
Nitro-glycerine is composed of carbon, hydrogen, nitrogen, and
oxygen, as indicated by the equation C3H5N3O9.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com