Browse Source

Configurable bot name and updated README. Fixes #115

pull/114/merge
Pēteris Caune 8 years ago
parent
commit
5cb372d18f
5 changed files with 27 additions and 5 deletions
  1. +20
    -0
      README.md
  2. +1
    -1
      hc/front/tests/test_add_telegram.py
  3. +2
    -1
      hc/front/views.py
  4. +1
    -0
      hc/settings.py
  5. +3
    -3
      templates/integrations/add_telegram.html

+ 20
- 0
README.md View File

@ -230,3 +230,23 @@ To enable Pushover integration, you will need to:
subscription type
* add the application token and subscription URL to `hc/local_settings.py`, as
`PUSHOVER_API_TOKEN` and `PUSHOVER_SUBSCRIPTION_URL`
### Telegram
* Create a Telegram bot by talking to the
[BotFather](https://core.telegram.org/bots#6-botfather). Set the bot's name,
description, user picture, and add a "/start" command.
* After creating the bot you will have the bot's name and token. Add them
to your `hc/local_settings.py` file as `TELEGRAM_BOT_NAME` and
`TELEGRAM_TOKEN` fields.
* Now the tricky part: when a Telegram user talks to your bot,
Telegram will use a webhook to forward received messages to your healthchecks
instance. For this to work, your healthchecks instance needs to be publicly
accessible over HTTPS. Using the
[setWebhook](https://core.telegram.org/bots/api#setwebhook) API call
set the bot's webhook to `https://yourdomain.com/integrations/telegram/bot/`.

+ 1
- 1
hc/front/tests/test_add_telegram.py View File

@ -12,7 +12,7 @@ class AddTelegramTestCase(BaseTestCase):
def test_instructions_work(self):
self.client.login(username="[email protected]", password="password")
r = self.client.get(self.url)
self.assertContains(r, "start@HealthchecksBot")
self.assertContains(r, "start@ExampleBot")
def test_it_shows_confirmation(self):
payload = signing.dumps((123, "group", "My Group"))


+ 2
- 1
hc/front/views.py View File

@ -804,7 +804,8 @@ def add_telegram(request):
ctx = {
"chat_id": chat_id,
"chat_type": chat_type,
"chat_name": chat_name
"chat_name": chat_name,
"bot_name": settings.TELEGRAM_BOT_NAME
}
return render(request, "integrations/add_telegram.html", ctx)


+ 1
- 0
hc/settings.py View File

@ -154,6 +154,7 @@ PUSHBULLET_CLIENT_ID = None
PUSHBULLET_CLIENT_SECRET = None
# Telegram integration -- override in local_settings.py
TELEGRAM_BOT_NAME = "ExampleBot"
TELEGRAM_TOKEN = None
if os.path.exists(os.path.join(BASE_DIR, "hc/local_settings.py")):


+ 3
- 3
templates/integrations/add_telegram.html View File

@ -42,13 +42,13 @@
<span class="step-no">1</span>
<p>
From your Telegram client, invite
<strong>HealthchecksBot</strong> to a group. It will get added
<strong>{{ bot_name }}</strong> to a group. It will get added
as a member with no access to group messages.
</p>
<p>
Alternatively, if you want notifications sent to yourself
directly, start a conversation with
<strong>HealthchecksBot</strong>.
<strong>{{ bot_name }}</strong>.
</p>
</div>
<div class="col-sm-6">
@ -63,7 +63,7 @@
<span class="step-no">2</span>
<p>Type <strong><code>/start</code></strong> command.
If there are multiple bots in the group, type
<strong><code>/start@HealthchecksBot</code></strong> instead.
<strong><code>/start@{{ bot_name }}</code></strong> instead.
</p>
<p>The bot will respond with a confirmation link.</p>
</div>


Loading…
Cancel
Save