Skip to content

Commit

Permalink
Update paimon.md (#1472)
Browse files Browse the repository at this point in the history
* Update paimon.md

* Update paimon.md

* Update paimon.md

* Update paimon.md

* Update paimon.md

* upgrade wechaty to 1.x
  • Loading branch information
zpaimon authored Feb 10, 2022
1 parent 3a1f7d3 commit 4f228fd
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions docusaurus/docs/puppet-services/paimon.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,100 @@ sidebar_label: Paimon
- Privacy Policy: To-be-added
- Service Level Agreement (SLA): To-be-added

## Simple and Effective

- Paimon service is so simple.It don't need Token Gateway(Docker) and don't need the 3rd party library.
- Paimon的服务很简单,不需要token网关也不需要第三方的库,原生支持Wechaty。

package.json

```json
{
"name": "wechaty-puppet-paimon",
"version": "0.0.1",
"description": "Demo for paimon",
"author": "you",
"license": "Apache-2.0",
"dependencies": {
"qrcode-terminal": "^0.12.0",
"wechaty": "^1.0"
}
}

```

bot.js

```js
const {
log,
ScanStatus,
WechatyBuilder,
} = require('wechaty')

const bot = WechatyBuilder.build({
name: 'ding-dong-bot',
puppet: 'wechaty-puppet-service',
puppetOptions: {
tls: {
disable: true
},
token: "puppet_paimon_YOUR_TOKEN" // !!!!! Please change it !!!!!
}
})

function onScan(qrcode, status) {
if (status === ScanStatus.Waiting && qrcode) {
const qrcodeImageUrl = [
'https://wechaty.js.org/qrcode/',
encodeURIComponent(qrcode),
].join('')

log.info('StarterBot', 'onScan: %s(%s) - %s', ScanStatus[status], status, qrcodeImageUrl)
} else {
log.info('StarterBot', 'onScan: %s(%s)', ScanStatus[status], status)
}
}

function onLogin(user) {
log.info('StarterBot', '%s login', user);
}

function onLogout(user) {
log.info('StarterBot', '%s logout', user);
}

function onMessage(msg) {
console.log(msg)
if (msg.self()) return;
}

bot.on('scan', onScan)
bot.on('login', onLogin)
bot.on('logout', onLogout)
bot.on('message', onMessage)

bot.start()
.then(() => {
log.info('StarterBot', 'Starter Bot Started.');
})
.catch(e => {
log.error('StarterBot', e);
})
```

```bash
>> npm i
>> node bot.js
```

## Paimon supports multi languages

NO token gateway required.(不需要Token网关直接使用)

- [Python](https://wechaty.readthedocs.io/zh_CN/latest/introduction/use-paimon-protocol/)
- [GO](https://github.com/wechaty/go-wechaty-getting-started)

## How to buy

[Get a FREE trail token for 7 days.](http://120.55.60.194/)
Expand Down

0 comments on commit 4f228fd

Please sign in to comment.