forked from holgern/beem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_votes.py
29 lines (25 loc) · 846 Bytes
/
print_votes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from __future__ import print_function
import sys
from datetime import timedelta
import time
import io
from beem.blockchain import Blockchain
from beem.utils import parse_time
import logging
log = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
class DemoBot(object):
def vote(self, vote_event):
w = vote_event["weight"]
if w > 0:
print("Vote by", vote_event["voter"], "for", vote_event["author"])
else:
if w < 0:
print("Downvote by", vote_event["voter"], "for", vote_event["author"])
else:
print("(Down)vote by", vote_event["voter"], "for", vote_event["author"], "CANCELED")
if __name__ == "__main__":
tb = DemoBot()
blockchain = Blockchain()
for vote in blockchain.stream(opNames=["vote"]):
tb.vote(vote)