Steevie - Never miss a notification from Steem blockchain Update 0.1.0

in #utopian-io5 years ago (edited)

Repository

https://github.com/gigatoride/steevie

Telegram bot

https://telegram.me/SteevieBot

logotype.png

New Feature

Commit

Notifications Manager

This is a new feature has been created for Steevie bot to notify registered users for mentions, replies, transfers each telegram user has only one Steem account only with the ability to change the account or delete it.
All notifications are being pushed to user chat by using an operator for it. I've implemented the streamTransactions() method to stream and operate the notifications stream from the Steem blockchain.

I've also made dynamic buttons that change on telegram user input I also would like to mention that on each database change for Account model it being caught as a change for watch() method in mongoose module
Then it will automatically update subscribes Array for the operator

notifi.gif

test.png

Notifications for replies

First I've created the operator as I've mentioned before then created a custom filter named getSubscribers()

Each stream is being filtered and matched with subscribed accounts then it's being pushed to the user as a new notification by chatId with telegraf-i18n as a translation module.

bot.telegram.sendMessage(
     sub.chatId,
     i18n.t(i18n.defaultLanguage,
    'new-notification-transfer', { from, amount, memo })
 );

Notifications for mentions

The same as the previous method it being filtered by getSubscribes() method and It's matched by body mention and the pushing the telegram message to notify the user.

bot.telegram.sendMessage(
    sub.chatId,
    i18n.t(i18n.defaultLanguage, 'new-notification-mention',
   { author: data.author })
  );

Notifications for transfers

This is a method notify the user for any transfer one his account, It's being matched by the receiver name which is the subscriber in this case

bot.telegram.sendMessage(
    sub.chatId,
    i18n.t(i18n.defaultLanguage,
    'new-notification-transfer', { from, amount, memo })
 );

Account authentication for notifications

An authentication for each notification action from the dynamic buttons has been made to prevent any bad upsert or conflict with the database as well as to make sure the telegram user is already registered

The following command will prevent unregistered accounts and prompt an answer callback query to tell the user he has to register first.

  const chatId = ctx.from.id;
  const account = await controller.getAccount(chatId);
  if (account.steemAccount) {
    // User action handler
} else {
    ctx.answerCbQuery(ctx.i18n.t('please-setup-account'));
  }

Bot Error handler

I've also added an error handler for general bot errors

bot.catch(err => {
  console.log('Ooops', err);
});

GitHub Account

https://github.com/gigatoride

Sort:  
  • Good article with an animated gif, code samples and explanations of coding choices.
  • Good commit comments and also of code comments.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thank you for your review, @helo! Keep up the good work!

This post has received a 10.00% complementary upvote from @swiftcash 🤑

Hi @gigatoride!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @gigatoride!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.22
TRX 0.20
JST 0.035
BTC 91285.68
ETH 3152.90
USDT 1.00
SBD 3.09