코인으로 부자되기/알트코인

스팀 자동 글쓰기 봇

야나부짱 2024. 4. 20. 12:37

스팀(steem) 이라는 코인이 있는데 글을 쓰고 사람들한테 보팅을 받는만큼 코인을 받게되는.. 그런 코인이 있다.

 

꽤 오래된 코인인데 지금도 살아있긴하다.

 

여러가지 메커니즘들이 있는데 그중에서 vnft, snft라고  스팀 커뮤니티에서 만든 nft를 갖고 있으면 보팅을 받을 수 있다. 약간 아파트 조합, 주민 조합이라고 볼 수 있다.

https://squad.steempunks.xyz/

 

SteemSquad - NFT Marketplace

The 1st NFT Marketplace on Steem

squad.steempunks.xyz

 

이걸 좀 갖고있는데, 보팅을 받으려면 글을 써야한다. 근데 매일마다 글쓰기가 힘들어서.. 그냥 봇을 만들기로 결심했다. 해야지해야지 미루다가 뚝딱 만들었는데, 혹시나 누군가에게 필요할까 싶어 글을 남겨놓는다. 필요한 api로는 dsteem, node-cron, node-upbit이다. javascript code이다.

 

var dsteem = require('dsteem')
var client = new dsteem.Client('https://api.steemit.com')
var cron = require('node-cron');
const axios = require('axios');

async function get_btc_price(market) {
  try {
    const response = await axios.get(`https://api.upbit.com/v1/candles/minutes/1?market=${market}&count=1`, {
      headers: {
        'accept': 'application/json'
      }
    });
    console.log('res', response)
    // return btc_price; // BTC 가격 반환
    return response.data[0].trade_price
  } catch (error) {
    console.error('Error:', error);
    throw error;
  }
}

get_btc_price('KRW-BTC')
  .then(btc_price => {
    console.log('BTC Price:', btc_price);
  })
  .catch(error => {
    console.error('Error occurred while fetching BTC price:', error);
  });


function addCommasToNumber(number) {
    return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

async function write_post(account, json_metadata, taglist, permlink, title, privateKey){

    const btc_price = await get_btc_price('KRW-BTC');
    let body = addCommasToNumber(btc_price)+"원 입니다.";
    console.log('body', body);
    client.broadcast
    .comment(
        {
            author: account,
            body: body,
            json_metadata: json_metadata,
            parent_author: '',
            parent_permlink: taglist[0],
            permlink: permlink,
            title: title,
        },
        privateKey
    )
    .then(
        function(result) {
            console.log('result', result)
        },
        function(error) {
            console.error(error);
        }
    );
}

const account = 'test'
const privateKey = dsteem.PrivateKey.fromString(
    '12345'
);

async function test(){
    const taglist = ['diary'];
    const currentDate = new Date();
    const formattedDate = `${String(currentDate.getMonth() + 1).padStart(2, '0')}-${String(currentDate.getDate()).padStart(2, '0')}`;
    const title = `[${formattedDate}] 비트코인 가격`;
    const permlink = 'btcprice' + `${String(currentDate.getMonth() + 1).padStart(2, '0')}${String(currentDate.getDate()).padStart(2, '0')}`;
    const json_metadata = JSON.stringify({ tags: taglist });
    await write_post(account, json_metadata, taglist, permlink, title, privateKey);
}

// test();
cron.schedule('5 10 * * *', async () => {
    test();
}, {
    scheduled: true,
    timezone: "Asia/Seoul" // Change the timezone as per your requirement
});

 

 

 

'코인으로 부자되기 > 알트코인' 카테고리의 다른 글

BRC-20 ORDI, SATS, RATS 폭등 원인 분석  (0) 2023.12.15
알트코인 Celestia (TIA) 분석  (1) 2023.11.25
[알트코인] BRC20 ORDI 가격 분석  (0) 2023.11.21
BRC20 ORDI 분석  (0) 2023.11.12
BRC20 SATS 분석 2  (1) 2023.11.11