[node.js 스팀봇 강좌] #10. steem.js를 이용하여 스팀잇 모니터링하기

in #kr7 years ago (edited)

지난 연재

[node.js 스팀봇 강좌] #1. steem.js 라이브러리 이용하기
[node.js 스팀봇 강좌] #2. steem.js를 이용해서 보팅해보기
[node.js 스팀봇 강좌] #3. steem.js를 이용해서 포스팅 올리기
[node.js 스팀봇 강좌] #4. 인증키 등의 정보를 외부 파일에 저장하기
[node.js 스팀봇 강좌] #5. steem.js를 이용하여 댓글 달기
[node.js 스팀봇 강좌] #6. steem.js를 이용하여 송금하기
[node.js 스팀봇 강좌] #7. steem.js를 이용하여 포스팅 조회하기
[node.js 스팀봇 강좌] #8. 포스팅 조회 결과에서 필요한 정보 추출하기
[node.js 스팀봇 강좌] #9. steem.js를 이용하여 팔로우 맺기


이번에는 steem.js를 이용하여 스팀잇에서 발생하는 모든 활동을 모니터링 해보겠습니다.

특히 이와 같은 모니터링을 통해 지난 #9 연재에서 사용한 custom 함수의 인자를 확인할 수도 있어서 부족한 steem.js의 메뉴얼을 보완할 수 있습니다.

또 메뉴얼만으로는 다 알기 힘든 스팀잇의 다양한 기능도 확인해 볼 수 있어 매우 유용하므로 지금까지의 실습을 따라오셧던 분들이라면 꼭 한번 실행해서 그 결과를 확인해 보시기 바랍니다.

그렇다고 뭔가 복잡한 프로그래밍 기술이 사용되는 것은 아니고, 지금까지와 마찬가지로 하나의 steem.js 함수 호출을 통해 가능합니다.

이 함수는 steem.js의 메뉴얼에 직접 언급되어 있지 않고 sample파일에 기술되어 있는 것을 우연히 실행해 보았다가 운좋게 얻어걸렸는데 그 형태는 다음과 같습니다.


