1.0.84 • Published 4 years ago

rsf-telegramable v1.0.84

Weekly downloads
6
License
GPL-3.0
Repository
github
Last release
4 years ago

rsf-telegramable

A class that can send and receive telegram messages, that has a clean and simple speak/listen API.

Works in concert with rsf-telegram-bot.

Installation

npm install --save rsf-telegramable

Formatting of id

The id property of a person config should be like the following:

username

Associated type configuration

In a person config, use type telegram to specify a Telegramable

Telegramable Person Config Example

{
  "type": "telegram",
  "id": "myusername"
}

Usage

You must be running an instance of rsf-telegram-bot to connect to via websockets in order for the following to work. Say that is running on localhost, on port 3022...

const { init, shutdown, Telegramable } = require('rsf-telegramable')

const config = {
  socketUrl: 'ws://localhost:3022'
}
init(config).then(() => {
  const person = new Telegramable('tgusername')
  // log anything that we hear from them
  person.listen(console.log)
  person.speak('hello!')

  // after 5 seconds, shutdown/disconnect
  // person methods will no longer work, or be fired
  setTimeout(() => {
    shutdown()
  }, 5000)
})
1.0.84

4 years ago

1.0.8

4 years ago

1.0.83

4 years ago

1.0.82

4 years ago

1.0.81

4 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago