Skip to content

Latest commit

 

History

History
141 lines (109 loc) · 6.94 KB

Telegram.md

File metadata and controls

141 lines (109 loc) · 6.94 KB

Overview

Prerequisites

This guide assumes:

  1. You are familiar with JSON formatting
  2. You have read and understood the Alarms Wiki
  3. You are comfortable with the layout of alarms.json.

Please familiarize yourself with all of the above before proceeding.

Introduction

Telegram is a cloud-based instant messaging service. Telegram clients exist for both mobile (Android, iOS, Windows Phone, Ubuntu Touch) and desktop systems (Windows, OS X, Linux). Users can send messages and exchange photos, videos, stickers and files of any type.

PokeAlarm offers the following for Telegram:

  • Notifications to multiple Telegram channels
  • Customizable Google Map image of the pokemon, gym, and/or pokestop location
  • Personalized notifications via Dynamic Text Substitution

Basic Config

Required Parameters

These alarm.json parameters are required to enable the Telegram alarm service:

Parameters Description
type must be telegram
active True for alarm to be active
bot_token Your Bot Token from Telegram
chat_id Your chat's id from Telegram

Example: Basic Alarm Configuration using Required Parameters

Below is how a basic Telegram alarm configuration would appear in alarms.json. Note that this is not the entire alarms.json, but only the section pertaining to the alarm portion of the JSON file.

{
	"active": "False",
	"type":"telegram",
	"bot_token":"YOUR_BOT_TOKEN",
	"chat_id":"YOUR_CHAT_ID"
}

Advanced Config

Optional Parameters

In addition to the required parameters, several alarm.json optional parameters are available to personalize your notifications. Below is an example of these optional parameters and how they are incorporated into a functional alarm layout.

Parameters at the alarm level will be the default to alert-level parameters.

Parameters Description Default
location Sends minimap after main message. True
disable_map_notification Disables map notifications. Set to False if you are experiencing notification issues on Android True
venue Sends location in main message. False
startup_message Confirmation post when PokeAlarm initialized True

These optional parameters below are applicable to the pokemon, pokestop, gym, egg, and raid sections of the JSON file. These parameters overide the alarm-level settings for this alert.

Parameters Description Default
title Header text for the message A wild <pkmn> has appeared!
body Additional text to be added to the message "<gmaps> \n Available until <24h_time> (<time_left>)."
location Sends minimap after main message. True
disable_map_notification Disables map notifications. Set to False if you are experiencing notification issues on Android True
venue Sends location in main message. False
stickers Sends pokemon images as stickers in the message True

Example: Alarm Configuration Using Optional Parameters

Below is how an advanced alarm configuration would appear in alarms.json. Note that this is not the entire alarms.json, but only the section pertaining to the alarm portion of the JSON file.

{
    "active": "False",
    "type":"telegram",
    "bot_token":"YOUR_BOT_TOKEN",
    "chat_id":"YOUR_CHAT_ID",
    "startup_message:":"True",
    "stickers": "True",
    "pokemon" : {
        "chat_id": "OVERRIDES_DEFAULT_CHANNEL",
        "title": "A wild <pkmn> has appeared!",
        "body": "<gmaps> \n Available until <24h_time> (<time_left>).",
        "location": "True"
    },
    "pokestop":{
        "chat_id": "OVERRIDES_DEFAULT_CHANNEL",
        "title":"Someone has placed a lure on a Pokestop!",
        "body": "<gmaps> \n Lure will expire at <24h_time> (<time_left>).",
        "location": "True"
    },
    "gym":{
        "chat_id": "OVERRIDES_DEFAULT_CHANNEL",
        "title":"A Team <old_team> gym has fallen!",
        "body": "<gmaps> \n It is now controlled by <new_team>.",
        "location": "True"
    },
    "egg": {
        "title": "A level <raid_level> raid is incoming!",
        "body": "The egg will hatch <begin_24h_time> (<begin_time_left>)."
    },
    "raid": {
        "title": "A raid is available against <pkmn>!",
        "body": "The raid is available until <24h_time> (<time_left>)."
    }
}

How to get a Telegram API Key

  1. Go to Telegram Web Client. Enter your phone number and follow the instructions to create your account.

  2. Talk to the BotFather to create a new bot. Use the /newbotcommand and follow his instructions. It will give you an API Token when you are finished.

  3. Start a conversation with your bot. In the top left click on the menu bars, then click create group. Type in the name of the bot you previously created, then click on it when it appears below. Then click next. Type any message to your bot.

  4. Enter your bot_token in to replace the <BOT_TOKEN_HERE> in the following url https://api.telegram.org/bot<BOT_TOKEN_HERE>/getUpdates. Then go to it, and find the section that says "chat":{"id":<CHAT_ID>. This number is your chat_id.

How to Create a Custom Channel

  1. Create a Public Channel (Currently doesn't work from the web app).

  2. Add your bot as an administrator for the channel.

  3. The chat_id for your bot will be @channel_url.