steem.api.streamOperations(function (err, operations) {
  operations.forEach(function (operation) {
    console.log(operation);
});

별다른 인자값도 받지 않고 실행되는 이 함수는 실행 즉시 스팀잇에서 발생하는 네트워크 정보가 모두 실시간으로 전송됩니다.

30만 이상의 회원을 보유한 스팀잇의 실시간 정보량은 상당하기 때문에 실행 로그창에 쌓이는 정보를 제대로 확인하기는 어렵습니다.

그래서 결과값을 확인하는데 편의를 위해 대부분의 운영체제에서 기본으로 제공하는 '리다이렉션(>)' 기능을 사용하여 응답 결과를 별도의 파일로 저장해 보도록 하겠습니다.

1단계: 소스코드(test.js) 및 실행

image.png

2단계: 실행결과(result.txt) 확인

프로그램 실행 후 수 초간 기다린 뒤에 ctrl+c 단축키를 통해 'node test.js' 실행을 중단시킨 후 result.txt 파일을 열어보면 다음과 같은 정보들이 실시간으로 저장되어 있는 것을 확인할 수 있습니다.

로그의 내용이 길기 때문에 먼저 설명을 드린 후 하단에 약 200라인의 로그파일을 표시하도록 하겠습니다.

가장 많은 요청은 단연 보팅(vote)입니다. custom_json을 이용한 팔로우 활동도 많이 보이고 간간히 transfer를 통한 이체 활동도 보이고 있습니다. 물론 포스팅(comment)도 그 세부항목까지 json형식으로 다 조회가 가능하구요.

이 함수를 활용한다면 주기적으로 정보를 조회하지 않고도 누가 포스팅을 하고 보팅을 하고 이체를 하는지 실시간으로 조회가 가능하며 데이터 누적도 가능합니다. 아마도, 실시간으로 서비스를 제공하고 있는 스팀잇 내 bot들도 이 기능을 사용하고 있지 않을까 추정됩니다.

특히 이와 같이 건별 조회가 아니라 stream기반의 정보 조회는 서버에 부담을 거의 주지 않는 것으로 알려져 있으며, 때문에 향후 봇을 만들게 될 경우에 가능하면 이 함수를 활용하여 모니터링을 하는게 좋을 것으로 생각됩니다.

vote
{ voter: 'cryptoriddler',
  author: 'duckmast3r',
  permlink: 'my-curation-results-for-9-2-0-345-sp-201792t22048728z',
  weight: 99 }
vote
{ voter: 'newhope',
  author: 'chiefmappster',
  permlink: 'beat-battle-league-week-five-update',
  weight: 700 }
vote
{ voter: 'zemskovto',
  author: 'lemooljiang',
  permlink: '45lr2w-2',
  weight: 10000 }
transfer
{ from: 'enomujjass',
  to: 'steemdice1',
  amount: '1.000 STEEM',
  memo: '{"ui":"steemdice.net","type":"lower","number":30}' }
vote
{ voter: 'da-dawn',
  author: 'lichtblick',
  permlink: 'monomad-photographic-contest-week-8-buildings-zoom-studies-berlin-tv-tower-by-lichtblick',
  weight: 600 }
custom_json
{ required_auths: [],
  required_posting_auths: [ 'bobokyaw' ],
  id: 'follow',
  json: '["follow",{"follower":"bobokyaw","following":"deathnote9","what":["blog"]}]' }
vote
{ voter: 'faster',
  author: 'darthnava',
  permlink: 'the-waterfalls-near-iligan-city-part-13',
  weight: 10000 }
custom_json
{ required_auths: [],
  required_posting_auths: [ 'izbing' ],
  id: 'follow',
  json: '["follow",{"follower":"izbing","following":"mirakel","what":["blog"]}]' }
vote
{ voter: 'twinbraid',
  author: 'seaturtle',
  permlink: '1-only-1-student-in-the-whole-school',
  weight: 7300 }
vote
{ voter: 'malchniko',
  author: 'roxane',
  permlink: 'reclame-tes-pockets-et-deviens-millionnaire',
  weight: 10000 }
vote
{ voter: 'pyc1512',
  author: 'krischy',
  permlink: 'drawing-contest-learn-how-to-draw-a-self-portrait-with-kris-kris',
  weight: 10000 }
vote
{ voter: 'cryptoninja',
  author: 'siswadi',
  permlink: 'menu-makan-siang',
  weight: 5 }
custom_json
{ required_auths: [],
  required_posting_auths: [ 'abeeryas' ],
  id: 'follow',
  json: '["follow",{"follower":"abeeryas","following":"zexplanet","what":["blog"]}]' }
vote
{ voter: 'pharesim',
  author: 'siswadi',
  permlink: 'menu-makan-siang',
  weight: 2 }
vote
{ voter: 'ausbitbank',
  author: 'bmj',
  permlink: 'dinner-time-happy-fathers-day-to-all-the-dads-out-there',
  weight: 90 }
vote
{ voter: 'dreeshevin',
  author: 'incrediblesnow',
  permlink: '3-9-2017-cn-abuse-report-for-cn-abuse-on-3-9-2017',
  weight: 10000 }
custom_json
{ required_auths: [],
  required_posting_auths: [ 'vevosongs' ],
  id: 'follow',
  json: '["follow",{"follower":"vevosongs","following":"kevinfontolan","what":["blog"]}]' }
custom_json
{ required_auths: [],
  required_posting_auths: [ 'bobokyaw' ],
  id: 'follow',
  json: '["follow",{"follower":"bobokyaw","following":"deathnote","what":["blog"]}]' }
custom_json
{ required_auths: [],
  required_posting_auths: [ 'stbrians' ],
  id: 'follow',
  json: '["follow",{"follower":"stbrians","following":"awakentolife","what":["blog"]}]' }
vote
{ voter: 'liuke96player',
  author: 'rocksg',
  permlink: 'my-entry-for-sndbox-monthly-thumbnail-competition-by-sndbox',
  weight: 10000 }
vote
{ voter: 'zejkinay',
  author: 'techblogger',
  permlink: 'mit-robotics-the-robot-that-can-follow-contextual-commands',
  weight: 10000 }
vote
{ voter: 'sylvia1997',
  author: 'tvb',
  permlink: '3oszkz',
  weight: 10000 }
comment
{ parent_author: 'phelimint',
  parent_permlink: 're-miriamslozberg-pcos-awareness-month-20170903t023237942z',
  author: 'miriamslozberg',
  permlink: 're-phelimint-re-miriamslozberg-pcos-awareness-month-20170903t132450495z',
  title: '',
  body: 'Lots have that lol.',
  json_metadata: '{"tags":["health"],"app":"steemit/0.1"}' }
vote
{ voter: 'pml2020',
  author: 'youmab',
  permlink: 'usa-labor-inspection-complaint-against-tesla',
  weight: 8555 }
comment
{ parent_author: 'tata1',
  parent_permlink: 're-krexchange-5c22z1-10sbd-11-205-100sbd-112-050-20170903t102603503z',
  author: 'krexchange',
  permlink: 're-tata1-re-krexchange-5c22z1-10sbd-11-205-100sbd-112-050-20170903t132450599z',
  title: '',
  body: '거래 감사합니다. tip!',
  json_metadata: '{"tags":["kr-exchange"],"app":"steemit/0.1"}' }
vote
{ voter: 'steemitadventure',
  author: 'overkillcoin',
  permlink: 'art-when-all-else-fails-randowhale',
  weight: 10000 }
custom_json
{ required_auths: [],
  required_posting_auths: [ 'fulcanelli' ],
  id: 'follow',
  json: '["follow",{"follower":"fulcanelli","following":"islandprincess","what":["blog"]}]' }
vote
{ voter: 'nacktepoesie',
  author: 'artpoet',
  permlink: 'steemit-contest-join-vote-and-win',
  weight: 10000 }
comment
{ parent_author: 'kimmydee2',
  parent_permlink: 're-rooneey-slow-but-sure-i-believe-it-201793t20192461z-20170903t132142667z',
  author: 'rooneey',
  permlink: 're-kimmydee2-201793t202348203z',
  title: '',
  body: 'Thank you buddy',
  json_metadata: '{"tags":"steemit","app":"esteem/1.4.6","format":"markdown+html","community":"esteem"}' }
comment_options
{ author: 'rooneey',
  permlink: 're-kimmydee2-201793t202348203z',
  max_accepted_payout: '1000000.000 SBD',
  percent_steem_dollars: 10000,
  allow_votes: true,
  allow_curation_rewards: true,
  extensions: [ [ 0, [Object] ] ] }
custom_json
{ required_auths: [],
  required_posting_auths: [ 'bobokyaw' ],
  id: 'follow',
  json: '["follow",{"follower":"bobokyaw","following":"deathandtaxes","what":["blog"]}]' }
vote
{ voter: 'kangnajiang',
  author: 'htliao',
  permlink: 'anime-character-drawing-challenge-or-50-sbd-prize-pool-or-50-sbd',
  weight: 10000 }
vote
{ voter: 'dewnert',
  author: 'gauravchugh',
  permlink: 'sunday-sunset',
  weight: 10000 }
custom_json
{ required_auths: [],
  required_posting_auths: [ 'amalhermuz' ],
  id: 'follow',
  json: '["follow",{"follower":"amalhermuz","following":"samwicallis","what":["blog"]}]' }
custom_json
{ required_auths: [],
  required_posting_auths: [ 'izbing' ],
  id: 'follow',
  json: '["follow",{"follower":"izbing","following":"t3ran13","what":["blog"]}]' }
vote
{ voter: 'samaraj',
  author: 'olegst',
  permlink: 'photo-experiments-earth',
  weight: 10000 }
custom_json
{ required_auths: [],
  required_posting_auths: [ 'vevosongs' ],
  id: 'follow',
  json: '["follow",{"follower":"vevosongs","following":"kevingamboa","what":["blog"]}]' }
transfer
{ from: 'amat',
  to: 'krwhale',
  amount: '0.500 SBD',
  memo: 'https://steemit.com/tes/@jamilah/5qxkbm-tes#@amat/re-jamilah-5qxkbm-tes-20170903t130931771z' }
vote
{ voter: 'riofloder',
  author: 'fredinjapan64',
  permlink: 'the-battle-with-the-tongue-1503709521-7830422',
  weight: 10000 }

지금까지 10회에 걸쳐 node.js를 이용한 스팀봇 강좌를 진행하고 있습니다.

아낌없는 칭찬과 격려 부탁드립니다 ^^

Sort:  

Cheer Up! 음~? 흥미로운 포스팅이군요.

  • from Clean STEEM activity supporter

잘 읽고 있습니다.... 시간 잡아서 10회까지 본 거 그대로 해봐야되겠네요...

별로 어렵지 않아요. 구글에서 node.js 검색해서 설치한 다음에 커맨드창 열고 npm install steem 한번하고나서 예제코드 바로 다 실행되요 ^^

으아!! 정말 어렵지만 이해하면 엄청난 도움이 될수 있는 글인것 같아요 ㅜㅜ

저는 얼마전에 '엘리스 코딩유치원'이라는 강의를 듣다가 학교가 개강을 해버려서 유치원도 졸업못한 낙오자라서.. 이해가 어렵네요 ㅜㅜ

코딩은 '귀찮은 반복작업을 쉽게 해주는 마법상자 같은것'이라는 말을 들었었어요. 나중에 꼭 정독하고, 스팀봇도 이용해 보겠습니다!! 업보트하고 갑니다~!

지금까지는 스팀잇에서 동작하는 봇 만들기의 아주 작은 빌딩블럭들에 해당하는데, 실제 봇을 만들기 위해서는 javascript로 항상 실행중인 프로그램을 코딩해야 하는데 이 부분에 진입장벽이 클 것으로 예상되요.

앗...지금까지는 아주 일부분에 불과한 것이었군요... ㅠㅠ

꾸준한 포스팅 감사드립니다^^ 많은분들이 배워가실것 같습니다

와 능력자이시네요 좋은정보감사합니다.

진짜 능력자들은 다른데 있겠지만, 칭찬 감사합니다~^^

Coin Marketplace

STEEM 0.30
TRX 0.11
JST 0.033
BTC 64104.40
ETH 3148.52
USDT 1.00
SBD 4.25