DTube IPFS Discord Bot March 2019 Update! Improved file pinning, node stats, usage data command and more!
![IPFS Discord Bot March 2019 update.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmUQifKS2FxRryReuPNMmSAEyEz27J5ByiRXMfLTV6JGRz/IPFS%20Discord%20Bot%20March%202019%20update.png)
Repository
https://github.com/techcoderx/DTube-IPFS-Bot
General Improvements
It has been over 6 months since the previous update on this bot. So it's time to give some fresh code to make this work more efficiently and give it some new features!
Improved file pinning
Commits:
Originally all file pinning operations were done entirely with ShellJS. Since then I had switched to the official IPFS Javascript library for file pinning in 0.8.3 update of my 3rd party DTube uploader, there's no reason to not do the same for my IPFS Discord Bot as well.
This code update mainly improves the error handling of pinning operations. In case of any errors, the API will return a proper error message which ShellJS cannot do.
Proper error message if IPFS hash record is not found on Steem
Previously, running any pinning commands for resolutions that simply do not exist as a record on the Steem blockchain, will result in a 404 download error, which could also mean that the video hash for specified resolution exists but failed to download from DTube's servers.
Now, if the specified hash cannot be found in json_metadata
of the Steem post, it will send a "record not found" error message to the user in the chat.
Tag spam fix on pin completion
This may not be an issue when only one or two instances of the bot are running at the same time. Since then, @onelovedtube have over 10 IPFS bots running in the Discord server. When a pin is complete, all the bots will tag the user that the pin is complete, effectively spam tagging.
![Screenshot 2019-03-19 at 9.35.50 PM.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmSma3Lyqn86Dy3rmmHKvUdnCgW6x7DCXMapWxN3cXkhTg/Screenshot%202019-03-19%20at%209.35.50%20PM.png)
So, instead of calling message.reply()
, it is now calling message.channel.send()
method on pin complete notification, with mention of the author and permlink together with the specified resolution in the notification.
![Screenshot 2019-03-19 at 9.38.18 PM.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmRjD1qtXHUYE1WT81ddinAWDc81yzjj4AT5UXYyr9CSyd/Screenshot%202019-03-19%20at%209.38.18%20PM.png)
New features
Now comes what's new in this update!
Usage stats command
Some users would like to check how much storage they're occupying with the videos that they pin. Now, the bot logs disk usage utilization for each pinning command run. And there is a command to check the totalled disk usage data.
It may be run by typing !usage
into the chat.
![Screenshot 2019-03-19 at 9.46.04 PM.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmWyHjgkipiaQzrXaWjgwH6VG4C9QNZ6SgcjUHojFfKGXJ/Screenshot%202019-03-19%20at%209.46.04%20PM.png)
Server admins may obtain all user's disk usage data in a RAW JSON file, in a DM by typing !usagels
into the chat.
IPFS node stats command
Commits:
- Add !stats command
- Add peer count in !stats command
- Add node ID to filter !stats
- Accept IPFS peer ID as filter for !stats command
A new command has been added to find out IPFS node stats, such as bandwidth usage, number of pins, peers connected etc, through the bot itself. It may be triggered by !stats
command, and the result will look something like this:
![Screenshot 2019-03-19 at 9.50.23 PM.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmf3LRKTHhkMcnXqyEbqX7H5H5ginsuRLCvzQes4h2Q6pe/Screenshot%202019-03-19%20at%209.50.23%20PM.png)
To filter stats so that it will only show stats for one particular node, either put !usage <nodeID>
(where nodeID
is a number or string specified in config.json, or the peer ID of the IPFS node, which may be obtained using the !myid
command).
.gitignore
these files:.DS_Store
bot.js
would benefit from being broken down in smaller functions instead of a massive if then else mess.REPLACE WITH FEEDBACK
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!
good job my friend , that's great to have the code on github to let some people learn
Excellent work! The system works really well and now my pinned DTube videos load really fast.
Posted using Partiko iOS
Great work :) . This code already helps a lot of people in DTube and is really the first IPFS bot we ever had. I am very thankful to see continued updates .
Congratulations! Your post has been selected as a daily Steemit truffle! It is listed on rank 8 of all contributions awarded today. You can find the TOP DAILY TRUFFLE PICKS HERE.
I upvoted your contribution because to my mind your post is at least 8 SBD worth and should receive 130 votes. It's now up to the lovely Steemit community to make this come true.
I am
TrufflePig
, an Artificial Intelligence Bot that helps minnows and content curators using Machine Learning. If you are curious how I select content, you can find an explanation here!Have a nice day and sincerely yours,
![trufflepig](https://steemitimages.com/640x0/https://raw.githubusercontent.com/SmokinCaterpillar/TrufflePig/master/img/trufflepig17_small.png)
TrufflePig
Hi @techcoderx!
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, @techcoderx!
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!