Gathering detailed insights and metrics for wechaty-puppet-mock-koa
Gathering detailed insights and metrics for wechaty-puppet-mock-koa
Gathering detailed insights and metrics for wechaty-puppet-mock-koa
Gathering detailed insights and metrics for wechaty-puppet-mock-koa
It is convenient to test wechaty with restful interface
npm install wechaty-puppet-mock-koa
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
36 Commits
1 Watchers
1 Branches
2 Contributors
Updated on Jan 12, 2021
Latest Version
0.2.3
Package Id
wechaty-puppet-mock-koa@0.2.3
Unpacked Size
108.72 kB
Size
18.10 kB
File Count
34
NPM Version
6.14.8
Node Version
14.15.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
packaging with koa based on wechaty-puppet-mock, It is convenient to test wechaty with restful interface.
1$ npm install wechaty-puppet-mock-koa --save-dev
PuppetKoa
Class
constructor([options])
- new class PuppetKoa
instance
options.port
- http listen port, default to 3000
.options.prefix
- http request prefix, default to /mock
.options.loginData
- information used to simulate login.
options.loginData.id
- login bot id, default to bot_id
.options.loginData.status
- login bot status, default to 0
.options.loginData.qrcode
- login bot qrcode, default to https://not-exist.com
.options.initFile
- initial imported login
, contact
, room
data, is a JSON file path, default to null
.NOTE:loginData
not required if initFile
exists
index.js
1const {PuppetPadplus} = require('wechaty-puppet-padplus'); 2 3let puppet = null; 4 5if (process.env.NODE_ENV != 'dev') { 6 // use ipad puppet 7 puppet = new PuppetPadplus({token: 'xxx'}); 8} else { 9 // use mock puppet 10 const {PuppetKoa} = require('wechaty-puppet-mock-koa'); 11 puppet = new PuppetKoa({port:3001,prefix:'/api',initFile:'./initFile.json'}); 12} 13 14// create bot 15const bot = new Wechaty({name: config.botName, puppet}); 16 17... 18 19// receive message 20bot.on('message', async (msg) => { 21 console.log(msg.from().name(),msg.text()); 22}); 23 24...
initFile.json
login
configuration is required.login
and contact
is consistent with the parameters of create contact ([PUT] /mock/contact)
interfaceroomMemberList
are better existing in the contactList
room
is consistent with the parameters of create room ([PUT] /mock/room)
interface1// /doc/mock.json 2{ 3 "login": { 4 "id": "bot_id", 5 "name": "bot_name", 6 "avatar": "https://avatars0.githubusercontent.com/u/21285357?s=200&v=4", 7 "type": 1, 8 "gender": 1, 9 "city": "shanghai", 10 "alias": "bot_alias", 11 "star": false, 12 "weixin": "weixin", 13 "friend": true, 14 "address": "shanghai", 15 "province": "shanghai" 16 }, 17 "contactList": [ 18 { 19 "id": "friend_1", 20 "name": "friend_1_name", 21 "avatar": "https://avatars0.githubusercontent.com/u/21285357?s=200&v=4", 22 "type": 1, 23 "gender": 1, 24 "city": "shanghai", 25 "alias": "friend_1_alias", 26 "star": false, 27 "weixin": "weixin", 28 "friend": true, 29 "address": "shanghai", 30 "province": "shanghai" 31 } 32 ], 33 "roomMemberList": [ 34 { 35 "id": "friend_1", 36 "roomAlias": "friend_1_alias", 37 "inviterId": "bot_id" 38 } 39 ], 40 "roomList": [ 41 { 42 "id": "room_1", 43 "topic": "room_topic", 44 "avatar": "https://avatars0.githubusercontent.com/u/21285357?s=200&v=4", 45 "ownerId": "bot_id", 46 "adminIdList": [ 47 "bot_id" 48 ], 49 "memberIdList": [ 50 "bot_id", 51 "friend_1" 52 ] 53 } 54 ] 55}
API sample
send message
1// request 2curl -X POST \ 3 http://localhost:3000/mock/message/single \ 4 -H 'Cache-Control: no-cache' \ 5 -H 'Content-Type: application/json' \ 6 -H 'Postman-Token: f7f34936-8a75-41f3-b008-7c48992bceca' \ 7 -d '{ 8 "type": 7, 9 "text": "hello", 10 "toId": "bot_id", 11 "fromId": "friend_1", 12 "filename": "/path/test.json" 13}' 14 15// response 16{"state":200,"message":"Request success!"} 17 18// console 19friend_1_name hello
Reference resources
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More