bottender - 发送打字指示
问题描述
有没有办法只使用一个函数调用来发送带有打字指示的消息。
还是我必须在一定时间内打开打字,然后在发送消息之前将其关闭?
谢谢
解决方案
我能够在示例文件夹中找到。我在文档中搜索,但似乎没有很好的记录。the delay and withTyping
这里是整个示例文件以供参考。
const { MessengerBot, withTyping } = require('bottender');
const { createServer } = require('bottender/express');
const bot = new MessengerBot({
accessToken: '__FILL_YOUR_TOKEN_HERE__',
appSecret: '__FILL_YOUR_SECRET_HERE__',
});
bot.use(withTyping({ delay: 1000 }));
bot.onEvent(async context => {
await context.sendText('Hello World');
await context.sendText('Hello World');
await context.sendText('Hello World~~~~~~~~~~', { delay: 2000 });
});
const server = createServer(bot);
server.listen(5000, () => {
console.log('server is running on 5000 port...');
});
推荐阅读
- sql - 如何选择在一个项目上一起工作时间最长的员工?
- tensorflow - 矩阵乘法但 min() 的总和而不是乘积的总和
- node.js - findOne 返回一个空对象
- android - 如果您在 web 视图中,如何可靠地测试?
- javascript - 功能组件和对象迭代
- go - 如何为当前操作系统构建 go 包但将其输出到指定文件夹?
- java - ActionProcessButton 上的空指针异常
- c++ - 为什么 fstream 不能在 Linux 中写入文件?
- android - 将日期转换为简单日期表示法
- ios - XCTest 失败并出现错误“类 AXAccessQueue 在两者中都实现...”