Help me please ! :((
berenjian opened this issue · 5 comments
hi dear friend ! would you give me a sample code for telegram bot ?!
i want a code for this :
when a client send a message to bot , for example
"hi"
the bot send him/her :
"hello dear friend"
i wrote some code but i didn't see any message from robot !
@mast thank you :*
There is example folder in the repo!
https://github.com/mast/telegram-bot-api/blob/master/examples/echo-bot.js
@mast i used this code but my bot didn't send me any message ! would you mind writing the code for me ? when i send hi , the bot send me hello dear friend ! thank you
As I said you can find working examples in "examples" folder. If it doesn't work for you, you do something wrong.
Excuse me dude ! i wrote these code with my token , but when i sent anything it didnt answer... .
var telegram = require('telegram-bot-api');
var api = new telegram({
token: '<my unique token >',
updates: {
enabled: true,
get_interval: 1000
}
});
api.on('message', function(message)
{
var chat_id = message.chat.id;
// It'd be good to check received message type here
// And react accordingly
// We consider that only text messages can be received here
api.sendMessage({
chat_id: message.chat.id,
text: message.text ? message.text : 'This message doesn\'t contain text :('
}, function(err, message)
{
console.log(err);
console.log(message);
});
});
tnx for everything my friend...
you are great.. 👍