如何使用 Bale bot 向群组发送消息?
How to send message using Bale bot into group?
如何使用Bale bot发消息进群?
为了使用 BaleBot 发送消息,我们需要有 User/Group 的 ID 和 accessHash。但是我无法获取 accessHash 以向组发送消息。
这并不难,如果您有组(或频道)的 ID 和 access_hash。您应该只创建 Peer 然后将其放入 send_message 函数中。
看看这段代码。客户端启动后推送一个"Hello"到指定频道。
注意:记住组和频道是相似的。
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)
});
});
如何使用Bale bot发消息进群?
为了使用 BaleBot 发送消息,我们需要有 User/Group 的 ID 和 accessHash。但是我无法获取 accessHash 以向组发送消息。
这并不难,如果您有组(或频道)的 ID 和 access_hash。您应该只创建 Peer 然后将其放入 send_message 函数中。 看看这段代码。客户端启动后推送一个"Hello"到指定频道。 注意:记住组和频道是相似的。
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)
});
});