Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Eris = require("eris");
- const steem = require("steem");
- var mysql = require('mysql');
- var con = mysql.createConnection({
- host: "127.0.0.1",
- user: "root",
- password: "45600",
- database: "voter"
- });
- con.connect();
- var bot = new Eris("NDI0NjIwNTY5MzA5MzQ3ODUx.DY_RnQ.W_0BDpZqZbGqhrFIaFy9sPoLGOQ");
- var regex = /(\$)+(upvote)+.+(https:\/\/)+.+(@)+.+(\/)/;
- var regex1 = /(@)+.+(\/)/;
- var wifkey = '5J4rtCGPQasTZMrP74uACzg3hpogTvUnx3bsedbMh3qrWQUa18X';
- var votey = "madh16";
- var weight = 1500; // 10000 = 100%
- var per = 0.0001; // 86400 seconds = 24hour
- bot.on("ready", () => {console.log('voter bot started! weight '+weight+' %');}); //when it is ready
- bot.on("messageCreate", (msg) => { // when a message is created
- if(msg.content.match(regex)){
- var permlink= msg.content.replace(msg.content.match(regex)[0],"");
- var au = msg.content.match(regex1)[0];
- var aut = au.replace("@","");
- var author = aut.replace("/","");
- var channel = msg.channel.id;
- var uid = msg.author.id;
- var x = '0';
- con.query('SELECT EXISTS(SELECT * FROM `voter` WHERE `userid` = "'+uid+'")', function (error, results, fields) {
- for(i in results){
- for(j in results[i]){
- x = results[i][j];
- if(x == '1'){
- var last;
- con.query('SELECT `lastvote` FROM `voter` WHERE `userid`="'+uid+'"', function (error, results, fields) {
- for(i in results){
- for(j in results[i]){
- last = results[i][j];
- }
- }
- var time = Math.floor(new Date().getTime() / 1000);
- if((time - last) > per){
- con.query('UPDATE `voter` SET `lastvote`="'+time+'" WHERE `userid`="'+uid+'"', function (error, results, fields) {
- steem.broadcast.vote(wifkey,votey,author,permlink,weight,function(downerr, result){
- if(downerr){
- setTimeout(function(){bot.createMessage(channel,'Already Upvoted!');},1000);
- con.query('UPDATE `voter` SET `lastvote`="'+last+'" WHERE `userid`="'+uid+'"', function (error, results, fields) {
- });
- }
- if(result) {
- setTimeout(function(){bot.createMessage(channel,'Done! Your Post Upvoted By @madh16');},1000);
- }
- });
- });
- }else{
- var come = per - (time - last);
- setTimeout(function(){bot.createMessage(channel,'Sorry! Come back after '+come+' seconds.');},1000);
- }
- });
- }else{
- var time = Math.floor(new Date().getTime() / 1000);
- con.query('INSERT INTO `voter`(`user`, `lastvote`, `userid`) VALUES ("'+author+'","'+time+'","'+uid+'")', function (error, results, fields) {
- steem.broadcast.vote(wifkey,votey,author,permlink,weight,function(downerr, result){
- if(downerr){
- setTimeout(function(){bot.createMessage(channel,'Already Upvoted!');},1000);
- con.query('UPDATE `voter` SET `lastvote`="10" WHERE `userid`="'+uid+'"', function (error, results, fields) {
- });
- }
- if(result) {
- setTimeout(function(){bot.createMessage(channel,'Done! Your Post Upvoted By @madh16');},1000);
- }
- });
- });
- }
- }
- }
- });
- }
- });
- bot.connect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement