Well, after struggling a bit to change the file permissions to update it via FTP transfer, I was able to update the user ID in
gladys-production.db
I restart Gladys and then update the token.
And that’s where it gets interesting: I reconnect to Telegram and bam it still doesn’t work!
I check the ID in the db again and there, surprise, the .0 is back
As if it gets added when the link is generated.
So I create the GitHub issue. (Or at least I try )
Thanks
Shoot! We’ll have to debug this, but it’s going to be very complicated because it’s a bug that only happens with your account due to your identifier…
Do you have any Node.js development skills or not at all?
We use this library in Gladys:
I wouldn’t be surprised if the cast happens on their end during the parsing of the data returned by the Telegram API, so we’ll need to write a piece of code that tests only the library’s code?
Hello!
Thank you for this thread, I have exactly the same problem as described above… I did the same checks, and bingo! My userid also has a .0 at the end
Crazy, that confirms the issue! Thanks for your feedback @Christophe_LOCHON
Do you have some technical skills to help us see where the problem comes from? The issue is that not having a Telegram account with an ID that causes problems (ending with 0), I can’t reproduce the issue at home
Hello,
First of all, thanks to @Christophe_LOCHON that confirms the bug
As for the rest, to be honest, I haven’t really made progress in debugging because I don’t really know how to go about it.
If I understand the operation correctly, when the API key is entered in Gladys, there is a call to Telegram which parses the key, confirms that it is valid and returns (or deduces) the associated user ID.
During initialization, this user ID is saved in the Gladys database.
It is then used to make the link during Telegram/Gladys exchanges.
For me there are 2 problems:
1/ during initialization the user ID is returned (or at least saved) with a .0 at the end
We also notice that even if we delete the .0 at the end of the ID in the database and we do another connection test with Telegram, the ID is then modified again with a .0.
Hence problem 2:
2/ The Telegram ID is saved during each exchange instead of simply « matching » with the one available in the database…
Now I don’t know how to « monitor » these exchanges to confirm all this and find out where the problem comes from.
@Mazshaka Actually, I suspect the library we are using is making a mistake when parsing the Telegram API response, as the library already returns a « Number » in JavaScript.
const TelegramBot = require('node-telegram-bot-api');
// replace the value below with the Telegram token you receive from @BotFather
const token = 'YOUR_TELEGRAM_BOT_TOKEN';
// Create a bot that uses 'polling' to fetch new updates
const bot = new TelegramBot(token, {polling: true});
// Listen for any kind of message. There are different kinds of
// messages.
bot.on('message', (msg) => {
const chatId = msg.chat.id;
console.log(msg);
});
You would need to run this piece of code on your machine, then send a message to the bot with your user.
Otherwise, another possibility is that you send me your API key (privately, from a dummy bot created for the test) and I do the test on my machine, but this implies that you are in front of your phone at the time I do the test to be able to send a message
Re,
I need a little help.
I don’t know where to put the .js file.
Unless I’m mistaken, Gladys uses URL routes to access the file.
So I don’t know where I can put the file to access it.
Or maybe I can run it via a command.
But I’m not sure about that either…
So if you could guide me
Thanks!
Best regards,
Lionel
In fact, that has nothing to do with Gladys, what I was talking about I suggested installing the library on your computer and running a test. After that, you need a Node.js development environment on your machine. If you’ve never done that before, the step might be a bit high.
So to be complete, I did think about running the pi script. I understood that it didn’t work like that. However, I did install Node.js on the instance to be able to run npm commands. But I don’t know if it’s useful and/or sufficient?
I admit that from there I wouldn’t know how to go any further without more in-depth help… like step by step
Or a link to a tutorial?
Otherwise, I can always send you my API key so you can test it.
I just worked on the bug this morning. I isolated the cause of the bug on Gladys’s side, indeed we were receiving the ID as a JS Number, except that the cast to a String for the DB was done automatically by Sequelize, and I think it thought our Number was a float.
By doing the cast ourselves in the Telegram service with a .toString(), the bug is no longer present.
I wrote a whole battery of tests to make sure the problem doesn’t happen again.
Thanks to those who took the time to give me the right information, it’s a pretty funny bug because it only affected 10% of users, because the cast seems to take this number for a float only if your Telegram ID ends with a 9! 1 in 10 chance