We often see in the Post Promotion channel of the Discord that people posts his or her same post more than once or more than one in 24 hours. So we need a script which will intelligent enough to delete those posts if its finds duplicate or more than one posts by a user in 24 hours. This will keep the post promotion clean and everyone will get the equal opportunity to promote their posts.
Technology Stack
The application is written in Node.js and we save the data in Sqlite database. Along with that we will use Discordie npm package to talk to Discord API. Along with this we also use Cluster Npm Package to make the BOT running 24 hours even if it crashes anytime.
Code
We are using Sqlite Database using the NPM package sqlite3
. So before starting we need to create the table, whenever you run the script it will see if the posts.db
has been created or not, if not it will create one for you with the Columns required in the script as shown below :
let db = new sqlite3.Database('posts.db');
db.serialize(function() {
db.run("CREATE TABLE if not exists posts_info
(discordName TEXT, post TEXT, time TEXT, channel_id TEXT)");
});
Next we Connect to the Discord using Discordie and whenever we see any incoming messages we will send the event to the Check Posts Function.
client.connect({
token: 'Bot Token'
});
client.Dispatcher.on(Events.GATEWAY_READY, e => {
console.log('Connected as: ' + client.User.username);
});
client.Dispatcher.on(Events.MESSAGE_CREATE, e => {
if (e.message.author.bot) {
return;
}
checkPosts(e);
});
In the Check Posts function we check if the link is valid i.e. if its from Steemit or Busy, if it is valid we check in the database if the user has added the Posts before by checking the discordName and channel_id. Once we get the posts we check the posts URL and the Time Difference between the earlier post and current post. If everything is correct you can post otherwise the bot will delete the post with a warning.
Commits
https://github.com/codingdefined/DiscordSpamRemoval/commit/da4821165749b309b65e8c9b70df1fce146ad331
https://github.com/codingdefined/DiscordSpamRemoval/commit/6b124748fcf6ff7cb4c5ebc9781349b58de5db57
https://github.com/codingdefined/DiscordSpamRemoval/commit/c36b504c6280d9ac7220b8f5b367cc2dd3fc7968
Bot in Action
Roadmap
As of now the Bot will save the Channel ID where the posts have been written along with Discord Name, now if you use more than one discord account you can still spam using the different account. We need to store the Steemit Username, Discord Name, Channel Id, Guild Id and Posts URL to reduce the spamming as much as possible. Create Test Cases and error handling.
How to contribute?
The code is freely available in Github which you can fork and create a pull request. If you need any feature to be added, you can also talk to me on the Discord (Id - codingdefined).
Posted on Utopian.io - Rewarding Open Source Contributors
This sounds interesting.
Might it at all be desirable to have a script that gamifies post promotion?
'Energy Units' measured in crystals.
It costs a certain amount of crystals (lets say 10) to successfully post a post promotion.
Crystals are regenerated slowly (lets say 1/ 6 hours)
Crystals can be saved and lost through public recognition and actions.
Users level up to increase not only the maximum number of crystals that they can hold but also can buy different abilities.
Example abilities:
Endorse - Lv1: At a cost of 1 crystal, another user gains one crystal
Torpedo - Lv1: At a cost of 1 crystal, another user loses one crystal
In this way, more complex and positive behavior can be encouraged while also setting a throttle on the number of posts that any user can post per day (and also mitigating multi-account abuse with proper design).
Sorry for the hijack. :c)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Its possible but the only thing is that there are people who just post their post and leave. We need to find out the balance between all so that all gets benefited.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
It's really thoughtful of you to start this project. I hope this will help the @thesteemengine post promotion channel and many others too.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Sure It will definitely help. Thanks
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you for the contribution. It has been approved.
Your readme is not named properly just add file extension
md
to it and it will be great if you expand yourREADME
about this project to make it more detailed.Thanks!!
You can contact us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Done the changes
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
This is a great addition to the @indiaunited discord channel and I believe this can be used in many other discord servers, we can get rid duplicate post nuisance. Great job!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks @lifecruiser, just helping the way I can
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @codingdefined I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit