Home
Write
Language
Login
李安
@1051445
做个 Mixin 机器人:用机器人转账
做个Mixin机器人
2021-08-17 02:47
Words count: 3869
本文介绍如何使用 Mixin 机器人转账。

本系列的其他文章:

  • Mixin 机器人开发的基本知识
  • 做个 Mixin 机器人:flomo 机器人
  • 做个 Mixin 机器人:用机器人转账
  • 做个 Mixin 机器人:定投机器人
  • 做个 Mixin 机器人:在 Swap 上挂单

在上一篇文章,我们已经学会了用 Mixin 机器人收发消息。这次,我们来学习用 Mixin 机器人转账。

初始化项目

首先还是初始化一个新项目。

mkdir mixin-bot-example-transfer
cd mixin-bot-example-transfer
yarn init
yarn add [email protected]

配置好机器人,开始接收消息。

// 这是 Mixin 机器人的密钥信息,拥有这些信息就拥有了机器人的控制权。
// 如果不慎外泄,在 Mixin 开发者后台重新生成一次即可,旧的会被覆盖
const CLIENT_CONFIG = {
// ...
};

// 引入 SDK
const { MixinSocket } = require("mixin-node-sdk");

// 用机器人的配置信息新建 webSocket 的实例
const socketClient = new MixinSocket(CLIENT_CONFIG, true, true);

// 告诉机器人收到消息之后做点啥
socketClient.get_message_handler = async function (message) {
  // 忽略一些无关的消息
  if (
    !message.action ||
    message.action === "ACKNOWLEDGE_MESSAGE_RECEIPT" ||
    message.action === "LIST_PENDING_MESSAGES" ||
    !message.data ||
    !message.data.data
  ) {
    return;
  }
  // 如果消息解析有错误,把错误打印出来
  if (message.error) return console.log(message.error);

  // 把收到消息打印出来
  console.log(message);

  // 告诉对方消息收到了(消息变双勾)
  await this.read_message(message);
};

socketClient.start();
- 90.0 % More to go -
Pay 0.000020 BTC (≈$2.4364) to continue reading
and receive early reader revenue (Rules)
This post is a virtural product selling on Quill, IT WILL NOT REFUND once paid. Please pay with caution.
Pay to Read
Already paid? Try to Login
6 0
48 times bought
•
0 times reward
Comments 3
李安
@1051445
Subscribing: 31 Subscribers: 449
Founder of Quill
Subscribe
References
做个 Mixin 机器人:flomo 机器人
5.0%
Mixin 机器人开发的基本知识
5.0%
Related Posts
我和绝世好女友的故事《做个Mixin机器人:用机器人转账》
Rules Stats Help Github Twitter Discord

Login

Read, write, and earn crypto rewards.

Connect Wallet
李安
@1051445
Subscribing: 31 Subscribers: 449
Founder of Quill
Subscribe
References
做个 Mixin 机器人:flomo 机器人
5.0%
Mixin 机器人开发的基本知识
5.0%
Related Posts
我和绝世好女友的故事《做个Mixin机器人:用机器人转账》
Rules Stats Help Github Twitter Discord