mast / telegram-bot-api

First Telegram Bot API node.js library
http://mast.github.io/telegram-bot-api/
MIT License
246 stars 64 forks source link

Help me please ! :(( #13

Closed berenjian closed 8 years ago

berenjian commented 8 years ago

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 :*

mast commented 8 years ago

There is example folder in the repo! https://github.com/mast/telegram-bot-api/blob/master/examples/echo-bot.js

berenjian commented 8 years ago

@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

berenjian commented 8 years ago

can you help me please ? i'm amateur ... :( @mast

mast commented 8 years ago

As I said you can find working examples in "examples" folder. If it doesn't work for you, you do something wrong.

berenjian commented 8 years ago

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.. :+1: