node.js - 如何使用 Bale bot 向群组发送消息?

标签 node.js bale-messenger balebot

如何使用 Bale bot 向群组发送消息?

为了使用 BaleBot 发送消息,我们需要有用户/组的 ID 和 accessHash。但我无法获取 accessHash 来向群组发送消息。

最佳答案

如果你有组(或 channel )的 id 和 access_hash,这并不太难。你应该只创建 Peer,然后将其放入 send_message 函数中。 看看这段代码。客户端启动后,向指定 channel 推送“Hello”。 注意:记住组和 channel 是相似的。

const SDK = require("balebot");
const BaleBot = SDK.BaleBot;
const TextMessage = SDK.TextMessage;
const Group = SDK.Group;


let bot = new BaleBot('token');


bot.hears(["/start"], (message, responder) => {
   console.log(responder._peer)
    bot.send(new TextMessage("hello"),responder.peer).then((res) => {
        console.log(res)
    }).catch((err) => {
        console.log(err)
    });
});

关于node.js - 如何使用 Bale bot 向群组发送消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50998197/

相关文章:

mysql - 如何使用插入查询将字典中的批量数据发送到数据库中?

python - 如何使用带有 BaleBot 的 Flask 应用程序向用户发送消息

node.js - 如何通过 Bale Bot 发送照片消息?

python - 如何将 bale bot 中的本地文件发送给客户端?

python - 如何修复 Python 主机中的 BaleBot 问题

javascript - 为什么我们需要返回一个 promise 解析?

node.js - 如何将 Google Analytics 跟踪代码与 node-express 应用程序一起使用?

javascript - 映射数组返回 Unresolved promise