Skip to content

Pipes data extracted from a blockchain to Telegram

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

pinax-network/substreams-sink-telegram

Repository files navigation

Substreams Telegram CLI Node.js

substreams-sink-telegram is a tool that allows developers to pipe data extracted from a blockchain to the Telegram messaging social platform.

📖 Documentation

Further resources

Protobuf

CLI

Use pre-built binaries

  • MacOS
  • Linux
  • Windows

Install globally via npm

$ npm install -g substreams-sink-telegram

Run

$ substreams-sink-telegram run [options] <spkg>

Formatting

Supports JSON and YAML format for configuration file. Example of config.json format configuration file:

[
    {
        "entity": "Transfer",
        "chat_ids": [
            "@some_chat_id",
            "@some_other_chat_id"
        ],
        "message": "This *{user_id}* made a transaction with id [{trx_id}](https://someblockexplorer.com/transactions/{trx_id})"
    },
    {
        "entity": "Transfer",
        "parse_mode": "HTML",
        "chat_ids": [
            "@some_chat_id"
        ],
        "message": "PRIVATE GROUP: This <b>{user_id}</b> made a transaction with id <a href=\"https://someblockexplorer.com/transactions/{trx_id}\">{trx_id}</a>"
    },
    {
        "entity": "OtherEntity",
        "chat_ids": [
            "@some_chat_id"
        ],
        "message": "This {other_field}"
    }
]

Text between {} are field names and are used as labels for message templating. In the example above, all EntityChanges messages coming from the substream with entity key having Transfer as value, will be sent to Telegram chats with id @some_chat_id and @some_other_chat_id, as specified in the first and second json object.

Features

Substreams

  • Consume *.spkg from:
    • Load URL or IPFS
    • Read from *.spkg local filesystem
    • Read from substreams.yaml local filesystem
  • Handle cursor restart

Telegram

  • Handle rate limit
  • HTML message parsing
  • MarkdownV2 message parsing (by default)