Skip to content

Client Telegram

Keith Sterling edited this page Mar 15, 2019 · 3 revisions

#Telegram Bot

The Telegram Client provides a way for a Telegram Messenger to interact with a bot client.

To begin, you'll need an Access Token. Read and follow the Introduction to the API on the Telegram Developer website. When you are ready you then need to create an Access Token, which do by talking to the @BotFather via Telegram Messenger and follow a few simple steps.

You create new bots by directly interacting with the Telegram BotFather via your favourite Telegram client.

Login to Telegram Client

Start a conversation with BotFather by searching for ‘botfather’ in the search box, click on @BotFather and a new conversation will start

We create a new bot with the ‘/newbot’ command

/newbot

Give it a name

Give it a username

Telegram will now create a token to access HTTP API is given

Take the token (blacked out for security purposes) and add it to licenses.keys

TELEGRAM_TOKEN = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

You are now ready to run your Telegram client

Run ./y-bot-telegram.sh
Loading Telegram client, please wait. See log output for progress...
No bot root argument set, defaulting to [../../config/xnix]
Found a total of 1 errors in your grammars, check your errors store
Found a total of 6 duplicates in your grammars, check your duplicates store
Telegram Bot connected and running...

Once you can can see its runnings, you can go to Telegram Client and search for the bot name you used above

Click on your bot and then on ‘start’ and you can then start talking to you bot

Configuration

Telegram client needs little configuration apart from which message to return if you send it an unknown command. This can be configured by adding the following client configuration to config.yaml.

telegram:
  unknown_command: Sorry, that is not a command I have been taught yet!

Running Program-y Telegram Client

To run the Telegram client, you can use the shell script in Y-Bot scripts folder

./y-bot-telegram.sh

Or you can use the command line

python3 -m programy.clients.polling.telegram.client --config <PATH TO CONFIG> --cformat yaml --logging <PATH TO LOGGING>
Clone this wiki locally