Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

coffea-telegram

telegram plugin for coffea 1.0-beta

Setup

  • Make sure to use the latest beta version of coffea by running: npm install --save coffea@beta
  • Install coffea-telegram: npm install coffea-telegram

Usage

Specify the telegram protocol in your network config:

{
  "protocol": "telegram",
  "token": "TOKEN"
}

coffea will automatically load coffea-telegram when it's needed! Thus, using telegram (or other protocols) this way should work on any coffea project, without any tweaks (other than installing coffea-telegram and specifying the config).

coffea-telegram aims to be compatible with coffea. Of course, features that telegram doesn't have (like joining channels) aren't available for telegram protocols, they will just be ignored.

Special Events

Telegram has some special events that IRC doesn't have, you can listen to them just like listening to messages and other events:

networks.on('EVENTNAME', (event, reply) => {
  console.log(event)
})

The following events are available: text, audio, document, photo, sticker, video, video_note, voice, contact, location, new_chat_members, left_chat_member, new_chat_title, new_chat_photo, delete_chat_photo, group_chat_created, callback_query, inline_query, chosen_inline_result, edited_message, edited_message_text, edited_message_caption, channel_post, edited_channel_post_text, edited_channel_post_caption, shipping_query, pre_checkout_query, error

If you want to use inline queries, make sure to enable inline mode.

For some example bots, check out the coffea-bots organisation for existing bots, or the coffea-starter repo, if you want to create your own bot.

Telegram API

You can use:

networks.send({
  type: 'FUNCTION_NAME',
  arguments
})

to access the telegram api. All arguments have the same names, except chatId has been changed to chat to be consistent with other coffea protocols and allow reply to work.

Here is an example:

Promise.all(networks.send({
  type: 'getMe'
})).then(
  me => console.log(me)
)

About

🔌 telegram protocol integration for coffea 1.0-beta

Resources

License

Packages

No packages published
You can’t perform that action at this time.