如何使用 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/