Skip to content

Commit

Permalink
From refs/heads/dev 9b4f5b8
Browse files Browse the repository at this point in the history
  • Loading branch information
pedohorse committed Apr 16, 2024
1 parent 49f9f95 commit 6ec51cd
Show file tree
Hide file tree
Showing 27 changed files with 790 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
GitHub Pages of [pedohorse/lifeblood](https://github.com/pedohorse/lifeblood.git)
===
Sphinx html documentation of [d01e0d38](https://github.com/pedohorse/lifeblood/tree/d01e0d38c4ceeba335603dab0c72533bb675f8e4)
Sphinx html documentation of [9b4f5b80](https://github.com/pedohorse/lifeblood/tree/9b4f5b80a3ba8eade190e3e14bf81a891ba7a410)
1 change: 1 addition & 0 deletions _sources/nodes.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ Nodes
nodes/stock/houdini/karma
nodes/stock/houdini/mantra
nodes/stock/matrixnotifier
nodes/stock/telegram_notifier
94 changes: 94 additions & 0 deletions _sources/nodes/stock/telegram_notifier.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
.. _nodes/stock/telegram_notifier:

=================
Telegram Notifier
=================

Telegram notifier node allows you to send text and files to a given chat through a given bot.

Bot must be created beforehand and added to all chats where it needs
to send messages to.

it is recommended to set up bot_id and chat_id once in then config,
not to expose them in node parameters.

To do that - keep the default expressions in node's parameters, and
set values of ``bot_id`` and room in your ``<home>/lifeblood/nodes/config.toml``

``chat_id`` is not that secret, but it may also be kept in config for the ease of future changes

::

telegram_notifier.bot_id = '<secret_bot_id here>'
telegram_notifier.chat_id = '<chat id here>'


Parameters
==========

:Bot Secret ID:
Bot's secret, the one telegram's `@BotFather <https://t.me/BotFather>`_ gives you.

Read the `official tutorial <https://core.telegram.org/bots/tutorial#obtain-your-bot-token>`_ on
how to create your personal notification bot. (Don't be afraid to give your bot complicated and even unreadable name,
it's just for your team to use after all.)

.. note::
Remember, keep your bot_id is a secret, it allows anyone to control the bot.
:Chat ID:
Chat ID where to send messages.

You can create a new group for you and the bot (and your team members maybe), add your bot there too.

To read messages in groups, the bot needs admin rights, but to write messages it does not. But to write messages in **channels** bot
needs admin privileges in that telegram channel.

To find out the proper ``chat id``:

* Add bot to the group or channel

* If it is channel - give bot admin rights
* If it is a group - write some random command to the bot, like ``/test @my_bot_name_here``
(where ``my_bot_name_here`` should be your actual bot's name)

* Now in your browser open a **new private tab** and go to ``https://api.telegram.org/<bot_id>/getUpdates``, where ``<bot_id>``
is that secret thing you got when creating the bot.
It will look something like this: ``4839574812:AAFD39kkdpWt3ywyRZergyOLMaJhac60qc``

.. note::
it's recommented to use a **private** tab to prevent that url with bot_id in it from being saved into browser history
* There you will see a json dump of a reply, look for something that looks like ``"chat": {"id": -123123123123 ....``
* That number after ``"id"`` is the chat id (yes, it can be a negative number, so do not forget to preserve the minus sign)
* If you see more than one chat id in that json dump - means that you have sent more than one message to your bot, so it's up to you to figure out
what chat id is what. (it should not be hard to do if you look through that whole json data)
:Fail on error:
If message is not sent due to network, authentication or really any other error - set the task into error state.
If this is disabled - task will be considered done regardless of the
success or failure of the message sending.
:Formatting:
How to parse the message.

Read about supported modes in `telegram API docs <https://core.telegram.org/bots/api#formatting-options>`_

.. warning::
If message formatting syntax is wrong (not closed html tag, something not escaped, backticks opened and not closed)
telegram server will return ERROR, it's not like in telegram client that just ignores those errors.

So it is your responsibility to ensure correct syntax if formatting is set to anything but ``Plain``
:Message:
Message to send. Message's formatting must be correct.
:Attach a file:
Optionally, a file may be attached to the message. it can be image, video
or any other file.
:Use worker:
By default notification is sent by scheduler's child process,
but you may want to use workers instead, for example if there is a LOT of
simultaneous uploads of many files, that may clog scheduler's processing pool.

With this checkbox set, notification will be scheduled to be sent from workers.
However it's up to you to ensure you don't hit any rate limits with telegram servers.

.. warning::
**BEWARE:** when executing on workers - ``bot_id`` **WILL BE SAVED TO SCHEDULER'S DATABASE**
as part of Invocation Job description. So anyone with direct access to the database will be
able to find your ``bot_id`` in it
3 changes: 3 additions & 0 deletions components/worker/worker_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@
<dt class="sig sig-object py" id="lifeblood.worker.Worker.deliver_invocation_message">
<em class="property"><span class="pre">async</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">deliver_invocation_message</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">destination_invocation_id</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">destination_addressee</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">source_invocation_id</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">message_body</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bytes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">addressee_timeout</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">90.0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#lifeblood.worker.Worker.deliver_invocation_message" title="Permalink to this definition">#</a></dt>
<dd><p>deliver message to task</p>
<p>the idea is to deliver ONLY when message is waited for.
so queues are added/removed by receiver, not by this deliver method
current impl is NOT thread safe, it relies on async to separate important regions</p>
</dd></dl>

<dl class="py method">
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ <h1>Welcome to Lifeblood documentation!<a class="headerlink" href="#welcome-to-l
<li class="toctree-l2"><a class="reference internal" href="nodes/stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l2"><a class="reference internal" href="nodes/stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l2"><a class="reference internal" href="nodes/stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l2"><a class="reference internal" href="nodes/stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</li>
</ul>
Expand Down
2 changes: 2 additions & 0 deletions nodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="nodes/stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="nodes/stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="nodes/stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="nodes/stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down Expand Up @@ -481,6 +482,7 @@
<li class="toctree-l1"><a class="reference internal" href="nodes/stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="nodes/stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="nodes/stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="nodes/stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</section>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/attribute_splitter.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/delete_attrib.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/environment_resolver_arguments_setter.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/killer.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/mod_attrib.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/null.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/parent_children_waiter.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/python.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/rename_attrib.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/set_attrib.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/spawn_children.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/split_waiter.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/switch.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/wait_for_task_value.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/core/wedge.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../stock/telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/stock/houdini/karma.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1 current active"><a class="current reference internal" href="#">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="mantra.html">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
1 change: 1 addition & 0 deletions nodes/stock/houdini/mantra.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="karma.html">Karma</a></li>
<li class="toctree-l1 current active"><a class="current reference internal" href="#">Mantra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../matrixnotifier.html">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="../telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down
11 changes: 11 additions & 0 deletions nodes/stock/matrixnotifier.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<script>DOCUMENTATION_OPTIONS.pagename = 'nodes/stock/matrixnotifier';</script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="Telegram Notifier" href="telegram_notifier.html" />
<link rel="prev" title="Mantra" href="houdini/mantra.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
Expand Down Expand Up @@ -398,6 +399,7 @@
<li class="toctree-l1"><a class="reference internal" href="houdini/karma.html">Karma</a></li>
<li class="toctree-l1"><a class="reference internal" href="houdini/mantra.html">Mantra</a></li>
<li class="toctree-l1 current active"><a class="current reference internal" href="#">Matrix Notifier</a></li>
<li class="toctree-l1"><a class="reference internal" href="telegram_notifier.html">Telegram Notifier</a></li>
</ul>
</div>
</nav></div>
Expand Down Expand Up @@ -593,6 +595,15 @@ <h3>Initializing Matrix-Commander<a class="headerlink" href="#initializing-matri
<p class="prev-next-title">Mantra</p>
</div>
</a>
<a class="right-next"
href="telegram_notifier.html"
title="next page">
<div class="prev-next-info">
<p class="prev-next-subtitle">next</p>
<p class="prev-next-title">Telegram Notifier</p>
</div>
<i class="fa-solid fa-angle-right"></i>
</a>
</div>
</footer>

Expand Down
Loading

0 comments on commit 6ec51cd

Please sign in to comment.