Skip to content

Commit 054ac03

Browse files
committed
multiString;appbuttongroup;appcard
1 parent de093e5 commit 054ac03

File tree

1 file changed

+52
-9
lines changed

1 file changed

+52
-9
lines changed

app2.js

+52-9
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,64 @@ client.on(
2525
var parameter4IncomingMsg = {"message_id":message.data.message_id, "status":"READ"};
2626
var RspMsg = {"id":client.getUUID(), "action":"ACKNOWLEDGE_MESSAGE_RECEIPT", "params":parameter4IncomingMsg};
2727
client.sendRaw(RspMsg);
28-
2928
if (text === 'pay') {
29+
var multiStr = ["usage: ",
30+
"pay: show this message",
31+
"pay1: send an APPBUTTONGROUP",
32+
"pay2: send one button",
33+
"pay3: send an APPCARD"].join("\n");
34+
return client.sendText(multiStr,message);
35+
}
36+
//buttons
37+
38+
if (text === 'pay1') {
39+
let payLinkEOS = "https://mixin.one/pay?recipient=" +
40+
config.clientId + "&asset=" +
41+
"6cfe566e-4aad-470b-8c9a-2fd35b49c68d" +
42+
"&amount=0.01" + '&trace=' + client.getUUID() +
43+
"&memo=";
44+
let payLinkBTC = "https://mixin.one/pay?recipient=" +
45+
config.clientId + "&asset=" +
46+
"c6d0c728-2624-429b-8e0d-d9d19b6592fa" +
47+
"&amount=0.01" + '&trace=' + client.getUUID() +
48+
"&memo=";
49+
return client.sendButtons([{
50+
label: 'pay 0.01 EOS',
51+
color: '#FF0000',
52+
action: payLinkEOS,
53+
},{
54+
label: 'pay 0.001 BTC',
55+
color: '#00ff00',
56+
action: payLinkBTC,
57+
}],message
58+
);
59+
}
60+
//button
61+
if (text === 'pay2') {
3062
let payLink = "https://mixin.one/pay?recipient=" +
3163
config.clientId + "&asset=" +
3264
"6cfe566e-4aad-470b-8c9a-2fd35b49c68d" +
3365
"&amount=0.01" + '&trace=' + client.getUUID() +
3466
"&memo=";
3567
return client.sendButton({
36-
label: 'pay 0.01 EOS',
37-
color: '#FF0000',
38-
action: payLink,
39-
},
40-
message
41-
);
68+
label: 'pay 0.01 EOS',
69+
color: '#FF0000',
70+
action: payLink,
71+
},message);
72+
}
73+
if (text === 'pay3') {
74+
let payLink = "https://mixin.one/pay?recipient=" +
75+
config.clientId + "&asset=" +
76+
"6cfe566e-4aad-470b-8c9a-2fd35b49c68d" +
77+
"&amount=0.01" + '&trace=' + client.getUUID() +
78+
"&memo=";
79+
return client.sendApp({
80+
icon_url: 'https://mixin.one/assets/98b586edb270556d1972112bd7985e9e.png',
81+
title: 'pay 0.01 EOS',
82+
description: '#FF0000',
83+
action: payLink,
84+
},message);
4285
}
43-
4486
// todo: catch a error when balance insufficient
4587
// (node:55535) UnhandledPromiseRejectionWarning: Error: Insufficient balance.
4688
// at HttpClient.(anonymous function) [as createTransfer] (/Users/wenewzhang/Documents/sl/mixin_network-nodejs-bot2/node_modules/mixin-node-client/lib/http.js:99:23)
@@ -51,7 +93,8 @@ client.on(
5193
return client.sendText( message.data.data, message);
5294
}
5395
}
54-
if (message.data && message.data.category === "SYSTEM_ACCOUNT_SNAPSHOT") {
96+
if (message.data && message.data.category === "SYSTEM_ACCOUNT_SNAPSHOT" &&
97+
message.action === 'CREATE_MESSAGE') {
5598
console.log("-----------the bot got money!---------------");
5699

57100
var jsData = JSON.parse(Buffer.from(message.data.data, 'base64').toString('utf-8'));

0 commit comments

Comments
 (0)