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
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.
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.
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.
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
- 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:
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