Add Node.js client
This commit is contained in:
parent
41f73ec8c3
commit
64e9e812e9
BIN
nodejs/TEQuant.jpeg
Executable file
BIN
nodejs/TEQuant.jpeg
Executable file
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
45
nodejs/package.json
Executable file
45
nodejs/package.json
Executable file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "WeChatFerryNodejs",
|
||||
"version": "1.0.0",
|
||||
"description": "WeChatFerry nodejs demo",
|
||||
"main": "./src/index.ts",
|
||||
"author": "radiocom@qq.com",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"prebuild": "eslint --fix src",
|
||||
"start": "npx ts-node src/index.ts",
|
||||
"proto:build": "npx grpc_tools_node_protoc --js_out=import_style=commonjs,binary:./proto/ --grpc_out=./proto/ --plugin=protoc-gen-grpc=\"node_modules/grpc-tools/bin/grpc_node_plugin.exe\" --proto_path=./proto wcf.proto",
|
||||
"proto:types": ".\\node_modules\\grpc-tools\\bin\\protoc.exe --plugin=protoc-gen-ts=\".\\node_modules\\.bin\\protoc-gen-ts.cmd\" --ts_out=./proto/ -I ./proto wcf.proto"
|
||||
},
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.7.2",
|
||||
"ffi-decorators": "^0.4.0",
|
||||
"ffi-napi": "^4.0.3",
|
||||
"grpc": "^1.24.11",
|
||||
"net": "^1.0.2",
|
||||
"readline": "^1.3.0",
|
||||
"ref-napi": "^3.0.3",
|
||||
"ref-struct-di": "^1.1.1",
|
||||
"ref-union-di": "^1.0.1",
|
||||
"stock-api": "^2.0.5",
|
||||
"tslog": "^3.3.4",
|
||||
"typed-emitter": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ffi-napi": "^4.0.6",
|
||||
"@types/node": "^18.11.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
||||
"@typescript-eslint/parser": "^5.40.1",
|
||||
"eslint": "^8.25.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-header": "^3.1.1",
|
||||
"eslint-plugin-import": "^2.26.0",
|
||||
"eslint-plugin-unused-imports": "^2.0.0",
|
||||
"grpc-tools": "^1.11.3",
|
||||
"grpc_tools_node_protoc_ts": "^5.3.2",
|
||||
"prettier": "^2.7.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"tslib": "^2.4.0",
|
||||
"typescript": "^4.8.4"
|
||||
}
|
||||
}
|
7
nodejs/prettier.config.js
Executable file
7
nodejs/prettier.config.js
Executable file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
tabWidth: 2,
|
||||
singleQuote: true,
|
||||
printWidth: 120,
|
||||
endOfLine: 'lf',
|
||||
};
|
||||
|
8
nodejs/proto/index.js
Executable file
8
nodejs/proto/index.js
Executable file
@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.protoIndex = void 0;
|
||||
require("./wcf_grpc_pb");
|
||||
require("./wcf_pb");
|
||||
const protoIndex = () => {
|
||||
};
|
||||
exports.protoIndex = protoIndex;
|
5
nodejs/proto/index.ts
Executable file
5
nodejs/proto/index.ts
Executable file
@ -0,0 +1,5 @@
|
||||
import './wcf_grpc_pb';
|
||||
import './wcf_pb';
|
||||
|
||||
export const protoIndex:any = ():void => {
|
||||
};
|
88
nodejs/proto/wcf.proto
Executable file
88
nodejs/proto/wcf.proto
Executable file
@ -0,0 +1,88 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package wcf;
|
||||
option java_package = "com.iamteer.wcf";
|
||||
|
||||
service Wcf {
|
||||
rpc RpcIsLogin(Empty) returns (Response) {}
|
||||
rpc RpcGetSelfWxid(Empty) returns (String) {}
|
||||
rpc RpcEnableRecvMsg(Empty) returns (stream WxMsg) {}
|
||||
rpc RpcDisableRecvMsg(Empty) returns (Response) {}
|
||||
rpc RpcSendTextMsg(TextMsg) returns (Response) {}
|
||||
rpc RpcSendImageMsg(ImageMsg) returns (Response) {}
|
||||
rpc RpcGetMsgTypes(Empty) returns (MsgTypes) {}
|
||||
rpc RpcGetContacts(Empty) returns (Contacts) {}
|
||||
rpc RpcGetDbNames(Empty) returns (DbNames) {}
|
||||
rpc RpcGetDbTables(String) returns (DbTables) {}
|
||||
rpc RpcExecDbQuery(DbQuery) returns (DbRows) {}
|
||||
rpc RpcAcceptNewFriend(Verification) returns (Response) {}
|
||||
}
|
||||
|
||||
message Empty {}
|
||||
|
||||
message WxMsg {
|
||||
bool is_self = 1; // 是否自己发送的
|
||||
bool is_group = 2; // 是否群消息
|
||||
int32 type = 3; // 消息类型
|
||||
string id = 4; // 消息 id
|
||||
string xml = 5; // 消息 xml
|
||||
string sender = 6; // 消息发送者
|
||||
string roomid = 7; // 群 id(如果是群消息的话)
|
||||
string content = 8; // 消息内容
|
||||
}
|
||||
|
||||
message Response {
|
||||
int32 status = 1; // 状态码
|
||||
}
|
||||
|
||||
message TextMsg {
|
||||
string msg = 1; // 要发送的消息内容
|
||||
string receiver = 2; // 消息接收人,当为群时可@
|
||||
string aters = 3; // 要@的人列表,逗号分隔
|
||||
}
|
||||
|
||||
message ImageMsg {
|
||||
string path = 1; // 要发送的图片的路径
|
||||
string receiver = 2; // 消息接收人
|
||||
}
|
||||
|
||||
message MsgTypes { map<int32, string> types = 1; }
|
||||
|
||||
message Contact {
|
||||
string wxid = 1; // 微信 id
|
||||
string code = 2; // 微信号
|
||||
string name = 3; // 微信昵称
|
||||
string country = 4; // 国家
|
||||
string province = 5; // 省/州
|
||||
string city = 6; // 城市
|
||||
int32 gender = 7; // 性别
|
||||
}
|
||||
message Contacts { repeated Contact contacts = 1; }
|
||||
|
||||
message DbNames { repeated string names = 1; }
|
||||
|
||||
message String { string str = 1; }
|
||||
|
||||
message DbTable {
|
||||
string name = 1; // 表名
|
||||
string sql = 2; // 建表 SQL
|
||||
}
|
||||
message DbTables { repeated DbTable tables = 1; }
|
||||
|
||||
message DbQuery {
|
||||
string db = 1; // 目标数据库
|
||||
string sql = 2; // 查询 SQL
|
||||
}
|
||||
|
||||
message DbField {
|
||||
int32 type = 1; // 字段类型
|
||||
string column = 2; // 字段名称
|
||||
bytes content = 3; // 字段内容
|
||||
}
|
||||
message DbRow { repeated DbField fields = 1; }
|
||||
message DbRows { repeated DbRow rows = 1; }
|
||||
|
||||
message Verification {
|
||||
string v3 = 1;
|
||||
string v4 = 2;
|
||||
}
|
226
nodejs/proto/wcf_grpc_pb.d.ts
vendored
Executable file
226
nodejs/proto/wcf_grpc_pb.d.ts
vendored
Executable file
@ -0,0 +1,226 @@
|
||||
// package: wcf
|
||||
// file: wcf.proto
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
import * as grpc from "grpc";
|
||||
import * as wcf_pb from "./wcf_pb";
|
||||
|
||||
interface IWcfService extends grpc.ServiceDefinition<grpc.UntypedServiceImplementation> {
|
||||
rpcIsLogin: IWcfService_IRpcIsLogin;
|
||||
rpcGetSelfWxid: IWcfService_IRpcGetSelfWxid;
|
||||
rpcEnableRecvMsg: IWcfService_IRpcEnableRecvMsg;
|
||||
rpcDisableRecvMsg: IWcfService_IRpcDisableRecvMsg;
|
||||
rpcSendTextMsg: IWcfService_IRpcSendTextMsg;
|
||||
rpcSendImageMsg: IWcfService_IRpcSendImageMsg;
|
||||
rpcGetMsgTypes: IWcfService_IRpcGetMsgTypes;
|
||||
rpcGetContacts: IWcfService_IRpcGetContacts;
|
||||
rpcGetDbNames: IWcfService_IRpcGetDbNames;
|
||||
rpcGetDbTables: IWcfService_IRpcGetDbTables;
|
||||
rpcExecDbQuery: IWcfService_IRpcExecDbQuery;
|
||||
rpcAcceptNewFriend: IWcfService_IRpcAcceptNewFriend;
|
||||
}
|
||||
|
||||
interface IWcfService_IRpcIsLogin extends grpc.MethodDefinition<wcf_pb.Empty, wcf_pb.Response> {
|
||||
path: "/wcf.Wcf/RpcIsLogin";
|
||||
requestStream: false;
|
||||
responseStream: false;
|
||||
requestSerialize: grpc.serialize<wcf_pb.Empty>;
|
||||
requestDeserialize: grpc.deserialize<wcf_pb.Empty>;
|
||||
responseSerialize: grpc.serialize<wcf_pb.Response>;
|
||||
responseDeserialize: grpc.deserialize<wcf_pb.Response>;
|
||||
}
|
||||
interface IWcfService_IRpcGetSelfWxid extends grpc.MethodDefinition<wcf_pb.Empty, wcf_pb.String> {
|
||||
path: "/wcf.Wcf/RpcGetSelfWxid";
|
||||
requestStream: false;
|
||||
responseStream: false;
|
||||
requestSerialize: grpc.serialize<wcf_pb.Empty>;
|
||||
requestDeserialize: grpc.deserialize<wcf_pb.Empty>;
|
||||
responseSerialize: grpc.serialize<wcf_pb.String>;
|
||||
responseDeserialize: grpc.deserialize<wcf_pb.String>;
|
||||
}
|
||||
interface IWcfService_IRpcEnableRecvMsg extends grpc.MethodDefinition<wcf_pb.Empty, wcf_pb.WxMsg> {
|
||||
path: "/wcf.Wcf/RpcEnableRecvMsg";
|
||||
requestStream: false;
|
||||
responseStream: true;
|
||||
requestSerialize: grpc.serialize<wcf_pb.Empty>;
|
||||
requestDeserialize: grpc.deserialize<wcf_pb.Empty>;
|
||||
responseSerialize: grpc.serialize<wcf_pb.WxMsg>;
|
||||
responseDeserialize: grpc.deserialize<wcf_pb.WxMsg>;
|
||||
}
|
||||
interface IWcfService_IRpcDisableRecvMsg extends grpc.MethodDefinition<wcf_pb.Empty, wcf_pb.Response> {
|
||||
path: "/wcf.Wcf/RpcDisableRecvMsg";
|
||||
requestStream: false;
|
||||
responseStream: false;
|
||||
requestSerialize: grpc.serialize<wcf_pb.Empty>;
|
||||
requestDeserialize: grpc.deserialize<wcf_pb.Empty>;
|
||||
responseSerialize: grpc.serialize<wcf_pb.Response>;
|
||||
responseDeserialize: grpc.deserialize<wcf_pb.Response>;
|
||||
}
|
||||
interface IWcfService_IRpcSendTextMsg extends grpc.MethodDefinition<wcf_pb.TextMsg, wcf_pb.Response> {
|
||||
path: "/wcf.Wcf/RpcSendTextMsg";
|
||||
requestStream: false;
|
||||
responseStream: false;
|
||||
requestSerialize: grpc.serialize<wcf_pb.TextMsg>;
|
||||
requestDeserialize: grpc.deserialize<wcf_pb.TextMsg>;
|
||||
responseSerialize: grpc.serialize<wcf_pb.Response>;
|
||||
responseDeserialize: grpc.deserialize<wcf_pb.Response>;
|
||||
}
|
||||
interface IWcfService_IRpcSendImageMsg extends grpc.MethodDefinition<wcf_pb.ImageMsg, wcf_pb.Response> {
|
||||
path: "/wcf.Wcf/RpcSendImageMsg";
|
||||
requestStream: false;
|
||||
responseStream: false;
|
||||
requestSerialize: grpc.serialize<wcf_pb.ImageMsg>;
|
||||
requestDeserialize: grpc.deserialize<wcf_pb.ImageMsg>;
|
||||
responseSerialize: grpc.serialize<wcf_pb.Response>;
|
||||
responseDeserialize: grpc.deserialize<wcf_pb.Response>;
|
||||
}
|
||||
interface IWcfService_IRpcGetMsgTypes extends grpc.MethodDefinition<wcf_pb.Empty, wcf_pb.MsgTypes> {
|
||||
path: "/wcf.Wcf/RpcGetMsgTypes";
|
||||
requestStream: false;
|
||||
responseStream: false;
|
||||
requestSerialize: grpc.serialize<wcf_pb.Empty>;
|
||||
requestDeserialize: grpc.deserialize<wcf_pb.Empty>;
|
||||
responseSerialize: grpc.serialize<wcf_pb.MsgTypes>;
|
||||
responseDeserialize: grpc.deserialize<wcf_pb.MsgTypes>;
|
||||
}
|
||||
interface IWcfService_IRpcGetContacts extends grpc.MethodDefinition<wcf_pb.Empty, wcf_pb.Contacts> {
|
||||
path: "/wcf.Wcf/RpcGetContacts";
|
||||
requestStream: false;
|
||||
responseStream: false;
|
||||
requestSerialize: grpc.serialize<wcf_pb.Empty>;
|
||||
requestDeserialize: grpc.deserialize<wcf_pb.Empty>;
|
||||
responseSerialize: grpc.serialize<wcf_pb.Contacts>;
|
||||
responseDeserialize: grpc.deserialize<wcf_pb.Contacts>;
|
||||
}
|
||||
interface IWcfService_IRpcGetDbNames extends grpc.MethodDefinition<wcf_pb.Empty, wcf_pb.DbNames> {
|
||||
path: "/wcf.Wcf/RpcGetDbNames";
|
||||
requestStream: false;
|
||||
responseStream: false;
|
||||
requestSerialize: grpc.serialize<wcf_pb.Empty>;
|
||||
requestDeserialize: grpc.deserialize<wcf_pb.Empty>;
|
||||
responseSerialize: grpc.serialize<wcf_pb.DbNames>;
|
||||
responseDeserialize: grpc.deserialize<wcf_pb.DbNames>;
|
||||
}
|
||||
interface IWcfService_IRpcGetDbTables extends grpc.MethodDefinition<wcf_pb.String, wcf_pb.DbTables> {
|
||||
path: "/wcf.Wcf/RpcGetDbTables";
|
||||
requestStream: false;
|
||||
responseStream: false;
|
||||
requestSerialize: grpc.serialize<wcf_pb.String>;
|
||||
requestDeserialize: grpc.deserialize<wcf_pb.String>;
|
||||
responseSerialize: grpc.serialize<wcf_pb.DbTables>;
|
||||
responseDeserialize: grpc.deserialize<wcf_pb.DbTables>;
|
||||
}
|
||||
interface IWcfService_IRpcExecDbQuery extends grpc.MethodDefinition<wcf_pb.DbQuery, wcf_pb.DbRows> {
|
||||
path: "/wcf.Wcf/RpcExecDbQuery";
|
||||
requestStream: false;
|
||||
responseStream: false;
|
||||
requestSerialize: grpc.serialize<wcf_pb.DbQuery>;
|
||||
requestDeserialize: grpc.deserialize<wcf_pb.DbQuery>;
|
||||
responseSerialize: grpc.serialize<wcf_pb.DbRows>;
|
||||
responseDeserialize: grpc.deserialize<wcf_pb.DbRows>;
|
||||
}
|
||||
interface IWcfService_IRpcAcceptNewFriend extends grpc.MethodDefinition<wcf_pb.Verification, wcf_pb.Response> {
|
||||
path: "/wcf.Wcf/RpcAcceptNewFriend";
|
||||
requestStream: false;
|
||||
responseStream: false;
|
||||
requestSerialize: grpc.serialize<wcf_pb.Verification>;
|
||||
requestDeserialize: grpc.deserialize<wcf_pb.Verification>;
|
||||
responseSerialize: grpc.serialize<wcf_pb.Response>;
|
||||
responseDeserialize: grpc.deserialize<wcf_pb.Response>;
|
||||
}
|
||||
|
||||
export const WcfService: IWcfService;
|
||||
|
||||
export interface IWcfServer {
|
||||
rpcIsLogin: grpc.handleUnaryCall<wcf_pb.Empty, wcf_pb.Response>;
|
||||
rpcGetSelfWxid: grpc.handleUnaryCall<wcf_pb.Empty, wcf_pb.String>;
|
||||
rpcEnableRecvMsg: grpc.handleServerStreamingCall<wcf_pb.Empty, wcf_pb.WxMsg>;
|
||||
rpcDisableRecvMsg: grpc.handleUnaryCall<wcf_pb.Empty, wcf_pb.Response>;
|
||||
rpcSendTextMsg: grpc.handleUnaryCall<wcf_pb.TextMsg, wcf_pb.Response>;
|
||||
rpcSendImageMsg: grpc.handleUnaryCall<wcf_pb.ImageMsg, wcf_pb.Response>;
|
||||
rpcGetMsgTypes: grpc.handleUnaryCall<wcf_pb.Empty, wcf_pb.MsgTypes>;
|
||||
rpcGetContacts: grpc.handleUnaryCall<wcf_pb.Empty, wcf_pb.Contacts>;
|
||||
rpcGetDbNames: grpc.handleUnaryCall<wcf_pb.Empty, wcf_pb.DbNames>;
|
||||
rpcGetDbTables: grpc.handleUnaryCall<wcf_pb.String, wcf_pb.DbTables>;
|
||||
rpcExecDbQuery: grpc.handleUnaryCall<wcf_pb.DbQuery, wcf_pb.DbRows>;
|
||||
rpcAcceptNewFriend: grpc.handleUnaryCall<wcf_pb.Verification, wcf_pb.Response>;
|
||||
}
|
||||
|
||||
export interface IWcfClient {
|
||||
rpcIsLogin(request: wcf_pb.Empty, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcIsLogin(request: wcf_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcIsLogin(request: wcf_pb.Empty, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcGetSelfWxid(request: wcf_pb.Empty, callback: (error: grpc.ServiceError | null, response: wcf_pb.String) => void): grpc.ClientUnaryCall;
|
||||
rpcGetSelfWxid(request: wcf_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.String) => void): grpc.ClientUnaryCall;
|
||||
rpcGetSelfWxid(request: wcf_pb.Empty, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.String) => void): grpc.ClientUnaryCall;
|
||||
rpcEnableRecvMsg(request: wcf_pb.Empty, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<wcf_pb.WxMsg>;
|
||||
rpcEnableRecvMsg(request: wcf_pb.Empty, metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<wcf_pb.WxMsg>;
|
||||
rpcDisableRecvMsg(request: wcf_pb.Empty, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcDisableRecvMsg(request: wcf_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcDisableRecvMsg(request: wcf_pb.Empty, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcSendTextMsg(request: wcf_pb.TextMsg, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcSendTextMsg(request: wcf_pb.TextMsg, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcSendTextMsg(request: wcf_pb.TextMsg, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcSendImageMsg(request: wcf_pb.ImageMsg, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcSendImageMsg(request: wcf_pb.ImageMsg, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcSendImageMsg(request: wcf_pb.ImageMsg, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcGetMsgTypes(request: wcf_pb.Empty, callback: (error: grpc.ServiceError | null, response: wcf_pb.MsgTypes) => void): grpc.ClientUnaryCall;
|
||||
rpcGetMsgTypes(request: wcf_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.MsgTypes) => void): grpc.ClientUnaryCall;
|
||||
rpcGetMsgTypes(request: wcf_pb.Empty, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.MsgTypes) => void): grpc.ClientUnaryCall;
|
||||
rpcGetContacts(request: wcf_pb.Empty, callback: (error: grpc.ServiceError | null, response: wcf_pb.Contacts) => void): grpc.ClientUnaryCall;
|
||||
rpcGetContacts(request: wcf_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.Contacts) => void): grpc.ClientUnaryCall;
|
||||
rpcGetContacts(request: wcf_pb.Empty, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.Contacts) => void): grpc.ClientUnaryCall;
|
||||
rpcGetDbNames(request: wcf_pb.Empty, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbNames) => void): grpc.ClientUnaryCall;
|
||||
rpcGetDbNames(request: wcf_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbNames) => void): grpc.ClientUnaryCall;
|
||||
rpcGetDbNames(request: wcf_pb.Empty, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbNames) => void): grpc.ClientUnaryCall;
|
||||
rpcGetDbTables(request: wcf_pb.String, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbTables) => void): grpc.ClientUnaryCall;
|
||||
rpcGetDbTables(request: wcf_pb.String, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbTables) => void): grpc.ClientUnaryCall;
|
||||
rpcGetDbTables(request: wcf_pb.String, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbTables) => void): grpc.ClientUnaryCall;
|
||||
rpcExecDbQuery(request: wcf_pb.DbQuery, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbRows) => void): grpc.ClientUnaryCall;
|
||||
rpcExecDbQuery(request: wcf_pb.DbQuery, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbRows) => void): grpc.ClientUnaryCall;
|
||||
rpcExecDbQuery(request: wcf_pb.DbQuery, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbRows) => void): grpc.ClientUnaryCall;
|
||||
rpcAcceptNewFriend(request: wcf_pb.Verification, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcAcceptNewFriend(request: wcf_pb.Verification, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
rpcAcceptNewFriend(request: wcf_pb.Verification, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
}
|
||||
|
||||
export class WcfClient extends grpc.Client implements IWcfClient {
|
||||
constructor(address: string, credentials: grpc.ChannelCredentials, options?: object);
|
||||
public rpcIsLogin(request: wcf_pb.Empty, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcIsLogin(request: wcf_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcIsLogin(request: wcf_pb.Empty, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetSelfWxid(request: wcf_pb.Empty, callback: (error: grpc.ServiceError | null, response: wcf_pb.String) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetSelfWxid(request: wcf_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.String) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetSelfWxid(request: wcf_pb.Empty, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.String) => void): grpc.ClientUnaryCall;
|
||||
public rpcEnableRecvMsg(request: wcf_pb.Empty, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<wcf_pb.WxMsg>;
|
||||
public rpcEnableRecvMsg(request: wcf_pb.Empty, metadata?: grpc.Metadata, options?: Partial<grpc.CallOptions>): grpc.ClientReadableStream<wcf_pb.WxMsg>;
|
||||
public rpcDisableRecvMsg(request: wcf_pb.Empty, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcDisableRecvMsg(request: wcf_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcDisableRecvMsg(request: wcf_pb.Empty, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcSendTextMsg(request: wcf_pb.TextMsg, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcSendTextMsg(request: wcf_pb.TextMsg, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcSendTextMsg(request: wcf_pb.TextMsg, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcSendImageMsg(request: wcf_pb.ImageMsg, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcSendImageMsg(request: wcf_pb.ImageMsg, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcSendImageMsg(request: wcf_pb.ImageMsg, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetMsgTypes(request: wcf_pb.Empty, callback: (error: grpc.ServiceError | null, response: wcf_pb.MsgTypes) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetMsgTypes(request: wcf_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.MsgTypes) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetMsgTypes(request: wcf_pb.Empty, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.MsgTypes) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetContacts(request: wcf_pb.Empty, callback: (error: grpc.ServiceError | null, response: wcf_pb.Contacts) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetContacts(request: wcf_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.Contacts) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetContacts(request: wcf_pb.Empty, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.Contacts) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetDbNames(request: wcf_pb.Empty, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbNames) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetDbNames(request: wcf_pb.Empty, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbNames) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetDbNames(request: wcf_pb.Empty, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbNames) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetDbTables(request: wcf_pb.String, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbTables) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetDbTables(request: wcf_pb.String, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbTables) => void): grpc.ClientUnaryCall;
|
||||
public rpcGetDbTables(request: wcf_pb.String, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbTables) => void): grpc.ClientUnaryCall;
|
||||
public rpcExecDbQuery(request: wcf_pb.DbQuery, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbRows) => void): grpc.ClientUnaryCall;
|
||||
public rpcExecDbQuery(request: wcf_pb.DbQuery, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbRows) => void): grpc.ClientUnaryCall;
|
||||
public rpcExecDbQuery(request: wcf_pb.DbQuery, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.DbRows) => void): grpc.ClientUnaryCall;
|
||||
public rpcAcceptNewFriend(request: wcf_pb.Verification, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcAcceptNewFriend(request: wcf_pb.Verification, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
public rpcAcceptNewFriend(request: wcf_pb.Verification, metadata: grpc.Metadata, options: Partial<grpc.CallOptions>, callback: (error: grpc.ServiceError | null, response: wcf_pb.Response) => void): grpc.ClientUnaryCall;
|
||||
}
|
286
nodejs/proto/wcf_grpc_pb.js
Executable file
286
nodejs/proto/wcf_grpc_pb.js
Executable file
@ -0,0 +1,286 @@
|
||||
// GENERATED CODE -- DO NOT EDIT!
|
||||
|
||||
'use strict';
|
||||
var grpc = require('grpc');
|
||||
var wcf_pb = require('./wcf_pb.js');
|
||||
|
||||
function serialize_wcf_Contacts(arg) {
|
||||
if (!(arg instanceof wcf_pb.Contacts)) {
|
||||
throw new Error('Expected argument of type wcf.Contacts');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_Contacts(buffer_arg) {
|
||||
return wcf_pb.Contacts.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_wcf_DbNames(arg) {
|
||||
if (!(arg instanceof wcf_pb.DbNames)) {
|
||||
throw new Error('Expected argument of type wcf.DbNames');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_DbNames(buffer_arg) {
|
||||
return wcf_pb.DbNames.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_wcf_DbQuery(arg) {
|
||||
if (!(arg instanceof wcf_pb.DbQuery)) {
|
||||
throw new Error('Expected argument of type wcf.DbQuery');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_DbQuery(buffer_arg) {
|
||||
return wcf_pb.DbQuery.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_wcf_DbRows(arg) {
|
||||
if (!(arg instanceof wcf_pb.DbRows)) {
|
||||
throw new Error('Expected argument of type wcf.DbRows');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_DbRows(buffer_arg) {
|
||||
return wcf_pb.DbRows.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_wcf_DbTables(arg) {
|
||||
if (!(arg instanceof wcf_pb.DbTables)) {
|
||||
throw new Error('Expected argument of type wcf.DbTables');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_DbTables(buffer_arg) {
|
||||
return wcf_pb.DbTables.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_wcf_Empty(arg) {
|
||||
if (!(arg instanceof wcf_pb.Empty)) {
|
||||
throw new Error('Expected argument of type wcf.Empty');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_Empty(buffer_arg) {
|
||||
return wcf_pb.Empty.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_wcf_ImageMsg(arg) {
|
||||
if (!(arg instanceof wcf_pb.ImageMsg)) {
|
||||
throw new Error('Expected argument of type wcf.ImageMsg');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_ImageMsg(buffer_arg) {
|
||||
return wcf_pb.ImageMsg.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_wcf_MsgTypes(arg) {
|
||||
if (!(arg instanceof wcf_pb.MsgTypes)) {
|
||||
throw new Error('Expected argument of type wcf.MsgTypes');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_MsgTypes(buffer_arg) {
|
||||
return wcf_pb.MsgTypes.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_wcf_Response(arg) {
|
||||
if (!(arg instanceof wcf_pb.Response)) {
|
||||
throw new Error('Expected argument of type wcf.Response');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_Response(buffer_arg) {
|
||||
return wcf_pb.Response.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_wcf_String(arg) {
|
||||
if (!(arg instanceof wcf_pb.String)) {
|
||||
throw new Error('Expected argument of type wcf.String');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_String(buffer_arg) {
|
||||
return wcf_pb.String.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_wcf_TextMsg(arg) {
|
||||
if (!(arg instanceof wcf_pb.TextMsg)) {
|
||||
throw new Error('Expected argument of type wcf.TextMsg');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_TextMsg(buffer_arg) {
|
||||
return wcf_pb.TextMsg.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_wcf_Verification(arg) {
|
||||
if (!(arg instanceof wcf_pb.Verification)) {
|
||||
throw new Error('Expected argument of type wcf.Verification');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_Verification(buffer_arg) {
|
||||
return wcf_pb.Verification.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_wcf_WxMsg(arg) {
|
||||
if (!(arg instanceof wcf_pb.WxMsg)) {
|
||||
throw new Error('Expected argument of type wcf.WxMsg');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_wcf_WxMsg(buffer_arg) {
|
||||
return wcf_pb.WxMsg.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
|
||||
var WcfService = exports.WcfService = {
|
||||
rpcIsLogin: {
|
||||
path: '/wcf.Wcf/RpcIsLogin',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: wcf_pb.Empty,
|
||||
responseType: wcf_pb.Response,
|
||||
requestSerialize: serialize_wcf_Empty,
|
||||
requestDeserialize: deserialize_wcf_Empty,
|
||||
responseSerialize: serialize_wcf_Response,
|
||||
responseDeserialize: deserialize_wcf_Response,
|
||||
},
|
||||
rpcGetSelfWxid: {
|
||||
path: '/wcf.Wcf/RpcGetSelfWxid',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: wcf_pb.Empty,
|
||||
responseType: wcf_pb.String,
|
||||
requestSerialize: serialize_wcf_Empty,
|
||||
requestDeserialize: deserialize_wcf_Empty,
|
||||
responseSerialize: serialize_wcf_String,
|
||||
responseDeserialize: deserialize_wcf_String,
|
||||
},
|
||||
rpcEnableRecvMsg: {
|
||||
path: '/wcf.Wcf/RpcEnableRecvMsg',
|
||||
requestStream: false,
|
||||
responseStream: true,
|
||||
requestType: wcf_pb.Empty,
|
||||
responseType: wcf_pb.WxMsg,
|
||||
requestSerialize: serialize_wcf_Empty,
|
||||
requestDeserialize: deserialize_wcf_Empty,
|
||||
responseSerialize: serialize_wcf_WxMsg,
|
||||
responseDeserialize: deserialize_wcf_WxMsg,
|
||||
},
|
||||
rpcDisableRecvMsg: {
|
||||
path: '/wcf.Wcf/RpcDisableRecvMsg',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: wcf_pb.Empty,
|
||||
responseType: wcf_pb.Response,
|
||||
requestSerialize: serialize_wcf_Empty,
|
||||
requestDeserialize: deserialize_wcf_Empty,
|
||||
responseSerialize: serialize_wcf_Response,
|
||||
responseDeserialize: deserialize_wcf_Response,
|
||||
},
|
||||
rpcSendTextMsg: {
|
||||
path: '/wcf.Wcf/RpcSendTextMsg',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: wcf_pb.TextMsg,
|
||||
responseType: wcf_pb.Response,
|
||||
requestSerialize: serialize_wcf_TextMsg,
|
||||
requestDeserialize: deserialize_wcf_TextMsg,
|
||||
responseSerialize: serialize_wcf_Response,
|
||||
responseDeserialize: deserialize_wcf_Response,
|
||||
},
|
||||
rpcSendImageMsg: {
|
||||
path: '/wcf.Wcf/RpcSendImageMsg',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: wcf_pb.ImageMsg,
|
||||
responseType: wcf_pb.Response,
|
||||
requestSerialize: serialize_wcf_ImageMsg,
|
||||
requestDeserialize: deserialize_wcf_ImageMsg,
|
||||
responseSerialize: serialize_wcf_Response,
|
||||
responseDeserialize: deserialize_wcf_Response,
|
||||
},
|
||||
rpcGetMsgTypes: {
|
||||
path: '/wcf.Wcf/RpcGetMsgTypes',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: wcf_pb.Empty,
|
||||
responseType: wcf_pb.MsgTypes,
|
||||
requestSerialize: serialize_wcf_Empty,
|
||||
requestDeserialize: deserialize_wcf_Empty,
|
||||
responseSerialize: serialize_wcf_MsgTypes,
|
||||
responseDeserialize: deserialize_wcf_MsgTypes,
|
||||
},
|
||||
rpcGetContacts: {
|
||||
path: '/wcf.Wcf/RpcGetContacts',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: wcf_pb.Empty,
|
||||
responseType: wcf_pb.Contacts,
|
||||
requestSerialize: serialize_wcf_Empty,
|
||||
requestDeserialize: deserialize_wcf_Empty,
|
||||
responseSerialize: serialize_wcf_Contacts,
|
||||
responseDeserialize: deserialize_wcf_Contacts,
|
||||
},
|
||||
rpcGetDbNames: {
|
||||
path: '/wcf.Wcf/RpcGetDbNames',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: wcf_pb.Empty,
|
||||
responseType: wcf_pb.DbNames,
|
||||
requestSerialize: serialize_wcf_Empty,
|
||||
requestDeserialize: deserialize_wcf_Empty,
|
||||
responseSerialize: serialize_wcf_DbNames,
|
||||
responseDeserialize: deserialize_wcf_DbNames,
|
||||
},
|
||||
rpcGetDbTables: {
|
||||
path: '/wcf.Wcf/RpcGetDbTables',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: wcf_pb.String,
|
||||
responseType: wcf_pb.DbTables,
|
||||
requestSerialize: serialize_wcf_String,
|
||||
requestDeserialize: deserialize_wcf_String,
|
||||
responseSerialize: serialize_wcf_DbTables,
|
||||
responseDeserialize: deserialize_wcf_DbTables,
|
||||
},
|
||||
rpcExecDbQuery: {
|
||||
path: '/wcf.Wcf/RpcExecDbQuery',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: wcf_pb.DbQuery,
|
||||
responseType: wcf_pb.DbRows,
|
||||
requestSerialize: serialize_wcf_DbQuery,
|
||||
requestDeserialize: deserialize_wcf_DbQuery,
|
||||
responseSerialize: serialize_wcf_DbRows,
|
||||
responseDeserialize: deserialize_wcf_DbRows,
|
||||
},
|
||||
rpcAcceptNewFriend: {
|
||||
path: '/wcf.Wcf/RpcAcceptNewFriend',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: wcf_pb.Verification,
|
||||
responseType: wcf_pb.Response,
|
||||
requestSerialize: serialize_wcf_Verification,
|
||||
requestDeserialize: deserialize_wcf_Verification,
|
||||
responseSerialize: serialize_wcf_Response,
|
||||
responseDeserialize: deserialize_wcf_Response,
|
||||
},
|
||||
};
|
||||
|
||||
exports.WcfClient = grpc.makeGenericClientConstructor(WcfService);
|
421
nodejs/proto/wcf_pb.d.ts
vendored
Executable file
421
nodejs/proto/wcf_pb.d.ts
vendored
Executable file
@ -0,0 +1,421 @@
|
||||
// package: wcf
|
||||
// file: wcf.proto
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
import * as jspb from "google-protobuf";
|
||||
|
||||
export class Empty extends jspb.Message {
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): Empty.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: Empty): Empty.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: Empty, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): Empty;
|
||||
static deserializeBinaryFromReader(message: Empty, reader: jspb.BinaryReader): Empty;
|
||||
}
|
||||
|
||||
export namespace Empty {
|
||||
export type AsObject = {
|
||||
}
|
||||
}
|
||||
|
||||
export class WxMsg extends jspb.Message {
|
||||
getIsSelf(): boolean;
|
||||
setIsSelf(value: boolean): WxMsg;
|
||||
getIsGroup(): boolean;
|
||||
setIsGroup(value: boolean): WxMsg;
|
||||
getType(): number;
|
||||
setType(value: number): WxMsg;
|
||||
getId(): string;
|
||||
setId(value: string): WxMsg;
|
||||
getXml(): string;
|
||||
setXml(value: string): WxMsg;
|
||||
getSender(): string;
|
||||
setSender(value: string): WxMsg;
|
||||
getRoomid(): string;
|
||||
setRoomid(value: string): WxMsg;
|
||||
getContent(): string;
|
||||
setContent(value: string): WxMsg;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): WxMsg.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: WxMsg): WxMsg.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: WxMsg, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): WxMsg;
|
||||
static deserializeBinaryFromReader(message: WxMsg, reader: jspb.BinaryReader): WxMsg;
|
||||
}
|
||||
|
||||
export namespace WxMsg {
|
||||
export type AsObject = {
|
||||
isSelf: boolean,
|
||||
isGroup: boolean,
|
||||
type: number,
|
||||
id: string,
|
||||
xml: string,
|
||||
sender: string,
|
||||
roomid: string,
|
||||
content: string,
|
||||
}
|
||||
}
|
||||
|
||||
export class Response extends jspb.Message {
|
||||
getStatus(): number;
|
||||
setStatus(value: number): Response;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): Response.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: Response): Response.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: Response, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): Response;
|
||||
static deserializeBinaryFromReader(message: Response, reader: jspb.BinaryReader): Response;
|
||||
}
|
||||
|
||||
export namespace Response {
|
||||
export type AsObject = {
|
||||
status: number,
|
||||
}
|
||||
}
|
||||
|
||||
export class TextMsg extends jspb.Message {
|
||||
getMsg(): string;
|
||||
setMsg(value: string): TextMsg;
|
||||
getReceiver(): string;
|
||||
setReceiver(value: string): TextMsg;
|
||||
getAters(): string;
|
||||
setAters(value: string): TextMsg;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): TextMsg.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: TextMsg): TextMsg.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: TextMsg, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): TextMsg;
|
||||
static deserializeBinaryFromReader(message: TextMsg, reader: jspb.BinaryReader): TextMsg;
|
||||
}
|
||||
|
||||
export namespace TextMsg {
|
||||
export type AsObject = {
|
||||
msg: string,
|
||||
receiver: string,
|
||||
aters: string,
|
||||
}
|
||||
}
|
||||
|
||||
export class ImageMsg extends jspb.Message {
|
||||
getPath(): string;
|
||||
setPath(value: string): ImageMsg;
|
||||
getReceiver(): string;
|
||||
setReceiver(value: string): ImageMsg;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): ImageMsg.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: ImageMsg): ImageMsg.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: ImageMsg, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): ImageMsg;
|
||||
static deserializeBinaryFromReader(message: ImageMsg, reader: jspb.BinaryReader): ImageMsg;
|
||||
}
|
||||
|
||||
export namespace ImageMsg {
|
||||
export type AsObject = {
|
||||
path: string,
|
||||
receiver: string,
|
||||
}
|
||||
}
|
||||
|
||||
export class MsgTypes extends jspb.Message {
|
||||
|
||||
getTypesMap(): jspb.Map<number, string>;
|
||||
clearTypesMap(): void;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): MsgTypes.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: MsgTypes): MsgTypes.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: MsgTypes, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): MsgTypes;
|
||||
static deserializeBinaryFromReader(message: MsgTypes, reader: jspb.BinaryReader): MsgTypes;
|
||||
}
|
||||
|
||||
export namespace MsgTypes {
|
||||
export type AsObject = {
|
||||
|
||||
typesMap: Array<[number, string]>,
|
||||
}
|
||||
}
|
||||
|
||||
export class Contact extends jspb.Message {
|
||||
getWxid(): string;
|
||||
setWxid(value: string): Contact;
|
||||
getCode(): string;
|
||||
setCode(value: string): Contact;
|
||||
getName(): string;
|
||||
setName(value: string): Contact;
|
||||
getCountry(): string;
|
||||
setCountry(value: string): Contact;
|
||||
getProvince(): string;
|
||||
setProvince(value: string): Contact;
|
||||
getCity(): string;
|
||||
setCity(value: string): Contact;
|
||||
getGender(): number;
|
||||
setGender(value: number): Contact;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): Contact.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: Contact): Contact.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: Contact, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): Contact;
|
||||
static deserializeBinaryFromReader(message: Contact, reader: jspb.BinaryReader): Contact;
|
||||
}
|
||||
|
||||
export namespace Contact {
|
||||
export type AsObject = {
|
||||
wxid: string,
|
||||
code: string,
|
||||
name: string,
|
||||
country: string,
|
||||
province: string,
|
||||
city: string,
|
||||
gender: number,
|
||||
}
|
||||
}
|
||||
|
||||
export class Contacts extends jspb.Message {
|
||||
clearContactsList(): void;
|
||||
getContactsList(): Array<Contact>;
|
||||
setContactsList(value: Array<Contact>): Contacts;
|
||||
addContacts(value?: Contact, index?: number): Contact;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): Contacts.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: Contacts): Contacts.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: Contacts, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): Contacts;
|
||||
static deserializeBinaryFromReader(message: Contacts, reader: jspb.BinaryReader): Contacts;
|
||||
}
|
||||
|
||||
export namespace Contacts {
|
||||
export type AsObject = {
|
||||
contactsList: Array<Contact.AsObject>,
|
||||
}
|
||||
}
|
||||
|
||||
export class DbNames extends jspb.Message {
|
||||
clearNamesList(): void;
|
||||
getNamesList(): Array<string>;
|
||||
setNamesList(value: Array<string>): DbNames;
|
||||
addNames(value: string, index?: number): string;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): DbNames.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: DbNames): DbNames.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: DbNames, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): DbNames;
|
||||
static deserializeBinaryFromReader(message: DbNames, reader: jspb.BinaryReader): DbNames;
|
||||
}
|
||||
|
||||
export namespace DbNames {
|
||||
export type AsObject = {
|
||||
namesList: Array<string>,
|
||||
}
|
||||
}
|
||||
|
||||
export class String extends jspb.Message {
|
||||
getStr(): string;
|
||||
setStr(value: string): String;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): String.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: String): String.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: String, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): String;
|
||||
static deserializeBinaryFromReader(message: String, reader: jspb.BinaryReader): String;
|
||||
}
|
||||
|
||||
export namespace String {
|
||||
export type AsObject = {
|
||||
str: string,
|
||||
}
|
||||
}
|
||||
|
||||
export class DbTable extends jspb.Message {
|
||||
getName(): string;
|
||||
setName(value: string): DbTable;
|
||||
getSql(): string;
|
||||
setSql(value: string): DbTable;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): DbTable.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: DbTable): DbTable.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: DbTable, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): DbTable;
|
||||
static deserializeBinaryFromReader(message: DbTable, reader: jspb.BinaryReader): DbTable;
|
||||
}
|
||||
|
||||
export namespace DbTable {
|
||||
export type AsObject = {
|
||||
name: string,
|
||||
sql: string,
|
||||
}
|
||||
}
|
||||
|
||||
export class DbTables extends jspb.Message {
|
||||
clearTablesList(): void;
|
||||
getTablesList(): Array<DbTable>;
|
||||
setTablesList(value: Array<DbTable>): DbTables;
|
||||
addTables(value?: DbTable, index?: number): DbTable;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): DbTables.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: DbTables): DbTables.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: DbTables, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): DbTables;
|
||||
static deserializeBinaryFromReader(message: DbTables, reader: jspb.BinaryReader): DbTables;
|
||||
}
|
||||
|
||||
export namespace DbTables {
|
||||
export type AsObject = {
|
||||
tablesList: Array<DbTable.AsObject>,
|
||||
}
|
||||
}
|
||||
|
||||
export class DbQuery extends jspb.Message {
|
||||
getDb(): string;
|
||||
setDb(value: string): DbQuery;
|
||||
getSql(): string;
|
||||
setSql(value: string): DbQuery;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): DbQuery.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: DbQuery): DbQuery.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: DbQuery, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): DbQuery;
|
||||
static deserializeBinaryFromReader(message: DbQuery, reader: jspb.BinaryReader): DbQuery;
|
||||
}
|
||||
|
||||
export namespace DbQuery {
|
||||
export type AsObject = {
|
||||
db: string,
|
||||
sql: string,
|
||||
}
|
||||
}
|
||||
|
||||
export class DbField extends jspb.Message {
|
||||
getType(): number;
|
||||
setType(value: number): DbField;
|
||||
getColumn(): string;
|
||||
setColumn(value: string): DbField;
|
||||
getContent(): Uint8Array | string;
|
||||
getContent_asU8(): Uint8Array;
|
||||
getContent_asB64(): string;
|
||||
setContent(value: Uint8Array | string): DbField;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): DbField.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: DbField): DbField.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: DbField, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): DbField;
|
||||
static deserializeBinaryFromReader(message: DbField, reader: jspb.BinaryReader): DbField;
|
||||
}
|
||||
|
||||
export namespace DbField {
|
||||
export type AsObject = {
|
||||
type: number,
|
||||
column: string,
|
||||
content: Uint8Array | string,
|
||||
}
|
||||
}
|
||||
|
||||
export class DbRow extends jspb.Message {
|
||||
clearFieldsList(): void;
|
||||
getFieldsList(): Array<DbField>;
|
||||
setFieldsList(value: Array<DbField>): DbRow;
|
||||
addFields(value?: DbField, index?: number): DbField;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): DbRow.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: DbRow): DbRow.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: DbRow, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): DbRow;
|
||||
static deserializeBinaryFromReader(message: DbRow, reader: jspb.BinaryReader): DbRow;
|
||||
}
|
||||
|
||||
export namespace DbRow {
|
||||
export type AsObject = {
|
||||
fieldsList: Array<DbField.AsObject>,
|
||||
}
|
||||
}
|
||||
|
||||
export class DbRows extends jspb.Message {
|
||||
clearRowsList(): void;
|
||||
getRowsList(): Array<DbRow>;
|
||||
setRowsList(value: Array<DbRow>): DbRows;
|
||||
addRows(value?: DbRow, index?: number): DbRow;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): DbRows.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: DbRows): DbRows.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: DbRows, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): DbRows;
|
||||
static deserializeBinaryFromReader(message: DbRows, reader: jspb.BinaryReader): DbRows;
|
||||
}
|
||||
|
||||
export namespace DbRows {
|
||||
export type AsObject = {
|
||||
rowsList: Array<DbRow.AsObject>,
|
||||
}
|
||||
}
|
||||
|
||||
export class Verification extends jspb.Message {
|
||||
getV3(): string;
|
||||
setV3(value: string): Verification;
|
||||
getV4(): string;
|
||||
setV4(value: string): Verification;
|
||||
|
||||
serializeBinary(): Uint8Array;
|
||||
toObject(includeInstance?: boolean): Verification.AsObject;
|
||||
static toObject(includeInstance: boolean, msg: Verification): Verification.AsObject;
|
||||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
|
||||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
|
||||
static serializeBinaryToWriter(message: Verification, writer: jspb.BinaryWriter): void;
|
||||
static deserializeBinary(bytes: Uint8Array): Verification;
|
||||
static deserializeBinaryFromReader(message: Verification, reader: jspb.BinaryReader): Verification;
|
||||
}
|
||||
|
||||
export namespace Verification {
|
||||
export type AsObject = {
|
||||
v3: string,
|
||||
v4: string,
|
||||
}
|
||||
}
|
3376
nodejs/proto/wcf_pb.js
Executable file
3376
nodejs/proto/wcf_pb.js
Executable file
File diff suppressed because it is too large
Load Diff
20
nodejs/src/commands/base-command.ts
Executable file
20
nodejs/src/commands/base-command.ts
Executable file
@ -0,0 +1,20 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
export class Context {}
|
||||
|
||||
export class Interaction {
|
||||
constructor(input: string) {
|
||||
this.input = input;
|
||||
this.options = {};
|
||||
}
|
||||
input: string;
|
||||
output?: string;
|
||||
options: any;
|
||||
}
|
||||
|
||||
export interface Command {
|
||||
name: string;
|
||||
follow: (interaction: Interaction) => number;
|
||||
run: (ctx: Context, interaction: Interaction) => string | Promise<string>;
|
||||
}
|
29
nodejs/src/commands/index.ts
Executable file
29
nodejs/src/commands/index.ts
Executable file
@ -0,0 +1,29 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import { log } from '../utils/log';
|
||||
import { Interaction, Command, Context } from './base-command';
|
||||
import rsp from './rock-scissors-paper';
|
||||
import stock from './stock';
|
||||
|
||||
let commands: Command[] = [rsp, stock];
|
||||
|
||||
export const handleCommand = async (ctx: Context, input: string): Promise<string> => {
|
||||
const interaction = new Interaction(input);
|
||||
const choice = commands
|
||||
.map((c) => {
|
||||
return { score: c.follow(interaction), command: c };
|
||||
})
|
||||
?.sort((a, b) => {
|
||||
return a.score - b.score;
|
||||
})
|
||||
?.filter((x) => x.score > 0)
|
||||
?.pop();
|
||||
|
||||
if (!choice) {
|
||||
log.debug('no command found');
|
||||
return '';
|
||||
}
|
||||
const reply = await choice.command.run(ctx, interaction);
|
||||
return reply;
|
||||
};
|
38
nodejs/src/commands/rock-scissors-paper.ts
Executable file
38
nodejs/src/commands/rock-scissors-paper.ts
Executable file
@ -0,0 +1,38 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
import { log } from '../utils/log';
|
||||
import { Interaction, Command, Context } from './base-command';
|
||||
|
||||
function RandomNum(max: number): number {
|
||||
return Math.floor(Math.random() * (max + 1));
|
||||
}
|
||||
|
||||
const keywords = ['rock', 'paper', 'scissors'];
|
||||
|
||||
export default {
|
||||
name: 'rock-scissors-paper',
|
||||
follow: (interaction: Interaction): number => {
|
||||
const i = keywords.find((k) => {
|
||||
return interaction.input.includes(k);
|
||||
});
|
||||
log.debug(`rock-scissors-paper follow-up: ${i}`);
|
||||
interaction.options.pick = i ?? undefined;
|
||||
return i ? 1 : 0;
|
||||
},
|
||||
run: (ctx: Context, interaction: Interaction): string => {
|
||||
const pick: string = interaction.options.pick as string;
|
||||
|
||||
const playerPick = keywords.findIndex((x) => x == pick);
|
||||
const botPick = RandomNum(2);
|
||||
|
||||
let result = 'tied';
|
||||
|
||||
if (playerPick == botPick) result = 'Tied';
|
||||
else if (playerPick == 0 && botPick == 2) result = 'Win';
|
||||
else if ((playerPick - botPick) % 3 == 1) result = 'Win';
|
||||
else result = 'Lose';
|
||||
|
||||
const content = `You picked **${pick}** and I picked **${keywords[botPick]}**, You **${result}**`;
|
||||
return content;
|
||||
}
|
||||
} as Command;
|
28
nodejs/src/commands/stock.ts
Executable file
28
nodejs/src/commands/stock.ts
Executable file
@ -0,0 +1,28 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
import { stocks } from 'stock-api';
|
||||
import { Interaction, Command, Context } from './base-command';
|
||||
|
||||
function getPrice(code: string): Promise<string> {
|
||||
return stocks.tencent.getStocks([code]).then((res) => {
|
||||
return JSON.stringify(res[0]);
|
||||
});
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'stock',
|
||||
follow: (interaction: Interaction): number => {
|
||||
let match = /(S[HZ]\d{6})/.exec(interaction.input);
|
||||
if (match) {
|
||||
let stock = match && match[0];
|
||||
interaction.options.stock = stock;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
run: async (ctx: Context, interaction: Interaction): Promise<string> => {
|
||||
const pick: string = interaction.options.stock as string;
|
||||
const content = await getPrice(pick);
|
||||
return content;
|
||||
}
|
||||
} as Command;
|
57
nodejs/src/index.ts
Executable file
57
nodejs/src/index.ts
Executable file
@ -0,0 +1,57 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import * as readline from 'readline';
|
||||
import { stdin as input } from 'node:process';
|
||||
import { WxMsg } from '../proto/wcf_pb';
|
||||
import { log } from './utils/log';
|
||||
import { handleCommand } from './commands';
|
||||
import { Context } from './commands/base-command';
|
||||
import { SDK } from './wcf/win32';
|
||||
import { WCF } from './wcf';
|
||||
import { portAvailable, sleep } from './utils/misic';
|
||||
|
||||
let ctx = new Context();
|
||||
|
||||
(async () => {
|
||||
if (await portAvailable(10086)) {
|
||||
log.debug(`Call SDK to inject.`);
|
||||
const sdk = new SDK();
|
||||
sdk.WxInitSDK();
|
||||
}
|
||||
|
||||
// wait util WCF is ready
|
||||
while (!(await portAvailable(10086))) {
|
||||
await sleep(1000);
|
||||
}
|
||||
|
||||
log.debug(`Connect to gRPC and wait for login.`);
|
||||
const wcf = new WCF();
|
||||
while (!(await wcf.IsLogin())) {
|
||||
await sleep(1000);
|
||||
}
|
||||
|
||||
wcf.on('message', async (msg: WxMsg) => {
|
||||
const txt = msg.getContent();
|
||||
log.debug(txt, msg.getIsSelf());
|
||||
if (!msg.getIsSelf()) {
|
||||
const reply = await handleCommand(ctx, txt);
|
||||
if (msg.getIsGroup()) {
|
||||
wcf.SendTextMsg(msg.getRoomid(), reply);
|
||||
} else {
|
||||
wcf.SendTextMsg(msg.getSender(), reply);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
wcf.EnableReceiveMsg();
|
||||
})();
|
||||
|
||||
const std = readline.createInterface({ input });
|
||||
std.on('line', async (line) => {
|
||||
const reply = await handleCommand(ctx, line);
|
||||
log.debug(`reply: ${reply}`);
|
||||
if (line === 'exit') {
|
||||
std.close();
|
||||
}
|
||||
});
|
11
nodejs/src/utils/log.ts
Executable file
11
nodejs/src/utils/log.ts
Executable file
@ -0,0 +1,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import { Logger } from 'tslog';
|
||||
|
||||
export const log: Logger = new Logger({
|
||||
name: 'main',
|
||||
displayLoggerName: false,
|
||||
overwriteConsole: true,
|
||||
dateTimePattern: 'monthday hour:minute:second'
|
||||
});
|
20
nodejs/src/utils/misic.ts
Executable file
20
nodejs/src/utils/misic.ts
Executable file
@ -0,0 +1,20 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
export function portAvailable(port: number): Promise<boolean> {
|
||||
const net = require('net');
|
||||
return new Promise((resolve, _reject) => {
|
||||
let server = net.createServer().listen(port);
|
||||
server.on('listening', function () {
|
||||
server.close();
|
||||
resolve(true);
|
||||
});
|
||||
server.on('error', function (err: any) {
|
||||
if (err.code == 'EADDRINUSE') {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
55
nodejs/src/wcf/index.ts
Executable file
55
nodejs/src/wcf/index.ts
Executable file
@ -0,0 +1,55 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import EventEmitter from 'events';
|
||||
import TypedEmitter from 'typed-emitter';
|
||||
import * as grpc from 'grpc';
|
||||
import { WcfClient, IWcfClient } from '../../proto/wcf_grpc_pb';
|
||||
import { Empty, TextMsg, WxMsg } from '../../proto/wcf_pb';
|
||||
|
||||
type MessageEvents = {
|
||||
error: (error: Error) => void;
|
||||
message: (msg: WxMsg) => void;
|
||||
};
|
||||
|
||||
export class WCF extends (EventEmitter as new () => TypedEmitter<MessageEvents>) {
|
||||
client: IWcfClient;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.client = new WcfClient(`localhost:10086`, grpc.credentials.createInsecure());
|
||||
}
|
||||
|
||||
async IsLogin(): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
const request = new Empty();
|
||||
this.client.rpcIsLogin(request, (err, ret) => {
|
||||
if (err) reject(err);
|
||||
else resolve(ret.getStatus() !== 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async EnableReceiveMsg() {
|
||||
let stream = this.client.rpcEnableRecvMsg(new Empty());
|
||||
stream.on('data', (d) => {
|
||||
this.emit('message', d);
|
||||
});
|
||||
stream.on('error', (err) => {
|
||||
this.emit('error', err);
|
||||
});
|
||||
}
|
||||
|
||||
async SendTextMsg(to: string, msg: string): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
const request = new TextMsg();
|
||||
request.setReceiver(to);
|
||||
request.setMsg(msg);
|
||||
|
||||
this.client.rpcSendTextMsg(request, (err, ret) => {
|
||||
if (err) reject(err);
|
||||
else resolve(ret.getStatus() !== 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
18
nodejs/src/wcf/win32.ts
Executable file
18
nodejs/src/wcf/win32.ts
Executable file
@ -0,0 +1,18 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
import { Library, Method, never } from 'ffi-decorators';
|
||||
|
||||
@Library({ libPath: './sdk.dll' })
|
||||
export class SDK {
|
||||
@Method({ types: ['int', []] })
|
||||
WxInitSDK(): number {
|
||||
return never();
|
||||
}
|
||||
|
||||
@Method({ types: ['int', []] })
|
||||
WxDestroySDK(): number {
|
||||
return never();
|
||||
}
|
||||
}
|
||||
|
||||
// Todo: inject spy.dll directly in ts code.
|
103
nodejs/tsconfig.json
Executable file
103
nodejs/tsconfig.json
Executable file
@ -0,0 +1,103 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||
|
||||
/* Projects */
|
||||
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
||||
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
||||
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
||||
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
||||
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
||||
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
||||
|
||||
/* Language and Environment */
|
||||
"target": "es2017", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
||||
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
||||
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
||||
"experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
||||
"emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
||||
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
||||
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
||||
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
||||
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
||||
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
||||
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
||||
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||
|
||||
/* Modules */
|
||||
"module": "commonjs", /* Specify what module code is generated. */
|
||||
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
||||
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
||||
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
||||
// "resolveJsonModule": true, /* Enable importing .json files. */
|
||||
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
||||
|
||||
/* JavaScript Support */
|
||||
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
||||
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
||||
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
||||
|
||||
/* Emit */
|
||||
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
||||
// "removeComments": true, /* Disable emitting comments. */
|
||||
// "noEmit": true, /* Disable emitting files from a compilation. */
|
||||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
||||
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
||||
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
||||
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
||||
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
||||
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
||||
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
||||
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
||||
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
||||
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
||||
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
||||
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
||||
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
||||
|
||||
/* Interop Constraints */
|
||||
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
||||
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
||||
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
||||
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
||||
|
||||
/* Type Checking */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
||||
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
||||
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
||||
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
||||
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
||||
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
||||
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
||||
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
||||
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
||||
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
||||
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
||||
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
||||
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
||||
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
||||
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
||||
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
||||
|
||||
/* Completeness */
|
||||
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user