【问题标题】:How to send message using Bale bot into group?如何使用 Bale bot 向群组发送消息?
【发布时间】:2018-12-02 12:53:33
【问题描述】:

如何使用 Bale bot 群发消息?

对于使用 BaleBot 发送消息,我们需要有 User/Group 的 id 和 accessHash。但我无法获取用于向 Group 发送消息的 accessHash。

【问题讨论】:

    标签: node.js bale-messenger balebot


    【解决方案1】:

    如果你有组(或频道)的 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)
        });
    });
    

    【讨论】:

    • 谢谢,但我不知道如何获取 Group 的访问哈希!
    • 您需要先将机器人添加到组中。之后给予许可。它将能够从组中获取更新。
    猜你喜欢
    • 2018-11-27
    • 2016-04-06
    • 2021-12-31
    • 2019-05-08
    • 1970-01-01
    • 2016-09-04
    • 2018-12-16
    • 2019-07-07
    • 2021-09-10
    相关资源
    最近更新 更多