forked from wechaty/puppet-lark
-
Notifications
You must be signed in to change notification settings - Fork 7
Getting Started with TypeScript Javascript
Leo_chen edited this page Aug 23, 2022
·
2 revisions
There are some ways to get started with Engine.
You need download dll to run this demo. How to Download Dll
Install Node, 16 LTS version is recommended.
$ node --version // >= v16.0.0
2. Clone the wechaty-puppet-engine-demo project.
$ git clone [email protected]:leochen-g/wechaty-puppet-engine-demo.git
Then install Node dependencies.
$ cd wechaty-puppet-engine-demo
$ npm install
3. Set you server info in main.ts
const puppet = new PuppetEngine({
port: 8089,
runLocal: false,
httpServer: 'http://10.10.10.15:8055',
})
Then run it:
$ npm run demo
If you want to explore Engine step by step, following instructions may be helpful.
You need download dll to run Engine. How to Download Dll
Install Node, 16 LTS version is recommended.
$ node --version // >= v16.0.0
mkdir my-engine-bot && cd my-engine-bot
npm init -y
npm install ts-node typescript -g --registry=https://registry.npmmirror.com/
tsc --init --target ES6
npm install wechaty@latest --registry=https://registry.npmmirror.com/
npm install wechaty-puppet-engine@latest --registry=https://registry.npmmirror.com/
// bot.ts
import {PuppetEngine} from "wechaty-puppet-engine";
import {WechatyBuilder} from "wechaty";
const puppet = new PuppetEngine({
port: 8089,
runLocal: false,
httpServer: 'http://10.10.10.15:8055',
}),
const bot = WechatyBuilder.build({
name: "TestBot",
puppet,
})
bot
.on("login", (user: Contact) => {
console.log(`${user} login`);
})
.on("message", async (message: Message) => {
console.log(`on message: ${message.toString()}`);
})
.start()
console.log("TestBot", "started");
Then run the bot:
$ ts-node bot.ts
Don't be evil
GETTING STARTED
- How to Download Dll
- Getting Started with TypeScript/JavaScript(RECOMMENDED)
- Getting Started with Python/Java/Go
REFERENCE
ADVANCED GUIDES