UNPKG

@juzi/wechaty

Version:

Wechaty is a RPA SDK for Chatbot Makers.

75 lines 2.75 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const wechaty_puppet_1 = __importDefault(require("@juzi/wechaty-puppet")); const file_box_1 = require("file-box"); const mod_js_1 = require("../src/mods/mod.js"); const bot = mod_js_1.WechatyBuilder.build({ name: 'video-post-bot', }); async function testVideoPost() { const contact = await bot.Contact.find({ id: 'xxx' }); const room = await bot.Room.find({ id: 'xxx' }); if (!contact || !room) { return; } const post = await bot.Post.builder() .add('hello, world') .add(file_box_1.FileBox.fromQRCode('qr')) .add(await bot.UrlLink.create('https://wechaty.js.org')) .build(); await bot.say(post); bot.on('message', async (message) => { // if (message.type() !== message.type.Post) { // return // } // forward video post await message.forward(contact); /** * Video Post */ const post2 = await message.toPost(); const counter = post2.counter(); console.info('total tap(like) number:', counter.taps && counter.taps[wechaty_puppet_1.default.types.Tap.Like]); console.info('total children number:', counter.descendant); /** * Comment */ // reply comment await post2.reply('xxxx'); await post2.reply(file_box_1.FileBox.fromQRCode('qrimage')); for await (const descendant of post.descendants({ contactId: message.wechaty.currentUser.id })) { console.info(descendant); } /** * Like */ // like message await post.like(true); // await post.tap(PostTapType.Like, true) // check whether we have liked this post const liked = await post.like(); console.info('liked date:', liked); // const liked = await post.tap(PostTapType.Like) // cancel like await post.like(false); // await post.tap(PostTapType.Like, false) // list all likers for await (const tap of post.taps()) { console.info('Taper -------'); console.info('taper:', tap.contact); console.info('date:', tap.date); console.info('type:', tap.type); } for await (const like of post.likes()) { console.info('-------'); console.info('liker:', like.contact); console.info('date:', like.date); console.info('type:', like.type); } }); } void testVideoPost(); //# sourceMappingURL=video-post.js.map