-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.py
41 lines (31 loc) · 900 Bytes
/
tests.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
from lzpush import LZPushHandler
access_key = ''
secret_key = ''
app_id = ''
matches = []
# Step 1. Call back functions
def on_match_update(card):
n = card['now']
if 'req' in n and 'runs' in n['req']:
print "%s - %s(%s)" % (n['runs_str'], n['req']['runs'], n['req']['balls'])
else:
print "%s" % (n['runs_str'])
# print "Got match update for", card['key'],
def on_past_ball_update(ball):
print "Got a ball update", ball
def on_event(name, *args):
print "Raised event %s with params %s" % (name, args)
# Step 2. Initialise handler
lzhandler = LZPushHandler(
access_key = access_key,
secret_key = secret_key,
app_id = app_id,
on_update = on_match_update,
on_past_ball_update = on_past_ball_update,
on_event = on_event
)
# Step 3. Listen matches
for match in matches:
lzhandler.listen_match(match)
# Step 4. Connect Litzscore push server
lzhandler.connect()