-
Notifications
You must be signed in to change notification settings - Fork 0
/
Steem_notify.py
60 lines (51 loc) · 1.43 KB
/
Steem_notify.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from piston.steem import Steem
from piston.account import Account
from RPLCD.i2c import CharLCD
import time
import RPi.GPIO as GPIO
import sys
# initialize Steem
account_name = 'guyverckw'
account = Account(account_name)
steem = Steem()
# initialize LCD
lcd = CharLCD('PCF8574', 0x3f)
# Clear LCD
print('Clear LCD')
# Prepare LED indicator
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT, initial=GPIO.LOW)
# Set user account, no. of history retrieve everytime, transaction ID buffer array of 10
first = 9999999999
limit = 5
History = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
History_ID = 1.0
message = ' '
# keep checking transactions
while True:
index = 0
print (History, History_ID)
# Get last 5 history, put ID into buffer array
for his in account.rawhistory(first, limit):
if History_ID == his[0]:
break
print('History ID: %d10.0' % History_ID)
print(his[1]['op'])
if his[1]['op'][0] == 'comment':
message = 'There is a comment from @' + his[1]['op'][1]['author']
elif his[1]['op'][0] == 'vote':
if his[1]['op'][1]['author'] == account_name:
message = 'There is a vote from @' + his[1]['op'][1]['voter'] + ' of ' + str(his[1]['op'][1]['weight']/100) +'%'
else:
History[index] = his[0]
index += 1
continue
History[index] = his[0]
index += 1
print (message)
GPIO.output(11, GPIO.HIGH)
lcd.clear()
lcd.write_string(message)
time.sleep(1)
GPIO.output(11, GPIO.LOW)
History_ID = History[0]