Skip to content

Commit 1718258

Browse files
Add more examples
1 parent 97dbf81 commit 1718258

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

examples/send_message.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import sys
2+
import json
3+
import uuid
4+
import asyncio
5+
from pymixin.mixin_bot_api import MixinBotApi
6+
7+
#path to bot config
8+
bot_config_file = sys.argv[1]
9+
with open(bot_config_file, 'r') as f:
10+
bot_config = f.read()
11+
bot_config = json.loads(bot_config)
12+
13+
mixin_bot = MixinBotApi(bot_config)
14+
15+
user_id = 'e0148fc6-0e10-470e-8127-166e0829c839'
16+
asset_id = '965e5c6e-434c-3fa9-b780-c50f43cd955c' #(CNB)
17+
18+
async def run():
19+
conversation_id = '80f5c80c-e5b2-309e-ba18-196ff57d540f'
20+
21+
await mixin_bot.send_text_message(conversation_id, 'hello, world')
22+
23+
name = "jiayou"
24+
album_id = "fb0eea56-c09f-4372-8ff4-9799f15b0f03"
25+
sticker_id = "0083ea85-7d28-4d0e-8132-427b6c3c9507"
26+
await mixin_bot.send_sticker_message(conversation_id, name, album_id, sticker_id)
27+
28+
await mixin_bot.send_contract_message(conversation_id, user_id)
29+
30+
label = 'hello'
31+
color = "#d53120"
32+
action = 'https://mixin.one'
33+
await mixin_bot.send_button_group_message(conversation_id, label, color, action)
34+
35+
amount = 0.00000006
36+
trace_id = str(uuid.uuid1())
37+
label = 'pay fee'
38+
color = "#d53120"
39+
action = f"https://mixin.one/pay?recipient={bot_config['client_id']}&asset={asset_id}&amount={amount:.8f}&trace={trace_id}&memo=hello"
40+
print(action)
41+
await mixin_bot.send_button_group_message(conversation_id, label, color, action)
42+
43+
await mixin_bot.close()
44+
asyncio.run(run())

examples/transfer_to_user.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import json
2+
import uuid
3+
import asyncio
4+
from pymixin.mixin_bot_api import MixinBotApi
5+
6+
#path to bot config
7+
bot_config_file = 'test1.json'
8+
with open(bot_config_file, 'r') as f:
9+
bot_config = f.read()
10+
bot_config = json.loads(bot_config)
11+
12+
mixin_bot = MixinBotApi(bot_config)
13+
14+
user_id = 'e0148fc6-0e10-470e-8127-166e0829c839'
15+
asset_id = '965e5c6e-434c-3fa9-b780-c50f43cd955c' #(CNB)
16+
17+
async def run():
18+
r = await mixin_bot.transfer_to_user(user_id, asset_id, 0.00000006, 'hello')
19+
print(r)
20+
await mixin_bot.close()
21+
asyncio.run(run())

examples/transfer_to_users.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import json
2+
import uuid
3+
import asyncio
4+
from pymixin.mixin_bot_api import MixinBotApi
5+
6+
#path to bot config
7+
bot_config_file = 'test1.json'
8+
with open(bot_config_file, 'r') as f:
9+
bot_config = f.read()
10+
bot_config = json.loads(bot_config)
11+
12+
mixin_bot = MixinBotApi(bot_config)
13+
14+
user_id = 'e0148fc6-0e10-470e-8127-166e0829c839'
15+
asset_id = '965e5c6e-434c-3fa9-b780-c50f43cd955c' #(CNB)
16+
17+
async def run():
18+
user_ids = [
19+
"e07c06fa-084c-4ce1-b14a-66a9cb147b9e",
20+
"e0148fc6-0e10-470e-8127-166e0829c839",
21+
"18a62033-8845-455f-bcde-0e205ef4da44",
22+
"49b00892-6954-4826-aaec-371ca165558a"
23+
]
24+
#transfer to multisiged users
25+
r = await mixin_bot.transfer_to_users(user_ids, 3, asset_id, 0.00000006, 'hello')
26+
print(r)
27+
await mixin_bot.close()
28+
asyncio.run(run())

0 commit comments

Comments
 (0)