Telegram-bot notifier for BitShares by scientistnik

View this thread on steempeak.com
· @scientistnik ·
$5.57
Telegram-bot notifier for BitShares
<center>![bts-notifier.png](https://ipfs.busy.org/ipfs/QmZx2R4hPpV4eKy75qJVPMS8fN6pY3PzLPA3zRibUhapGt)
</center>
I sincerely believe that the popularity of the platform is correlated with the ease with which it is used. This also applies to writing software products for BitShares. Thus, I set myself the goal of reducing the barrier for programmers to enter the world of BitShares. The first stage was the implementation of `btsdex.js` oriented primarily to traders. But the subscription to change the account realized there seemed to me rather convenient not only for trading, but also for notification via third-party services. For example, I implemented [bts-notifier](https://github.com/scientistnik/bts-notifier), which will tell if in your account there will be a transfer of funds, creating order or fill order. On the basis of it you can build a notifier for email, Slack and other similar services.

For my part, I will do everything in my power to make this bot work consistently and stably. But all this I draw attention to, that this bot is only an example of use not intended for industrial use.

## <center>How to check it out</center>

To try it out in work, just find the bot in the telegraph [@btsnotifierbot](https://t.me/btsnotifierbot).
<center>![DeepinScreenshot_select-area_20180526210649.png](https://ipfs.busy.org/ipfs/QmPUdmcWHry4J92tH4qQQVBzxd54Cq4crXpERERUkwCAhE)</center>

Add tracking account
<center>![DeepinScreenshot_select-area_20180526210949.png](https://ipfs.busy.org/ipfs/QmVcqt2Dd6V243Ly6cT6damPFihaHNVESXHU8Ke8ZG23mN)</center>

and wait until something happens)
<center>![DeepinScreenshot_select-area_20180526210850.png](https://ipfs.busy.org/ipfs/QmR1Ax6NoFY5offW69bLPXoQYNyttZUPdfpqJWr78Xz4ce)</center>

## <center>Implementation</center>

Logic of the bot itself is divided into two files `database.js` and` main.js`. Most likely it is already clear from the name that in `database.js` is the logic of storing information about subscriptions. The main logic is in `main.js`. The settings for the entire program are in `config.js`.

After the startup, the program connects to the BitShares blockchain, sets up telegram notifications, and starts waiting for either messages from the telegram or changes in the BitShares account being tracked.

I used the packages:
- `btsdex` for working with blockchain,
- `telegraf` for working with telegram,
- `i18n` for multilanguage application.

`btsdex` is used very simply:
```js
const
  BitShares = require ('btsdex'),
  ...
BitShares.init (config.node);
BitShares.subscribe ('connected', start); // after establishing the connection, call start

async function start () {
  ...
  BitShares.subscribe ('account', funcs [acc], acc); // subscription to acc account
  ...
}
```

`telegraf` is also quite easy to use:
```js
async function start () {
  ...
  bot = new Telegraf (config.telegram.token)
  
  bot.start (greeting) // call the function greeting if the bot wrote `/ start`
  bot.hears (I18n.match ('menu.add_account'), addWaitAcc) // if someone wanted to add an account to call addWaitAcc
  bot.hears (I18n.match ('menu.remove_account'), removeWaitAcc)
  bot.hears (I18n.match ('menu.show_accounts'), showAcc)
  bot.hears (I18n.match ('menu.settings'), settings)
  bot.action ('cancel_wait_sub', cancelSub)
  bot.action (/ remove _. * /, removeSub)
  bot.on ('text', getText) // call getText if nothing above matches

  bot.startPolling () // get started
}
```

`i18n` is also nothing complicated:
```js
async function start () {
  ...
  i18n = new I18n ({
    directory: `$ {__ dirname} / locales`,
    defaultLanguage: 'en'
  })

  bot.use (i18n.middleware ())
}
// further everywhere where there is i18n.t ('here-some-text') - this is the localization of 'here-some-text'
```



All source code is available under the MIT license for [github](https://github.com/scientistnik/bts-notifier). So, quietly fork-up, modify and create your amazing services in the BitShares community.

Until a new meeting!
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
post_id50,418,919
authorscientistnik
permlinktelegram-bot-notifier-for-bitshares
categorybitshares
json_metadata"{"links": ["https://github.com/scientistnik/bts-notifier", "https://t.me/btsnotifierbot", "https://github.com/scientistnik/bts-notifier"], "users": ["btsnotifierbot"], "format": "markdown", "tags": ["bitshares", "bts", "blockchain"], "community": "busy", "app": "busy/2.4.0"}"
created2018-05-26 18:34:36
last_update2018-05-26 18:34:36
depth0
children1
net_rshares1,443,688,741,907
last_payout2018-06-02 18:34:36
cashout_time1969-12-31 23:59:59
total_payout_value4.268 SBD
curator_payout_value1.302 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length3,993
author_reputation748,935,547,503
root_title"Telegram-bot notifier for BitShares"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (35)
@steemitboard ·
Congratulations @scientistnik! You have received a personal award!

[![](https://steemitimages.com/70x70/http://steemitboard.com/@scientistnik/birthday1.png)](http://steemitboard.com/@scientistnik)  1 Year on Steemit
<sub>_Click on the badge to view your Board of Honor._</sub>


**Do not miss the last post from @steemitboard:**
[SteemitBoard World Cup Contest - Quarter Finals - Day 2](https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-quarter-finals-day-2)

---
**Participate in the [SteemitBoard World Cup Contest](https://steemit.com/steemitboard/@steemitboard/steemitboard-world-cup-contest-collect-badges-and-win-free-sbd)!**
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: [@good-karma](https://v2.steemconnect.com/sign/account-witness-vote?witness=good-karma&approve=1) and [@lukestokes](https://v2.steemconnect.com/sign/account-witness-vote?witness=lukestokes.mhth&approve=1)

---

> Do you like [SteemitBoard's project](https://steemit.com/@steemitboard)? Then **[Vote for its witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1)** and **get one more award**!
properties (22)
post_id55,887,175
authorsteemitboard
permlinksteemitboard-notify-scientistnik-20180708t213014000z
categorybitshares
json_metadata{"image":["https:\/\/steemitboard.com\/img\/notify.png"]}
created2018-07-08 21:30:12
last_update2018-07-08 21:30:12
depth1
children0
net_rshares0
last_payout2018-07-15 21:30:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length1,176
author_reputation38,705,954,145,809
root_title"Telegram-bot notifier for BitShares"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000