# Golang 监听币安Websocket实现机器人自动推送消息

By [Robin](https://paragraph.com/@robin-8) · 2023-02-22

---

准备工作
----

*   注册一个企业微信、创建群聊、群设置里创建一个Bot机器人、记录下机器人的调用Webhook地址。
    
*   准备一个Golnag的开发环境
    

[https://mirror.xyz/0xa572762E9250899A3e6d2D99497e0D1dc39D2Ee1/ak3i-Tx-1IgtvXhHx2xmTFE0ORmHctDH\_i32K4E6E9E](https://mirror.xyz/0xa572762E9250899A3e6d2D99497e0D1dc39D2Ee1/ak3i-Tx-1IgtvXhHx2xmTFE0ORmHctDH_i32K4E6E9E)

代码地址
====

[https://github.com/robinwangrubin/BinanceAlart](https://github.com/robinwangrubin/BinanceAlart)

功能列表
====

*   发邮件通知
    
*   发企业微信消息通知
    
*   数据存储Influxdb中
    

效果截图
====

*   邮件通知
    

![](https://storage.googleapis.com/papyrus_images/0241e1cb822d9a2de4ca26fb46c4109ee565bc3a1bdc14e0e781f0fe4d4f37dc.jpg)

*   企业微信机器人通知
    

![](https://storage.googleapis.com/papyrus_images/8f3ee6978a608d205c094afd2a8d53f80373479507238db8c1632ef6d6dc1380.jpg)

*   Grafana展示Influxdb的数据
    

![](https://storage.googleapis.com/papyrus_images/b8d21ca3a7aee5aa5deb98b6df8e3cf06758ee1e83039aef7561b4e651295e8c.png)

你需要做什么
======

1.下载代码

    git clone git@github.com:robinwangrubin/BinanceAlart.git
    

2.修改配置文件

    [Bot]
    key = "YourWeChat Key"
    [Email]
    mailServer = "smtp.163.com"
    mailPort = 465
    maillUser = "YourEmailAddress@xxx.com"
    mailPass = "YourPassWord"
    toUserList = "SomeoneEmail@xxx.com","SomeoneEmail@xxx.com"
    

3.如果需要落盘写入Influxdb；则需要安装Influxdb1.8版本+Grafana展示；这里不在说明。

---

*Originally published on [Robin](https://paragraph.com/@robin-8/golang-websocket)*
