-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread.py
100 lines (85 loc) · 4.3 KB
/
read.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import sys
import os
import re
from datetime import datetime
logLine = sys.argv[1]
kbHandle = sys.argv[2]
tradeId = ""
msg = ""
# new trade
match = re.search( "TradeEvents.+We got a new trade", logLine )
if match is not None:
tail = logLine[ ( re.search( " id=", logLine ) ).end(0): ]
tradeId = tail[ 0:re.search( '-', tail ).start(0) ]
msg = "New Trade! ID: {tradeId}".format( tradeId = tradeId )
# deposit confirmed
match = re.search( "Set new state.+DEPOSIT_CONFIRMED_IN_BLOCK_CHAIN", logLine )
if match is not None:
tail = logLine[ ( re.search( " \(id=", logLine ) ).end(0): ]
tradeId = tail[ 0:re.search( '\)', tail ).start(0) ]
msg = "{tradeId}: Deposit tx Confirmed".format( tradeId = tradeId ) # datetime.now()
# buyer has started payment
match = re.search( "Set new state.+SELLER_RECEIVED_FIAT_PAYMENT_INITIATED_MSG", logLine )
if match is not None:
tail = logLine[ ( re.search( " \(id=", logLine ) ).end(0): ]
tradeId = tail[ 0:re.search( '\)', tail ).start(0) ]
msg = "{tradeId}: Buyer Made Payment".format( tradeId = tradeId )
# seller has received payment / trade complete
match = re.search( "Set new state.+BUYER_RECEIVED_PAYOUT_TX_PUBLISHED_MSG", logLine )
if match is not None:
tail = logLine[ ( re.search( " \(id=", logLine ) ).end(0): ]
tradeId = tail[ 0:re.search( '\)', tail ).start(0) ]
msg = "{tradeId}: Trade Complete".format( tradeId = tradeId )
# receive trader chat message
match = re.search( "TraderChatManager.+Received ChatMessage", logLine )
if match is not None:
tail = logLine[ ( re.search( " with tradeId ", logLine ) ).end(0): ]
tradeId = tail[ 0:re.search( '-', tail ).start(0) ]
msg = "{tradeId}: New Message (Trader Chat)".format( tradeId = tradeId )
# mediation opened
match = re.search( "MediationManager.+Received PeerOpenedDisputeMessage", logLine )
if match is not None:
tail = logLine[ ( re.search( " with tradeId ", logLine ) ).end(0): ]
tradeId = tail[ 0:re.search( '-', tail ).start(0) ]
msg = "{tradeId}: Mediation Opened".format( tradeId = tradeId )
# new mediation message
match = re.search( "MediationManager.+Received ChatMessage", logLine )
if match is not None:
tail = logLine[ ( re.search( " with tradeId ", logLine ) ).end(0): ]
tradeId = tail[ 0:re.search( '-', tail ).start(0) ]
msg = "{tradeId}: New Message (Mediation). Please respond quickly, within 48 hours at most.".format( tradeId = tradeId )
# receive mediation result
match = re.search( "MediationManager.+Received DisputeResultMessage", logLine )
if match is not None:
tail = logLine[ ( re.search( " with tradeId ", logLine ) ).end(0): ]
tradeId = tail[ 0:re.search( '-', tail ).start(0) ]
msg = "{tradeId}: Received Mediation Suggestion. Please accept or reject ASAP.".format( tradeId = tradeId )
# payout from mediation
match = re.search( "Received MediatedPayoutTxPublishedMessage", logLine )
if match is not None:
tail = logLine[ ( re.search( " with tradeId ", logLine ) ).end(0): ]
tradeId = tail[ 0:re.search( '-', tail ).start(0) ]
msg = "{tradeId}: Trade Complete (Mediation Payout Accepted)".format( tradeId = tradeId )
# arbitration opened
match = re.search( "RefundManager.+Received PeerOpenedDisputeMessage", logLine )
if match is not None:
tail = logLine[ ( re.search( " with tradeId ", logLine ) ).end(0): ]
tradeId = tail[ 0:re.search( '-', tail ).start(0) ]
msg = "{tradeId}: Arbitration Opened".format( tradeId = tradeId )
# new arbitration message
match = re.search( "RefundManager.+Received ChatMessage", logLine )
if match is not None:
tail = logLine[ ( re.search( " with tradeId ", logLine ) ).end(0): ]
tradeId = tail[ 0:re.search( '-', tail ).start(0) ]
msg = "{tradeId}: New Message (Arbitration). Please respond quickly, within 48 hours at most.".format( tradeId = tradeId )
# payout from arbitration
match = re.search( "RefundManager.+Received DisputeResultMessage", logLine )
if match is not None:
tail = logLine[ ( re.search( " with tradeId ", logLine ) ).end(0): ]
tradeId = tail[ 0:re.search( '-', tail ).start(0) ]
msg = "{tradeId}: Trade Complete (Arbitration Payout)".format( tradeId = tradeId )
if msg:
print( "{time} {msg}".format( time = datetime.now(), msg = msg ) )
os.system( "keybase chat send {kbHandle} \"{msg}\"".format( kbHandle = kbHandle, msg = msg ) )
# exit
sys.exit(0)