# node-telme

> A CLI tool that will report to you via telegram when a task is done

Latest version **0.1.3** (published 2020-03-31) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install node-telme
pnpm add node-telme
yarn add node-telme
bun add node-telme
```

Provides the command `telme`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2020-03-31 |
| First published | 2020-03-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 54.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sagi Dayan |
| Maintainers | sagidayan |
| Keywords | telegram, bot, cli, telme, notifications, notification, automation |

## Links

- npm: https://www.npmjs.com/package/node-telme
- Repository: https://gitlab.com/sagidayan/telme
- Homepage: https://gitlab.com/sagidayan/telme#readme
- Issues: https://gitlab.com/sagidayan/telme/-/issues
- npm.io page: https://npm.io/package/node-telme

## Dependencies (1)

- [node-telegram-bot-api](https://npm.io/package/node-telegram-bot-api.md) ^0.40.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2020-03-31
- 0.1.2 — 2020-03-25
- 0.1.1 — 2020-03-23
- 0.0.4 — 2020-03-20
- 0.0.3 — 2020-03-19
- 0.0.2 — 2020-03-19
- 0.0.1 — 2020-03-19

## README

# **telme**
#### CLI inline telegram bot notifications

## TL;DR
1. Get a bot token ( [BotFather](https://telegram.me/botfather) )
2. `$ npm install -g node-telme`
3. `$ telme --init`
4. Need help? `$ telme --help`

## How do i get a bot token?
 - Get a telegram bot token from the BotFather, It takes less than a minute
   - Just talk to [BotFather](https://telegram.me/botfather)  and follow a few simple steps. Once you've created a bot and received your authorization token, copy it for later 

## Configure `telme`

Simply run `$ telme --init` and follow 2 easy steps. You will need the bot token at this stage.
This will help you generate a `.telmeconfig` file in your home directory. You can always run `--init` again to override values or just edit the file yourself.

#### Config file structure
The config file `.telmeconfig` should be located in your home folder and contain a valid JSON.

Example config (`~/.telmeconfig`): 
```json
{
  "version": "0.1.0",
  "profiles": {
    "profile_name": {
      "chat_id": 000000,
      "bot_token": "<bot_token>",
      "task_message_template": "*Task:*\n\n```sh\n%cmd%\n```\nHas finished.\n*Errors*:\n %errors%"
    },
    ...
  }
}
```
> `task_message_template` allows the following optional placeholders `%cmd%`, `%errors%`. These will be replaced with the actual command and errors.

## Profiles

You can set multiple profiles, that will target different bots and/or different chats.
> You can use the same bot in all profiles if you like, But the target chat can be different

To initialize a new profile:
```shell
$ telme --init --profile <profile_name>
```

## Examples:
###### Simple message
```shell
$ telme -m "Message to send"
```

In the next example a message will be sent every time the user `user` logs in to a tty.
> Added the next lines at the bottom of `~/.profile` file
```shell
# Telme on login
telme -m "A new Login:\`\`\` user: $(whoami) | hostname: $(hostname) | remote ip $(who | cut -d'(' -f2 | cut -d')' -f1)\`\`\` Hope this is you\!"
```

###### Task message
Task messages are a simple way to receive a message from your bot once a command has been finished. It will also let you know if you had any errors.
```shell
$ telme docker build . -t my-image/build/that/takes/for/ever
```
In this example, once the docker build has finished you will receive a message.

As mentioned before - you can also specify a profile.

```shell
$ telme -p movie-club curl https://example.com/large/file/download.mp4
```
this will send the message to the `movie-club` profile chat. (By the `movie-club` bot)  

## Using as a `node_module`
> Typescript users will have definitions
```javascript
import Telme from 'node-telme' // OR const Telme = require('node-telme').default

const config = {
  chat_id: 'somechatid',
  bot_token: 'bot-token'
}

Telme.sendMessage(config, 'Hi there!').then(_=>{
  ...
}).catch(console.error);

// %cmd% and %errors% will be replaced buy actual values.
config.task_message_template = 'Task: %cmd% is done!. Errors: %errors%';
const options = {
  command: 'ls',
  args: ['-lah'] // If no args pass in an empty array
};

Telme.runTask(config, options).then(_=>{
  ...
}).catch(console.error);

```

---
_Source: https://npm.io/package/node-telme · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
