coffea-telegram
v1.0.0-beta9-9
Published
_telegram plugin for [coffea 1.0-beta](https://github.com/caffeinery/coffea/tree/1.0-beta)_
Downloads
49
Readme
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
, 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
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)
)