enricostara / termgram

A terminal client to connect with Telegram
www.termgram.me
MIT License
45 stars 10 forks source link

Question regarding sendCode #7

Closed badoualy closed 9 years ago

badoualy commented 9 years ago

Hi,

first thank for your work, can't wait being able to send/retrieve messages !

I'm trying to get telegram.link to work, but I can't manage to send a verification code to login, here's my code : (Wasn't sure whether to post here or in telegram.link, since I'm basing my work on this project).

var os = require('os');
var telegramLink = require('telegram.link')();

// set the  environment
var app = {
    id: -----,
    hash: '----------------------------',
    version: '1.0.0',
    lang: 'fr',
    deviceModel: os.type().replace('Darwin', 'OS_X'),
    systemVersion: os.platform() + '/' + os.release()
};

var client = telegramLink.createClient(
    app,
    telegramLink.TEST_PRIMARY_DC,
    function () {
        console.log('Connected to Telegram !');
        client.createAuthKey(function (auth) {
            console.log('Auth key OK: %s', auth.key.toString());

            client.auth.sendCode("+336--------);
        });
    }
);

Any idea? May be I am missing a step ?

enricostara commented 9 years ago

You are declaring an anonymous function never called. Try also to give a callback function to the sendCode call

badoualy commented 9 years ago

I updated to use the prod server, not sure why but it worked. And the anonymous function is called, it's a callback for createClient, the log are printed and the request sent. I guess I can close since it's working now, thanks.

enricostara commented 9 years ago

You're right and also for me the test environment does not always work