Skip to content

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

License

Notifications You must be signed in to change notification settings

rapid-sensemaking-framework/rsf-telegramable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
})

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published