Reputation: 951
How to send message using Bale bot into group?
for send message using BaleBot, we need to have id of User/Group and have an accessHash. But I can`t get accessHash for send mesage to Group.
Upvotes: 2
Views: 223
Reputation: 4291
It's not too hard, if you have id and access_hash of the group(or channel). you should just make the Peer and after that put it in send_message function. look at this code. It push a "Hello" to a specified channel after getting start by client. Note: Remember group and channel are similar.
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)
});
});
Upvotes: 4