Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // У вас должен быть установлен nodejs
- // Установите зависимости для скрипта командой npm install golos-js
- // =====================================================================
- // Автор https://golos.io/@djimirji/
- // =====================================================================
- // Логин и пароль(постинг ключ) аккаунта который будет делать реблоги в свой блог
- const votersSemiBot = [
- {user:"djimirji", userpwd:"555555555555555555555555555555"}
- ];
- // Логин аккаунта на который должены подписываться пользователи, что бы их имена попали в белый список!
- const mainBot = 'djimirji';
- //Вызов бота
- const UpVoteCall = '@djimirji up!';
- // ======================= Коннект ==========================
- //const GOLOSNODE = "ws://localhost:9090"
- const GOLOSNODE = "wss://api.golos.cf"; //нода @vik
- // Подключение JavaScript библиотеки для работы c API голоса
- const golos = require('golos-js');
- // Указываем ноду, к которой будет подключен скрипт
- golos.config.set('websocket', GOLOSNODE);
- // =====================================================================
- //#######################################################################
- // =================== Удаление дублей =========================
- function removeDuplicates(arr){
- let unique_array = []
- for(let i = 0;i < arr.length; i++){
- if(unique_array.indexOf(arr[i]) == -1){
- unique_array.push(arr[i])
- }
- }
- return unique_array
- }
- // =================== Конец удаления дублей ========================
- //##########################################################################
- // =================== Получение блогов =========================
- function getEachBlog(follower) {
- let d = new Date();
- let dt = d.toISOString().split('.')[0];
- let author = follower;
- let startPermlink = '';
- let beforeDate = dt;
- let limit = 3;
- return golos.api.getDiscussionsByAuthorBeforeDate(author, startPermlink, beforeDate, limit, async function(err, result) {
- });
- };
- // =================== Конец получения постов из блогов =========================
- //##########################################################################
- //##########################################################################
- // =================== Получения подписчиков =========================
- var startFollower = '';
- var followType = 'blog';
- var limit = 100;
- let i_followers = [];
- let lastFollower = '';
- let getfollowers = (startFollower) => {
- golos.api.getFollowers(mainBot, startFollower, followType, limit, function(err, result) {
- if ( ! err) {
- for (let f of result){
- i_followers.push(f.follower);
- };
- lastFollower = i_followers[i_followers.length - 1];
- };
- if (startFollower === i_followers[i_followers.length - 1]) {
- //console.log("Всех выбрали");
- i_followers = removeDuplicates(i_followers);
- setTimeout(() => {
- getblogs(i_followers);
- },1000);
- }
- else {
- getfollowers(lastFollower);
- };
- });
- };
- // =================== Конец функции получения подписчиков =========================
- //##########################################################################
- // =================== Получение коментариев =========================
- all_Comments_From_Blog = [];
- function CallCommFromBlog (CommCheckAuthor, CommCheckLink) {
- async function GetComments (CommCheckAuthor, CommCheckLink, commchildren) {
- function i_GetComments (Author, Link) {
- return golos.api.getContentReplies(Author, Link,function(err, result) { });
- };
- let FirstLevel = await i_GetComments (CommCheckAuthor, CommCheckLink);
- if (FirstLevel != null) {
- for (let i of FirstLevel){
- //console.log(i); //
- if (i.children > 0){
- await GetComments (i.author, i.permlink, commchildren);
- //console.log("дочерних каментов", i.children);
- }
- else {};
- if (i.body.toLowerCase().search(UpVoteCall) != '-1'){
- //console.log("Найден запрос", i.url, commchildren);
- let findedcall = '';
- let comented = '';
- findedcall = await i_GetComments (i.author, i.permlink);
- if ( findedcall != '' ) {
- let checkanswer = [];
- let str = "";
- for (let f of findedcall ){
- str = f.json_metadata.split(',"app":')[1];
- if (str != null){
- str = str.substring(0, str.length - 2);
- str = str.substring(1);
- checkanswer.push(str);
- };
- }
- if (checkanswer.includes("djimirji upvote bot")){
- comented = 1;
- //console.log("Прокоментировано");
- }
- else {
- comented = 0;
- //console.log("Коментарий не оставлен");
- };
- }
- else {
- comented = 0;
- //console.log("Коментарий не оставлен");
- }
- add_comm_to_array = {
- url: i.url,
- author: i.author,
- permlink: i.permlink,
- body: i.body,
- created: i.created,
- comented: comented
- }
- all_Comments_From_Blog.push(add_comm_to_array);
- }
- }
- }
- else {
- return;
- };
- }
- GetComments (CommCheckAuthor, CommCheckLink, 0);
- };
- // =================== Конец получения коментариев =========================
- // =================== Проверка на апвоут ================================
- function UpVoteCheck (url) {
- let str = url.split('#')[0];
- str = str.split('@')[1];
- let pauthor = str.split('/')[0];
- let plink = str.split('/')[1];
- return golos.api.getActiveVotes(pauthor, plink, function(err, result) {
- });
- };
- // =================== Конец проверки на апвоут =========================
- //##########################################################################
- // =================== Коментарий ================================
- function CommentAdd (parentAuthor, parentPermlink,body,p) {
- let postingkey = votersSemiBot[0].userpwd;
- // let permlink = 're-' + parentAuthor + '-' + parentPermlink + '-' + Date.now();
- let permlink = 're-' + parentPermlink + '-' + Date.now();
- let title = '';
- let jsonMetadata = {
- "tags": ["djimirji"],
- "app": "djimirji upvote bot"
- }
- setTimeout(() => {
- console.log("Коментирую",parentAuthor,body);
- return golos.broadcast.comment(postingkey, parentAuthor, parentPermlink, mainBot, permlink, title, body, jsonMetadata, function(err, result) {
- // console.log(err, result);
- });
- },p);
- };
- // =================== Конец кометария =============================
- // =================== Голосование =========================
- function Vote (parent_author,parent_permlink,VOTEPOWER,postingkey,author,p) {
- setTimeout(() => {
- console.log("ГОЛОСУЮ",author, parent_author);
- return golos.broadcast.vote(postingkey, author, parent_author, parent_permlink, VOTEPOWER * 100, function(err, result) {
- });
- },p);
- };
- // =================== Конец голосования =========================
- //################################################################################
- //##########################################################################
- var end_of_check_all_comments = '';
- async function getblogs (i_followers) {
- let allblogs = [];
- for (i=0;i<i_followers.length;i++){
- let carentBlog = await getEachBlog(i_followers[i]);
- if (carentBlog != null) {
- carentBlog.forEach(function(item){
- //console.log(item.author);
- blg = {
- author: item.author,
- permlink: item.permlink
- }
- allblogs.push(blg);
- });
- }
- if (i == i_followers.length -1 ){
- i_followers = []; //Чистим массив подписчиков
- //console.log("Всего блогов",allblogs.length);
- for (k=0;k < allblogs.length;k++){
- CallCommFromBlog(allblogs[k].author, allblogs[k].permlink);
- if (k == allblogs.length - 1){
- //console.log(allblogs);
- allblogs = []; //Чистим массив блогов
- end_of_check_all_comments = 'end';
- };
- };
- };
- };
- }
- function runBot() {
- getfollowers();
- async function BroadcastCommentAndVote () {
- let pause_comments = [];
- let p = 0;
- for (z=0;z < all_Comments_From_Blog.length;z++){
- let upvoted = '';
- let body = '';
- let VOTEPOWER = '';
- let str = all_Comments_From_Blog[z].url.split('#')[0];
- str = str.split('@')[1];
- let pauthor = str.split('/')[0];
- let plink = str.split('/')[1];
- let votecheck = await UpVoteCheck (all_Comments_From_Blog[z].url);
- let voters = [];
- votecheck.forEach(function(item) {
- voters.push(item.voter);
- })
- if (voters.includes(mainBot)) {
- upvoted = 1;
- }
- else {
- upvoted = 0;
- }
- let commentFromAuthorByDay = [];
- all_Comments_From_Blog.forEach( function (item) {
- if ((item.author == pauthor) && (new Date(item.created) > new Date(new Date().getTime() - 60 * 60 * 24 * 1000))) {
- //console.log(pauthor, item.created);
- commentFromAuthorByDay.push(item);
- }
- });
- if (commentFromAuthorByDay.length != 0) {
- VOTEPOWER = (Math.floor((Math.random() * 20) + 79)) - (commentFromAuthorByDay.length * 15);
- if (VOTEPOWER < 30) {
- VOTEPOWER = 33;
- };
- }
- else {
- VOTEPOWER = (Math.floor((Math.random() * 35) + 64));
- }
- // console.log(pauthor,commentFromAuthorByDay.length );
- commentFromAuthorByDay = [];
- // console.log(pauthor, plink, all_Comments_From_Blog[z].created,VOTEPOWER);
- if (all_Comments_From_Blog[z].comented == 0){
- pause_comments.push(all_Comments_From_Blog[z].url);
- p = (pause_comments.length -1 ) * 23000;
- votersSemiBot.forEach(function (v) {
- //console.log(p);
- if ((upvoted == 1) && (v.user == mainBot)){
- body = "💡 Этот пост уже получал upvote ранее :)";
- CommentAdd (all_Comments_From_Blog[z].author, all_Comments_From_Blog[z].permlink,body,p);
- return console.log(`\x1b[31m☹️ ${body} - ${all_Comments_From_Blog[z].author} - ${all_Comments_From_Blog[z].permlink} \x1b[0m`);
- }
- else {
- if (v.user == mainBot){
- //VOTEPOWER = (Math.floor((Math.random() * 50) + 50));
- body = "💡 @" + pauthor + " получил апвоут на " + VOTEPOWER +"% :)"+ `<br>` + `<pre><code class="language-sh">` + " Что бы вызывать бота подпишись на меня! " + `</code></pre>` + "";
- CommentAdd (all_Comments_From_Blog[z].author, all_Comments_From_Blog[z].permlink,body,p);
- Vote(pauthor,plink,VOTEPOWER,v.userpwd,v.user,p);
- return console.log(`\x1b[96m💬 ${v.user} коментирует и голосует за ${pauthor}, по ссылке - ${plink} \x1b[0m`);
- }
- else {
- VOTEPOWER = 100;
- Vote(pauthor,plink,VOTEPOWER,v.userpwd,v.user,p);
- return console.log(`\x1b[32m🔗 Голосует доп.аккаунт: ${v.user} силой ${VOTEPOWER}, за ${pauthor}, статья: ${plink} \x1b[0m`);
- }
- };
- });
- }
- };
- pause = ( pause_comments.length * 23000 ) + 120000;
- console.log(new Date(), " Пауза", pause/1000," сек.");
- setTimeout(() => {
- all_Comments_From_Blog = [];
- end_of_check_all_comments = '';
- pause_comments = [];
- runBot();
- }, pause );
- }
- function checkArrayEmptines (){
- if (end_of_check_all_comments == 'end') {
- //console.log("Коментарии обработаны");
- setTimeout(() => {
- BroadcastCommentAndVote();
- }, 10000);
- }
- else {
- setTimeout(checkArrayEmptines, 1000);
- //console.log("Не все проверено, ждем");
- }
- }
- checkArrayEmptines();
- }
- runBot();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement