Code Monkey home page Code Monkey logo

serverless-reactor-starter's Introduction

Serverless Reactors 让你可以快速零成本地构建发布飞书机器人。

安装必要的软件

请确保您已经安装了Rust, 和ssvmup. 为了您的方便,下面是 Linux / Mac / PowerShell 的安装命令。

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
$ source $HOME/.cargo/env
$ rustup override set 1.50.0

$ curl https://raw.githubusercontent.com/second-state/ssvmup/master/installer/init.sh -sSf | sh

编写机器人逻辑

请 fork 这个代码仓库。默认的函数是一个计算器机器人,向它发一个“2+2”的消息,它就会回答“4”。

use wasm_bindgen::prelude::*;
use meval;

#[wasm_bindgen]
pub fn text_received(msg: String, _username: String, _step_data: String) -> String {
  let x = meval::eval_str(&msg).unwrap();
  return format!("{}", x);
}

改动 src/lib.rs 这个文件,将它改为你的机器人逻辑。具体函数的写法请参见文档

编译

将机器人的函数编译成可以部署的 WebAssembly 文件。

$ ssvmup build

部署

参见文档创建一个飞书企业应用与 Serverless Reactor 的对应 app,将编译成功的 pkg/calculator_lib_bg.wasm 文件上传到 Serverless Reactor,并把生成的 service URL 提交给飞书。

祝贺你!你现在有了一个属于你的飞书机器人!

serverless-reactor-starter's People

Contributors

juntao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.