Telegram is a free & open-source messenger.
This article describes Telegram configuration for CAS when operating your own CAS server to receive notifications from CAS regarding transactions and other events relevant to your BATM operation.
Server: Notifications can be delivered via Telegram.
Extensions: You can talk to extensions via Telegram.
To use Telegram as a notification method, you must build the extension and load it in CAS.
Example compilation instructions (below): Compiling from Source
Once the extension is loaded, you can proceed to use the instructions that follow.
In this example, we'll use "gb_kb_example_bot".
NOTE: the bot name MUST end with the word "bot"! |
/start /newbot [name of your bot] |
Example:
/start
/newbot gb_kb_example_bot
Example:
/start
/newbot gb_kb_example_bot
The BotFather will now ask you to invent a "username".
Save the received HTTP API token. |
sudo touch /batm/config/telegram sudo nano /batm/config/telegram |
telegram_bot_username=your_unique_bot_name telegram_bot_token=APIKey:APIToken |
The resulting file will look like this (using our example):
Save the file (type Ctrl+x and save when asked).
sudo /batm/batm-manage stop all sudo /batm/batm-manage start all |
The bot won't work until the CAS Admin service is running!
Open Telegram and locate your new bot:
Click on the start button:
Receive your Telegram User ID in a reply:
This number is your "Telegram User ID" for CAS notification rules! |
Be sure to SAVE the setting (SUBMIT).
Create a Notification Rule:
Set the Action Parameter to the same Telegram User ID previously identified.
Save the Policy/Rule and test using a BATM. |
You can search the master log for the TelegramBot string. You should see the TelegramBot registering command.
If you have carefully followed the above steps, and the test event does not trigger a notification properly, please Create a Support Ticket . |
Test to see if the extension already exists:
ls /batm/app/master/extensions/server_extensions_examples*.jar |
If the extension already exists, building it from source is optional.
REPOSITORIES: GitHub, Java, and source code compilation is beyond the scope of this article and General Bytes' support. |
This article is intended for advanced Operators. If you are unfamiliar with Java, website development, or addressing ports via IP, then STOP ! |
Clone the GB repository.
Compile the CAS extension (JAR).
Copy that JAR to the correct destination in your CAS host.
Test it.
sudo apt update && sudo apt install git |
These instructions assume you’ll use your home directory. If you choose to clone into another, different directory, then adjust this next command to change to it instead:
cd $HOME |
Now clone the batm_public
repository:
git clone https://github.com/GENERALBYTESCOM/batm_public |
If you’ve previously cloned the repository (e.g. for the SSH wallet tunnel), the server_extensions_examples directory (and contents) may not exist. Fix that to continue. You’ll have to either:
|
Compilation currently requires OpenJDK version 8.
sudo apt update && sudo apt install openjdk-8-jdk openjdk-8-jre |
Build the batm_server_extensions_examples.jar extension with:
cd $HOME/batm_public/currencies ../gradlew clean build cd ../server_extensions_api ../gradlew clean build cd ../server_extensions_examples ../gradlew clean build |
After each build (above), you should see “BUILD SUCCESSFUL”:
You have succeeded in building the API jar from source code. Now copy the file to CAS. |
You’ve prepared CAS (in step 1) to look for an extension in a specific place. Put it in it’s place.
The default compiled location of the JAR (using above instructions) is:
$HOME/batm_public/server_extensions_examples/build/libs/batm_server_extensions_examples.jar
We want to copy it to this folder:
/batm/app/master/extensions/
sudo cp $HOME/batm_public/server_extensions_examples/build/libs/batm_server_extensions_examples.jar /batm/app/master/extensions/batm_server_extensions_examples.jar |
sudo chown batmmaster:batmmaster /batm/app/master/extensions/batm_server_extensions_examples.jar |
sudo /batm/batm-manage stop all sudo /batm/batm-manage start all |
Success. The JAR is now in the proper place, and CAS will load it when started. |