Closed OliverWieland closed 3 years ago
I would have implemented that years ago if Telegram would support that. Don't ask me why but there is no way to resolve a chatId by username. Sorry but this is not possible.
@windkh I was thinking of something like this: sendMsgByUsername
It is not ready, because I don't know what is the best practice to store the lookup table in a node red node. But principally this works (except for storing the data persistently).
So you want to configure a local lookup table for your own to be able to resolve the username. There are several ways how that can be implemented. Can you describe the use-case why you need this, so that I better understand. Right now I do not really see the point why this is needed as every received message contains the user name anyway.
The use-case is, that I have a few users. Everyone of them can select in the Dashboard which notifications he/she wants to receive, but a normal user doesn't know his/her id, but his/her username. Of course I could store this lookup table in my NodeRed-Application, but I thought, it would be nice to have that in the telegram nodes itself.
FYI FHEM has this kind of mechanism in his telegram module implemented, and it's very nice and smooth to use, that the user has not to think about his cryptic id.
I want to send my messages by username.
My proposal: The data from the bot's api includes the user name, so I suggest to save a lookup table with chatId and username. In the payload.chatId of the telegram sender node will be differentiated if the type of the content is numeric or string. If it's numeric, the content will be used as chatId. If it is a string, it is a usernam and the chatId will be determined through a search in the lookup table.
Alternative proposal: The sender's payload will be extended by a new key named 'userName'. Either 'userName' or 'chatId' ha to be set. If both are set, one of both has a higher priority (don't know which makes more sense).